source: webkit/trunk/JavaScriptCore/kjs/interpreter.cpp@ 34842

Last change on this file since 34842 was 34842, checked in by [email protected], 17 years ago

Bug 18626: SQUIRRELFISH: support the "slow script" dialog <https://bugs.webkit.org/show_bug.cgi?id=18626>
<rdar://problem/5973931> Slow script dialog needs to be reimplemented for squirrelfish

Reviewed by Sam

Adds support for the slow script dialog in squirrelfish. This requires the addition
of three new op codes, op_loop, op_loop_if_true, and op_loop_if_less which have the
same behaviour as their simple jump equivalents but have an additional time out check.

Additional assertions were added to other jump instructions to prevent accidentally
creating loops with jump types that do not support time out checks.

Sunspider does not report a regression, however this appears very sensitive to code
layout and hardware, so i would expect up to a 1% regression on other systems.

Part of this required moving the old timeout logic from JSGlobalObject and into Machine
which is the cause of a number of the larger diff blocks.

  • Property svn:eol-style set to native
File size: 3.5 KB
Line 
1/*
2 * Copyright (C) 1999-2001 Harri Porten ([email protected])
3 * Copyright (C) 2001 Peter Kelly ([email protected])
4 * Copyright (C) 2003, 2007 Apple Inc.
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
20 *
21 */
22
23#include "config.h"
24#include "interpreter.h"
25
26#include "ExecState.h"
27#include "JSGlobalObject.h"
28#include "Machine.h"
29#include "Parser.h"
30#include "completion.h"
31#include "debugger.h"
32#include <profiler/Profiler.h>
33#include <stdio.h>
34
35#if !PLATFORM(WIN_OS)
36#include <unistd.h>
37#endif
38
39namespace KJS {
40
41Completion Interpreter::checkSyntax(ExecState* exec, const UString& sourceURL, int startingLineNumber, const UString& code)
42{
43 return checkSyntax(exec, sourceURL, startingLineNumber, UStringSourceProvider::create(code));
44}
45
46Completion Interpreter::checkSyntax(ExecState* exec, const UString& sourceURL, int startingLineNumber, PassRefPtr<SourceProvider> source)
47{
48 JSLock lock;
49
50 int errLine;
51 UString errMsg;
52
53 RefPtr<ProgramNode> progNode = exec->parser()->parse<ProgramNode>(exec, sourceURL, startingLineNumber, source, 0, &errLine, &errMsg);
54 if (!progNode)
55 return Completion(Throw, Error::create(exec, SyntaxError, errMsg, errLine, 0, sourceURL));
56 return Completion(Normal);
57}
58
59Completion Interpreter::evaluate(ExecState* exec, ScopeChain& scopeChain, const UString& sourceURL, int startingLineNumber, const UString& code, JSValue* thisV)
60{
61 return evaluate(exec, scopeChain, sourceURL, startingLineNumber, UStringSourceProvider::create(code), thisV);
62}
63
64Completion Interpreter::evaluate(ExecState* exec, ScopeChain& scopeChain, const UString& sourceURL, int startingLineNumber, PassRefPtr<SourceProvider> source, JSValue* thisValue)
65{
66 JSLock lock;
67
68 // parse the source code
69 int sourceId;
70 int errLine;
71 UString errMsg;
72
73 RefPtr<ProgramNode> programNode = exec->parser()->parse<ProgramNode>(exec, sourceURL, startingLineNumber, source, &sourceId, &errLine, &errMsg);
74
75 // no program node means a syntax error occurred
76 if (!programNode)
77 return Completion(Throw, Error::create(exec, SyntaxError, errMsg, errLine, sourceId, sourceURL));
78
79 JSObject* thisObj = (!thisValue || thisValue->isUndefinedOrNull()) ? exec->dynamicGlobalObject() : thisValue->toObject(exec);
80
81 JSValue* exception = 0;
82 JSValue* result = exec->machine()->execute(programNode.get(), exec, scopeChain.node(), thisObj, &exception);
83
84 if (exception) {
85 if (exception->isObject() && static_cast<JSObject*>(exception)->isWatchdogException())
86 return Completion(Interrupted, result);
87 return Completion(Throw, exception);
88 }
89 return Completion(Normal, result);
90}
91
92static bool printExceptions = false;
93
94bool Interpreter::shouldPrintExceptions()
95{
96 return printExceptions;
97}
98
99void Interpreter::setShouldPrintExceptions(bool print)
100{
101 printExceptions = print;
102}
103
104} // namespace KJS
Note: See TracBrowser for help on using the repository browser.