summaryrefslogtreecommitdiffstats
path: root/JavaScriptCore
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2010-05-26 10:11:43 +0100
committerSteve Block <steveblock@google.com>2010-05-27 11:14:42 +0100
commite78cbe89e6f337f2f1fe40315be88f742b547151 (patch)
treed778000b84a04f24bbad50c7fa66244365e960e9 /JavaScriptCore
parent7b582e96e4e909ed7dba1e07153d20fbddaec3f7 (diff)
downloadexternal_webkit-e78cbe89e6f337f2f1fe40315be88f742b547151.zip
external_webkit-e78cbe89e6f337f2f1fe40315be88f742b547151.tar.gz
external_webkit-e78cbe89e6f337f2f1fe40315be88f742b547151.tar.bz2
Merge WebKit at r60074: Initial merge by git
Change-Id: I18a2dc5439e36c928351ea829d8fb4e39b062fc7
Diffstat (limited to 'JavaScriptCore')
-rw-r--r--JavaScriptCore/API/JSCallbackConstructor.cpp4
-rw-r--r--JavaScriptCore/API/JSCallbackConstructor.h6
-rw-r--r--JavaScriptCore/API/JSCallbackFunction.cpp4
-rw-r--r--JavaScriptCore/API/JSCallbackFunction.h2
-rw-r--r--JavaScriptCore/API/JSCallbackObject.cpp4
-rw-r--r--JavaScriptCore/API/JSCallbackObject.h4
-rw-r--r--JavaScriptCore/API/JSCallbackObjectFunctions.h11
-rw-r--r--JavaScriptCore/API/JSClassRef.cpp2
-rw-r--r--JavaScriptCore/API/JSContextRef.cpp2
-rw-r--r--JavaScriptCore/API/JSObjectRef.cpp26
-rw-r--r--JavaScriptCore/API/JSStringRefBSTR.cpp2
-rw-r--r--JavaScriptCore/API/JSValueRef.cpp4
-rw-r--r--JavaScriptCore/API/JSWeakObjectMapRefPrivate.cpp2
-rw-r--r--JavaScriptCore/Android.mk1
-rw-r--r--JavaScriptCore/CMakeLists.txt2
-rw-r--r--JavaScriptCore/ChangeLog1199
-rw-r--r--JavaScriptCore/Configurations/FeatureDefines.xcconfig3
-rw-r--r--JavaScriptCore/Configurations/Version.xcconfig2
-rw-r--r--JavaScriptCore/GNUmakefile.am2
-rw-r--r--JavaScriptCore/JavaScriptCore.exp21
-rw-r--r--JavaScriptCore/JavaScriptCore.gypi4
-rw-r--r--JavaScriptCore/JavaScriptCore.pro2
-rw-r--r--JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def13
-rw-r--r--JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj12
-rw-r--r--JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj44
-rw-r--r--JavaScriptCore/bytecode/CodeBlock.cpp43
-rw-r--r--JavaScriptCore/bytecode/CodeBlock.h44
-rw-r--r--JavaScriptCore/bytecode/Opcode.h19
-rw-r--r--JavaScriptCore/bytecompiler/BytecodeGenerator.cpp88
-rw-r--r--JavaScriptCore/bytecompiler/BytecodeGenerator.h34
-rw-r--r--JavaScriptCore/bytecompiler/NodesCodegen.cpp34
-rw-r--r--JavaScriptCore/interpreter/CallFrame.h12
-rw-r--r--JavaScriptCore/interpreter/CallFrameClosure.h2
-rw-r--r--JavaScriptCore/interpreter/Interpreter.cpp443
-rw-r--r--JavaScriptCore/interpreter/Interpreter.h9
-rw-r--r--JavaScriptCore/interpreter/Register.h2
-rw-r--r--JavaScriptCore/interpreter/RegisterFile.h19
-rw-r--r--JavaScriptCore/jit/JIT.cpp54
-rw-r--r--JavaScriptCore/jit/JIT.h41
-rw-r--r--JavaScriptCore/jit/JITArithmetic.cpp8
-rw-r--r--JavaScriptCore/jit/JITArithmetic32_64.cpp10
-rw-r--r--JavaScriptCore/jit/JITCall.cpp475
-rw-r--r--JavaScriptCore/jit/JITCall32_64.cpp427
-rw-r--r--JavaScriptCore/jit/JITInlineMethods.h62
-rw-r--r--JavaScriptCore/jit/JITOpcodes.cpp136
-rw-r--r--JavaScriptCore/jit/JITOpcodes32_64.cpp331
-rw-r--r--JavaScriptCore/jit/JITPropertyAccess.cpp17
-rw-r--r--JavaScriptCore/jit/JITPropertyAccess32_64.cpp26
-rw-r--r--JavaScriptCore/jit/JITStubCall.h10
-rw-r--r--JavaScriptCore/jit/JITStubs.cpp119
-rw-r--r--JavaScriptCore/jit/JITStubs.h25
-rw-r--r--JavaScriptCore/jit/JSInterfaceJIT.h23
-rw-r--r--JavaScriptCore/jit/SpecializedThunkJIT.h6
-rw-r--r--JavaScriptCore/jit/ThunkGenerators.cpp31
-rw-r--r--JavaScriptCore/jit/ThunkGenerators.h15
-rw-r--r--JavaScriptCore/jsc.cpp22
-rw-r--r--JavaScriptCore/profiler/ProfileNode.cpp2
-rw-r--r--JavaScriptCore/profiler/Profiler.cpp3
-rw-r--r--JavaScriptCore/qt/tests/qscriptvalue/qscriptvalue.pro4
-rw-r--r--JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue.h2
-rw-r--r--JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue_generated.cpp1922
-rw-r--r--JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue_generated_init.cpp165
-rw-r--r--JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue_generated_istype.cpp567
-rw-r--r--JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue_generated_totype.cpp1763
-rw-r--r--JavaScriptCore/runtime/Arguments.h12
-rw-r--r--JavaScriptCore/runtime/ArrayConstructor.cpp6
-rw-r--r--JavaScriptCore/runtime/ArrayConstructor.h2
-rw-r--r--JavaScriptCore/runtime/ArrayPrototype.cpp3
-rw-r--r--JavaScriptCore/runtime/ArrayPrototype.h10
-rw-r--r--JavaScriptCore/runtime/BooleanConstructor.cpp4
-rw-r--r--JavaScriptCore/runtime/BooleanConstructor.h2
-rw-r--r--JavaScriptCore/runtime/BooleanPrototype.cpp6
-rw-r--r--JavaScriptCore/runtime/BooleanPrototype.h2
-rw-r--r--JavaScriptCore/runtime/DateConstructor.cpp10
-rw-r--r--JavaScriptCore/runtime/DateConstructor.h2
-rw-r--r--JavaScriptCore/runtime/DatePrototype.cpp3
-rw-r--r--JavaScriptCore/runtime/DatePrototype.h2
-rw-r--r--JavaScriptCore/runtime/ErrorConstructor.cpp4
-rw-r--r--JavaScriptCore/runtime/ErrorConstructor.h2
-rw-r--r--JavaScriptCore/runtime/ErrorPrototype.cpp4
-rw-r--r--JavaScriptCore/runtime/ErrorPrototype.h2
-rw-r--r--JavaScriptCore/runtime/Executable.h37
-rw-r--r--JavaScriptCore/runtime/FunctionConstructor.cpp4
-rw-r--r--JavaScriptCore/runtime/FunctionConstructor.h2
-rw-r--r--JavaScriptCore/runtime/FunctionPrototype.cpp24
-rw-r--r--JavaScriptCore/runtime/FunctionPrototype.h4
-rw-r--r--JavaScriptCore/runtime/GlobalEvalFunction.cpp4
-rw-r--r--JavaScriptCore/runtime/GlobalEvalFunction.h2
-rw-r--r--JavaScriptCore/runtime/InternalFunction.cpp14
-rw-r--r--JavaScriptCore/runtime/InternalFunction.h10
-rw-r--r--JavaScriptCore/runtime/JSActivation.cpp34
-rw-r--r--JavaScriptCore/runtime/JSActivation.h2
-rw-r--r--JavaScriptCore/runtime/JSCell.h8
-rw-r--r--JavaScriptCore/runtime/JSFunction.cpp66
-rw-r--r--JavaScriptCore/runtime/JSFunction.h59
-rw-r--r--JavaScriptCore/runtime/JSGlobalData.cpp11
-rw-r--r--JavaScriptCore/runtime/JSGlobalData.h6
-rw-r--r--JavaScriptCore/runtime/JSGlobalObject.cpp98
-rw-r--r--JavaScriptCore/runtime/JSGlobalObject.h15
-rw-r--r--JavaScriptCore/runtime/JSONObject.cpp6
-rw-r--r--JavaScriptCore/runtime/JSONObject.h9
-rw-r--r--JavaScriptCore/runtime/JSObject.cpp11
-rw-r--r--JavaScriptCore/runtime/JSObject.h11
-rw-r--r--JavaScriptCore/runtime/JSObjectWithGlobalObject.cpp46
-rw-r--r--JavaScriptCore/runtime/JSObjectWithGlobalObject.h58
-rw-r--r--JavaScriptCore/runtime/JSString.cpp3
-rw-r--r--JavaScriptCore/runtime/JSString.h9
-rw-r--r--JavaScriptCore/runtime/JSValue.cpp5
-rw-r--r--JavaScriptCore/runtime/JSValue.h1
-rw-r--r--JavaScriptCore/runtime/Lookup.cpp10
-rw-r--r--JavaScriptCore/runtime/MathObject.cpp4
-rw-r--r--JavaScriptCore/runtime/MathObject.h6
-rw-r--r--JavaScriptCore/runtime/NativeErrorConstructor.cpp11
-rw-r--r--JavaScriptCore/runtime/NativeErrorConstructor.h2
-rw-r--r--JavaScriptCore/runtime/NativeErrorPrototype.cpp11
-rw-r--r--JavaScriptCore/runtime/NativeErrorPrototype.h7
-rw-r--r--JavaScriptCore/runtime/NumberConstructor.cpp4
-rw-r--r--JavaScriptCore/runtime/NumberConstructor.h2
-rw-r--r--JavaScriptCore/runtime/NumberPrototype.cpp14
-rw-r--r--JavaScriptCore/runtime/NumberPrototype.h2
-rw-r--r--JavaScriptCore/runtime/ObjectConstructor.cpp18
-rw-r--r--JavaScriptCore/runtime/ObjectConstructor.h2
-rw-r--r--JavaScriptCore/runtime/ObjectPrototype.cpp22
-rw-r--r--JavaScriptCore/runtime/ObjectPrototype.h2
-rw-r--r--JavaScriptCore/runtime/PrototypeFunction.cpp8
-rw-r--r--JavaScriptCore/runtime/PrototypeFunction.h4
-rw-r--r--JavaScriptCore/runtime/RegExpConstructor.cpp6
-rw-r--r--JavaScriptCore/runtime/RegExpConstructor.h2
-rw-r--r--JavaScriptCore/runtime/RegExpObject.cpp4
-rw-r--r--JavaScriptCore/runtime/RegExpObject.h10
-rw-r--r--JavaScriptCore/runtime/RegExpPrototype.cpp10
-rw-r--r--JavaScriptCore/runtime/RegExpPrototype.h2
-rw-r--r--JavaScriptCore/runtime/StringConstructor.cpp10
-rw-r--r--JavaScriptCore/runtime/StringConstructor.h2
-rw-r--r--JavaScriptCore/runtime/StringPrototype.cpp5
-rw-r--r--JavaScriptCore/runtime/StringPrototype.h2
-rw-r--r--JavaScriptCore/runtime/UString.cpp2
-rw-r--r--JavaScriptCore/wtf/CurrentTime.cpp1
-rw-r--r--JavaScriptCore/wtf/ListHashSet.h206
-rw-r--r--JavaScriptCore/wtf/MainThread.cpp2
-rw-r--r--JavaScriptCore/wtf/Platform.h10
-rw-r--r--JavaScriptCore/wtf/SizeLimits.cpp56
-rw-r--r--JavaScriptCore/wtf/StringExtras.h2
-rw-r--r--JavaScriptCore/wtf/text/StringImpl.cpp2
-rw-r--r--JavaScriptCore/yarr/RegexInterpreter.cpp2
145 files changed, 6019 insertions, 3474 deletions
diff --git a/JavaScriptCore/API/JSCallbackConstructor.cpp b/JavaScriptCore/API/JSCallbackConstructor.cpp
index 9c5f6d7..2948932 100644
--- a/JavaScriptCore/API/JSCallbackConstructor.cpp
+++ b/JavaScriptCore/API/JSCallbackConstructor.cpp
@@ -37,8 +37,8 @@ namespace JSC {
const ClassInfo JSCallbackConstructor::info = { "CallbackConstructor", 0, 0, 0 };
-JSCallbackConstructor::JSCallbackConstructor(NonNullPassRefPtr<Structure> structure, JSClassRef jsClass, JSObjectCallAsConstructorCallback callback)
- : JSObject(structure)
+JSCallbackConstructor::JSCallbackConstructor(JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, JSClassRef jsClass, JSObjectCallAsConstructorCallback callback)
+ : JSObjectWithGlobalObject(globalObject, structure)
, m_class(jsClass)
, m_callback(callback)
{
diff --git a/JavaScriptCore/API/JSCallbackConstructor.h b/JavaScriptCore/API/JSCallbackConstructor.h
index e529947..a6d64cc 100644
--- a/JavaScriptCore/API/JSCallbackConstructor.h
+++ b/JavaScriptCore/API/JSCallbackConstructor.h
@@ -27,13 +27,13 @@
#define JSCallbackConstructor_h
#include "JSObjectRef.h"
-#include <runtime/JSObject.h>
+#include <runtime/JSObjectWithGlobalObject.h>
namespace JSC {
-class JSCallbackConstructor : public JSObject {
+class JSCallbackConstructor : public JSObjectWithGlobalObject {
public:
- JSCallbackConstructor(NonNullPassRefPtr<Structure>, JSClassRef, JSObjectCallAsConstructorCallback);
+ JSCallbackConstructor(JSGlobalObject*, NonNullPassRefPtr<Structure>, JSClassRef, JSObjectCallAsConstructorCallback);
virtual ~JSCallbackConstructor();
JSClassRef classRef() const { return m_class; }
JSObjectCallAsConstructorCallback callback() const { return m_callback; }
diff --git a/JavaScriptCore/API/JSCallbackFunction.cpp b/JavaScriptCore/API/JSCallbackFunction.cpp
index 63c8add..4953010 100644
--- a/JavaScriptCore/API/JSCallbackFunction.cpp
+++ b/JavaScriptCore/API/JSCallbackFunction.cpp
@@ -41,8 +41,8 @@ ASSERT_CLASS_FITS_IN_CELL(JSCallbackFunction);
const ClassInfo JSCallbackFunction::info = { "CallbackFunction", &InternalFunction::info, 0, 0 };
-JSCallbackFunction::JSCallbackFunction(ExecState* exec, JSObjectCallAsFunctionCallback callback, const Identifier& name)
- : InternalFunction(&exec->globalData(), exec->lexicalGlobalObject()->callbackFunctionStructure(), name)
+JSCallbackFunction::JSCallbackFunction(ExecState* exec, JSGlobalObject* globalObject, JSObjectCallAsFunctionCallback callback, const Identifier& name)
+ : InternalFunction(&exec->globalData(), globalObject, globalObject->callbackFunctionStructure(), name)
, m_callback(callback)
{
}
diff --git a/JavaScriptCore/API/JSCallbackFunction.h b/JavaScriptCore/API/JSCallbackFunction.h
index 10dae6b..b0dc425 100644
--- a/JavaScriptCore/API/JSCallbackFunction.h
+++ b/JavaScriptCore/API/JSCallbackFunction.h
@@ -33,7 +33,7 @@ namespace JSC {
class JSCallbackFunction : public InternalFunction {
public:
- JSCallbackFunction(ExecState*, JSObjectCallAsFunctionCallback, const Identifier& name);
+ JSCallbackFunction(ExecState*, JSGlobalObject*, JSObjectCallAsFunctionCallback, const Identifier& name);
static const ClassInfo info;
diff --git a/JavaScriptCore/API/JSCallbackObject.cpp b/JavaScriptCore/API/JSCallbackObject.cpp
index b36c194..abd2adc 100644
--- a/JavaScriptCore/API/JSCallbackObject.cpp
+++ b/JavaScriptCore/API/JSCallbackObject.cpp
@@ -32,11 +32,11 @@
namespace JSC {
-ASSERT_CLASS_FITS_IN_CELL(JSCallbackObject<JSObject>);
+ASSERT_CLASS_FITS_IN_CELL(JSCallbackObject<JSObjectWithGlobalObject>);
ASSERT_CLASS_FITS_IN_CELL(JSCallbackObject<JSGlobalObject>);
// Define the two types of JSCallbackObjects we support.
-template <> const ClassInfo JSCallbackObject<JSObject>::info = { "CallbackObject", 0, 0, 0 };
+template <> const ClassInfo JSCallbackObject<JSObjectWithGlobalObject>::info = { "CallbackObject", 0, 0, 0 };
template <> const ClassInfo JSCallbackObject<JSGlobalObject>::info = { "CallbackGlobalObject", 0, 0, 0 };
} // namespace JSC
diff --git a/JavaScriptCore/API/JSCallbackObject.h b/JavaScriptCore/API/JSCallbackObject.h
index 1cf7a02..0660b45 100644
--- a/JavaScriptCore/API/JSCallbackObject.h
+++ b/JavaScriptCore/API/JSCallbackObject.h
@@ -114,8 +114,8 @@ struct JSCallbackObjectData {
template <class Base>
class JSCallbackObject : public Base {
public:
- JSCallbackObject(ExecState*, NonNullPassRefPtr<Structure>, JSClassRef, void* data);
- JSCallbackObject(JSClassRef);
+ JSCallbackObject(ExecState*, JSGlobalObject*, NonNullPassRefPtr<Structure>, JSClassRef, void* data);
+ JSCallbackObject(JSClassRef, NonNullPassRefPtr<Structure>);
virtual ~JSCallbackObject();
void setPrivate(void* data);
diff --git a/JavaScriptCore/API/JSCallbackObjectFunctions.h b/JavaScriptCore/API/JSCallbackObjectFunctions.h
index 6c83eb4..6573ed9 100644
--- a/JavaScriptCore/API/JSCallbackObjectFunctions.h
+++ b/JavaScriptCore/API/JSCallbackObjectFunctions.h
@@ -48,8 +48,8 @@ inline JSCallbackObject<Base>* JSCallbackObject<Base>::asCallbackObject(JSValue
}
template <class Base>
-JSCallbackObject<Base>::JSCallbackObject(ExecState* exec, NonNullPassRefPtr<Structure> structure, JSClassRef jsClass, void* data)
- : Base(structure)
+JSCallbackObject<Base>::JSCallbackObject(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, JSClassRef jsClass, void* data)
+ : Base(globalObject, structure)
, m_callbackObjectData(new JSCallbackObjectData(data, jsClass))
{
init(exec);
@@ -58,8 +58,8 @@ JSCallbackObject<Base>::JSCallbackObject(ExecState* exec, NonNullPassRefPtr<Stru
// Global object constructor.
// FIXME: Move this into a separate JSGlobalCallbackObject class derived from this one.
template <class Base>
-JSCallbackObject<Base>::JSCallbackObject(JSClassRef jsClass)
- : Base()
+JSCallbackObject<Base>::JSCallbackObject(JSClassRef jsClass, NonNullPassRefPtr<Structure> structure)
+ : Base(structure)
, m_callbackObjectData(new JSCallbackObjectData(0, jsClass))
{
ASSERT(Base::isGlobalObject());
@@ -560,7 +560,8 @@ JSValue JSCallbackObject<Base>::staticFunctionGetter(ExecState* exec, JSValue sl
if (OpaqueJSClassStaticFunctionsTable* staticFunctions = jsClass->staticFunctions(exec)) {
if (StaticFunctionEntry* entry = staticFunctions->get(propertyName.ustring().rep())) {
if (JSObjectCallAsFunctionCallback callAsFunction = entry->callAsFunction) {
- JSObject* o = new (exec) JSCallbackFunction(exec, callAsFunction, propertyName);
+
+ JSObject* o = new (exec) JSCallbackFunction(exec, asGlobalObject(thisObj->getAnonymousValue(0)), callAsFunction, propertyName);
thisObj->putDirect(propertyName, o, entry->attributes);
return o;
}
diff --git a/JavaScriptCore/API/JSClassRef.cpp b/JavaScriptCore/API/JSClassRef.cpp
index 3e65b75..d8393f1 100644
--- a/JavaScriptCore/API/JSClassRef.cpp
+++ b/JavaScriptCore/API/JSClassRef.cpp
@@ -256,7 +256,7 @@ JSObject* OpaqueJSClass::prototype(ExecState* exec)
if (!jsClassData.cachedPrototype) {
// Recursive, but should be good enough for our purposes
- jsClassData.cachedPrototype = new (exec) JSCallbackObject<JSObject>(exec, exec->lexicalGlobalObject()->callbackObjectStructure(), prototypeClass, &jsClassData); // set jsClassData as the object's private data, so it can clear our reference on destruction
+ jsClassData.cachedPrototype = new (exec) JSCallbackObject<JSObjectWithGlobalObject>(exec, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->callbackObjectStructure(), prototypeClass, &jsClassData); // set jsClassData as the object's private data, so it can clear our reference on destruction
if (parentClass) {
if (JSObject* prototype = parentClass->prototype(exec))
jsClassData.cachedPrototype->setPrototype(prototype);
diff --git a/JavaScriptCore/API/JSContextRef.cpp b/JavaScriptCore/API/JSContextRef.cpp
index b97ceda..926badc 100644
--- a/JavaScriptCore/API/JSContextRef.cpp
+++ b/JavaScriptCore/API/JSContextRef.cpp
@@ -97,7 +97,7 @@ JSGlobalContextRef JSGlobalContextCreateInGroup(JSContextGroupRef group, JSClass
return JSGlobalContextRetain(toGlobalRef(globalObject->globalExec()));
}
- JSGlobalObject* globalObject = new (globalData.get()) JSCallbackObject<JSGlobalObject>(globalObjectClass);
+ JSGlobalObject* globalObject = new (globalData.get()) JSCallbackObject<JSGlobalObject>(globalObjectClass, JSCallbackObject<JSGlobalObject>::createStructure(jsNull()));
ExecState* exec = globalObject->globalExec();
JSValue prototype = globalObjectClass->prototype(exec);
if (!prototype)
diff --git a/JavaScriptCore/API/JSObjectRef.cpp b/JavaScriptCore/API/JSObjectRef.cpp
index 8fdbdab..73bba67 100644
--- a/JavaScriptCore/API/JSObjectRef.cpp
+++ b/JavaScriptCore/API/JSObjectRef.cpp
@@ -81,7 +81,7 @@ JSObjectRef JSObjectMake(JSContextRef ctx, JSClassRef jsClass, void* data)
if (!jsClass)
return toRef(new (exec) JSObject(exec->lexicalGlobalObject()->emptyObjectStructure())); // slightly more efficient
- JSCallbackObject<JSObject>* object = new (exec) JSCallbackObject<JSObject>(exec, exec->lexicalGlobalObject()->callbackObjectStructure(), jsClass, data);
+ JSCallbackObject<JSObjectWithGlobalObject>* object = new (exec) JSCallbackObject<JSObjectWithGlobalObject>(exec, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->callbackObjectStructure(), jsClass, data);
if (JSObject* prototype = jsClass->prototype(exec))
object->setPrototype(prototype);
@@ -95,7 +95,7 @@ JSObjectRef JSObjectMakeFunctionWithCallback(JSContextRef ctx, JSStringRef name,
Identifier nameID = name ? name->identifier(&exec->globalData()) : Identifier(exec, "anonymous");
- return toRef(new (exec) JSCallbackFunction(exec, callAsFunction, nameID));
+ return toRef(new (exec) JSCallbackFunction(exec, exec->lexicalGlobalObject(), callAsFunction, nameID));
}
JSObjectRef JSObjectMakeConstructor(JSContextRef ctx, JSClassRef jsClass, JSObjectCallAsConstructorCallback callAsConstructor)
@@ -107,7 +107,7 @@ JSObjectRef JSObjectMakeConstructor(JSContextRef ctx, JSClassRef jsClass, JSObje
if (!jsPrototype)
jsPrototype = exec->lexicalGlobalObject()->objectPrototype();
- JSCallbackConstructor* constructor = new (exec) JSCallbackConstructor(exec->lexicalGlobalObject()->callbackConstructorStructure(), jsClass, callAsConstructor);
+ JSCallbackConstructor* constructor = new (exec) JSCallbackConstructor(exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->callbackConstructorStructure(), jsClass, callAsConstructor);
constructor->putDirect(exec->propertyNames().prototype, jsPrototype, DontEnum | DontDelete | ReadOnly);
return toRef(constructor);
}
@@ -343,8 +343,8 @@ void* JSObjectGetPrivate(JSObjectRef object)
if (jsObject->inherits(&JSCallbackObject<JSGlobalObject>::info))
return static_cast<JSCallbackObject<JSGlobalObject>*>(jsObject)->getPrivate();
- else if (jsObject->inherits(&JSCallbackObject<JSObject>::info))
- return static_cast<JSCallbackObject<JSObject>*>(jsObject)->getPrivate();
+ else if (jsObject->inherits(&JSCallbackObject<JSObjectWithGlobalObject>::info))
+ return static_cast<JSCallbackObject<JSObjectWithGlobalObject>*>(jsObject)->getPrivate();
return 0;
}
@@ -356,8 +356,8 @@ bool JSObjectSetPrivate(JSObjectRef object, void* data)
if (jsObject->inherits(&JSCallbackObject<JSGlobalObject>::info)) {
static_cast<JSCallbackObject<JSGlobalObject>*>(jsObject)->setPrivate(data);
return true;
- } else if (jsObject->inherits(&JSCallbackObject<JSObject>::info)) {
- static_cast<JSCallbackObject<JSObject>*>(jsObject)->setPrivate(data);
+ } else if (jsObject->inherits(&JSCallbackObject<JSObjectWithGlobalObject>::info)) {
+ static_cast<JSCallbackObject<JSObjectWithGlobalObject>*>(jsObject)->setPrivate(data);
return true;
}
@@ -373,8 +373,8 @@ JSValueRef JSObjectGetPrivateProperty(JSContextRef ctx, JSObjectRef object, JSSt
Identifier name(propertyName->identifier(&exec->globalData()));
if (jsObject->inherits(&JSCallbackObject<JSGlobalObject>::info))
result = static_cast<JSCallbackObject<JSGlobalObject>*>(jsObject)->getPrivateProperty(name);
- else if (jsObject->inherits(&JSCallbackObject<JSObject>::info))
- result = static_cast<JSCallbackObject<JSObject>*>(jsObject)->getPrivateProperty(name);
+ else if (jsObject->inherits(&JSCallbackObject<JSObjectWithGlobalObject>::info))
+ result = static_cast<JSCallbackObject<JSObjectWithGlobalObject>*>(jsObject)->getPrivateProperty(name);
return toRef(exec, result);
}
@@ -389,8 +389,8 @@ bool JSObjectSetPrivateProperty(JSContextRef ctx, JSObjectRef object, JSStringRe
static_cast<JSCallbackObject<JSGlobalObject>*>(jsObject)->setPrivateProperty(name, jsValue);
return true;
}
- if (jsObject->inherits(&JSCallbackObject<JSObject>::info)) {
- static_cast<JSCallbackObject<JSObject>*>(jsObject)->setPrivateProperty(name, jsValue);
+ if (jsObject->inherits(&JSCallbackObject<JSObjectWithGlobalObject>::info)) {
+ static_cast<JSCallbackObject<JSObjectWithGlobalObject>*>(jsObject)->setPrivateProperty(name, jsValue);
return true;
}
return false;
@@ -406,8 +406,8 @@ bool JSObjectDeletePrivateProperty(JSContextRef ctx, JSObjectRef object, JSStrin
static_cast<JSCallbackObject<JSGlobalObject>*>(jsObject)->deletePrivateProperty(name);
return true;
}
- if (jsObject->inherits(&JSCallbackObject<JSObject>::info)) {
- static_cast<JSCallbackObject<JSObject>*>(jsObject)->deletePrivateProperty(name);
+ if (jsObject->inherits(&JSCallbackObject<JSObjectWithGlobalObject>::info)) {
+ static_cast<JSCallbackObject<JSObjectWithGlobalObject>*>(jsObject)->deletePrivateProperty(name);
return true;
}
return false;
diff --git a/JavaScriptCore/API/JSStringRefBSTR.cpp b/JavaScriptCore/API/JSStringRefBSTR.cpp
index a7d3e99..70f4254 100644
--- a/JavaScriptCore/API/JSStringRefBSTR.cpp
+++ b/JavaScriptCore/API/JSStringRefBSTR.cpp
@@ -24,7 +24,7 @@
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+ */
#include "config.h"
#include "JSStringRefBSTR.h"
diff --git a/JavaScriptCore/API/JSValueRef.cpp b/JavaScriptCore/API/JSValueRef.cpp
index f5dcccc..a29a207 100644
--- a/JavaScriptCore/API/JSValueRef.cpp
+++ b/JavaScriptCore/API/JSValueRef.cpp
@@ -131,8 +131,8 @@ bool JSValueIsObjectOfClass(JSContextRef ctx, JSValueRef value, JSClassRef jsCla
if (JSObject* o = jsValue.getObject()) {
if (o->inherits(&JSCallbackObject<JSGlobalObject>::info))
return static_cast<JSCallbackObject<JSGlobalObject>*>(o)->inherits(jsClass);
- else if (o->inherits(&JSCallbackObject<JSObject>::info))
- return static_cast<JSCallbackObject<JSObject>*>(o)->inherits(jsClass);
+ else if (o->inherits(&JSCallbackObject<JSObjectWithGlobalObject>::info))
+ return static_cast<JSCallbackObject<JSObjectWithGlobalObject>*>(o)->inherits(jsClass);
}
return false;
}
diff --git a/JavaScriptCore/API/JSWeakObjectMapRefPrivate.cpp b/JavaScriptCore/API/JSWeakObjectMapRefPrivate.cpp
index 7e6bb63..9beeb82 100644
--- a/JavaScriptCore/API/JSWeakObjectMapRefPrivate.cpp
+++ b/JavaScriptCore/API/JSWeakObjectMapRefPrivate.cpp
@@ -58,7 +58,7 @@ void JSWeakObjectMapSet(JSContextRef ctx, JSWeakObjectMapRef map, void* key, JSO
JSObject* obj = toJS(object);
if (!obj)
return;
- ASSERT(obj->inherits(&JSCallbackObject<JSGlobalObject>::info) || obj->inherits(&JSCallbackObject<JSObject>::info));
+ ASSERT(obj->inherits(&JSCallbackObject<JSGlobalObject>::info) || obj->inherits(&JSCallbackObject<JSObjectWithGlobalObject>::info));
map->map().set(key, obj);
}
diff --git a/JavaScriptCore/Android.mk b/JavaScriptCore/Android.mk
index 211cea9..60ce27f 100644
--- a/JavaScriptCore/Android.mk
+++ b/JavaScriptCore/Android.mk
@@ -52,6 +52,7 @@ LOCAL_SRC_FILES := \
jit/JITArithmetic.cpp \
jit/JITArithmetic32_64.cpp \
jit/JITCall.cpp \
+ jit/JITCall32_64.cpp \
jit/JITOpcodes.cpp \
jit/JITPropertyAccess.cpp \
jit/JITStubs.cpp \
diff --git a/JavaScriptCore/CMakeLists.txt b/JavaScriptCore/CMakeLists.txt
index f0281e4..da7e119 100644
--- a/JavaScriptCore/CMakeLists.txt
+++ b/JavaScriptCore/CMakeLists.txt
@@ -61,6 +61,7 @@ SET(JavaScriptCore_SOURCES
jit/JITPropertyAccess32_64.cpp
jit/JITArithmetic.cpp
jit/JITCall.cpp
+ jit/JITCall32_64.cpp
jit/JIT.cpp
parser/Lexer.cpp
@@ -122,6 +123,7 @@ SET(JavaScriptCore_SOURCES
runtime/JSNotAnObject.cpp
runtime/JSNumberCell.cpp
runtime/JSObject.cpp
+ runtime/JSObjectWithGlobalObject.cpp
runtime/JSONObject.cpp
runtime/JSPropertyNameIterator.cpp
runtime/JSStaticScopeObject.cpp
diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index 85755cc..83076da 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -1,3 +1,1202 @@
+2010-05-23 Sam Weinig <sam@webkit.org>
+
+ Fix windows build.
+
+ * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:
+
+2010-05-23 Sam Weinig <sam@webkit.org>
+
+ Reviewed by Oliver Hunt.
+
+ Fix for https://bugs.webkit.org/show_bug.cgi?id=39575
+ Make JS DOMObject inherit from JSObjectWithGlobalObject instead of JSObject
+
+ Expose the global object stored in JSObjectWithGlobalObject.
+
+ * JavaScriptCore.exp:
+ * JavaScriptCore.xcodeproj/project.pbxproj:
+ * runtime/JSObjectWithGlobalObject.cpp:
+ (JSC::JSObjectWithGlobalObject::JSObjectWithGlobalObject):
+ (JSC::JSObjectWithGlobalObject::globalObject):
+ * runtime/JSObjectWithGlobalObject.h:
+
+2010-05-21 Oliver Hunt <oliver@apple.com>
+
+ "asm volatile" isn't valid outside of functions.
+
+ Reviewed by Gavin Barraclough.
+
+ * jit/JITStubs.cpp:
+
+2010-05-21 Gavin Barraclough <barraclough@apple.com>
+
+ Unreviewed build fix.
+
+ Interpreter fix following r59974.
+
+ * interpreter/Interpreter.cpp:
+ (JSC::Interpreter::privateExecute):
+ * runtime/JSPropertyNameIterator.cpp:
+ (JSC::JSPropertyNameIterator::get):
+ * runtime/JSPropertyNameIterator.h:
+
+2010-05-21 Gavin Barraclough <barraclough@apple.com>
+
+ Rubber stamped by Oliver Hunt.
+
+ Interpreter fix following r59939.
+
+ * interpreter/Interpreter.cpp:
+ (JSC::Interpreter::privateExecute):
+
+2010-05-21 David Levin <levin@chromium.org>
+
+ Unreviewed build fix.
+
+ * wtf/SizeLimits.cpp: Removed a check while I figure out how to write it properly.
+
+2010-05-21 David Levin <levin@chromium.org>
+
+ Reviewed by Darin Adler.
+
+ Enforce size constraints on various data structures in JavaScriptCore/wtf.
+ https://bugs.webkit.org/show_bug.cgi?id=39327
+
+ I only modified the default build for OSX and Chromium's build file to include WTFCompileAsserts.cpp
+ as those should be sufficient to catch regressions on the size of the data structures.
+
+ * JavaScriptCore.gypi: Added the WTFCompileAsserts.cpp file.
+ * JavaScriptCore.xcodeproj/project.pbxproj: Added the WTFCompileAsserts.cpp file.
+ * runtime/UString.cpp: Added a compile assert for UString size.
+ * wtf/SizeLimits.cpp: Added compile asserts for data structures that didn't have cpp files.
+ * wtf/text/StringImpl.cpp: Added a compile assert for StringImpl size.
+
+2010-05-21 Gavin Barraclough <barraclough@apple.com>
+
+ Reviewed by Oliver Hunt.
+
+ Bug 39509 - Exceptions raised when JSString::value() is called not always properly thrown.
+ Missing some CHECK_FOR_EXCEPTION()s, cleanup NativeError construction (adding a property
+ via the prototype was inefficient, and whilst trivially true that the property is is not
+ a rope - and thus couldn't except - it would be hard to prove this).
+
+ * interpreter/Interpreter.cpp:
+ (JSC::Interpreter::callEval):
+ (JSC::Interpreter::privateExecute):
+ * jit/JITStubs.cpp:
+ (JSC::DEFINE_STUB_FUNCTION):
+ * runtime/InternalFunction.cpp:
+ (JSC::InternalFunction::name):
+ (JSC::InternalFunction::displayName):
+ * runtime/JSFunction.cpp:
+ (JSC::JSFunction::name):
+ (JSC::JSFunction::displayName):
+ * runtime/JSGlobalObject.cpp:
+ (JSC::JSGlobalObject::reset):
+ * runtime/JSPropertyNameIterator.cpp:
+ * runtime/JSPropertyNameIterator.h:
+ * runtime/JSString.h:
+ (JSC::RopeBuilder::tryGetValue):
+ (JSC::JSString::getIndex):
+ * runtime/NativeErrorConstructor.cpp:
+ (JSC::NativeErrorConstructor::NativeErrorConstructor):
+ * runtime/NativeErrorConstructor.h:
+ * runtime/NativeErrorPrototype.cpp:
+ (JSC::NativeErrorPrototype::NativeErrorPrototype):
+ * runtime/NativeErrorPrototype.h:
+ * runtime/StringPrototype.cpp:
+ (JSC::stringProtoFuncReplace):
+
+2010-05-21 Gavin Barraclough <barraclough@apple.com>
+
+ Reviewed by NOBODY (build fix).
+
+ Fix interpreter build.
+
+ * interpreter/Interpreter.cpp:
+ (JSC::Interpreter::privateExecute):
+
+2010-05-21 Geoffrey Garen <ggaren@apple.com>
+
+ Reviewed by Gavin Barraclough.
+
+ Split out JITCall32_64.cpp, and tightened up some #ifdefs in the hopes
+ of improving compile times.
+ https://bugs.webkit.org/show_bug.cgi?id=39507
+
+ * JavaScriptCore.xcodeproj/project.pbxproj:
+ * jit/JIT.cpp:
+ * jit/JITArithmetic.cpp:
+ * jit/JITArithmetic32_64.cpp:
+ * jit/JITCall.cpp:
+ * jit/JITCall32_64.cpp: Copied from jit/JITCall.cpp.
+ * jit/JITOpcodes.cpp:
+ * jit/JITOpcodes32_64.cpp:
+ * jit/JITPropertyAccess.cpp:
+ * jit/JITPropertyAccess32_64.cpp:
+ * jit/JITStubs.cpp:
+
+2010-05-21 Csaba Osztrogonác <ossy@webkit.org>
+
+ Unreviewed buildfix for Qt after r59941.
+
+ * JavaScriptCore.pro: missing runtime/JSObjectWithGlobalObject.cpp added to SOURCES.
+
+2010-05-21 Oliver Hunt <oliver@apple.com>
+
+ Windows build fix #3
+
+ * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:
+
+2010-05-21 Oliver Hunt <oliver@apple.com>
+
+ Windows build fix #2
+
+ * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:
+
+2010-05-21 Oliver Hunt <oliver@apple.com>
+
+ Windows build fix #1
+
+ * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:
+
+2010-05-21 Oliver Hunt <oliver@apple.com>
+
+ Reviewed by Geoffrey Garen.
+
+ All callable objects should have a global object reference
+ https://bugs.webkit.org/show_bug.cgi?id=39495
+
+ All objects that may ever return a value other CallTypeNone
+ or ConstructTypeNone now get a global object in their constructor
+ and store that in their first anonymous slot. We add a new type
+ JSObjectWithGlobalObject to allow us to share this logic as much
+ as possible, however some objects have specific inheritance
+ requirements so we can't just use it universally.
+
+ To enforce this requirement JSValue::getCallData and getConstructData
+ make use of a new "isValidCallee" function to assert that any object
+ that returns a value other than CallType/ConstructTypeNone has a
+ global object in anonymous slot 0.
+
+ In order to ensure that static function slots are converted into
+ function objects with the correct global object, all prototype objects
+ and other classes with static function slots also gain a global object
+ reference. Happily this fixes the long standing issue where host
+ function objects get a prototype from the lexical global object of the
+ first function that calls them, instead of the global object that they
+ are defined on.
+
+ * API/JSCallbackConstructor.cpp:
+ (JSC::JSCallbackConstructor::JSCallbackConstructor):
+ * API/JSCallbackConstructor.h:
+ * API/JSCallbackFunction.cpp:
+ (JSC::JSCallbackFunction::JSCallbackFunction):
+ * API/JSCallbackFunction.h:
+ * API/JSCallbackObject.cpp:
+ (JSC::):
+ * API/JSCallbackObject.h:
+ * API/JSCallbackObjectFunctions.h:
+ (JSC::::JSCallbackObject):
+ (JSC::::staticFunctionGetter):
+ * API/JSClassRef.cpp:
+ (OpaqueJSClass::prototype):
+ * API/JSContextRef.cpp:
+ * API/JSObjectRef.cpp:
+ (JSObjectMake):
+ (JSObjectMakeFunctionWithCallback):
+ (JSObjectMakeConstructor):
+ (JSObjectGetPrivate):
+ (JSObjectSetPrivate):
+ (JSObjectGetPrivateProperty):
+ (JSObjectSetPrivateProperty):
+ (JSObjectDeletePrivateProperty):
+ * API/JSValueRef.cpp:
+ (JSValueIsObjectOfClass):
+ * API/JSWeakObjectMapRefPrivate.cpp:
+ * CMakeLists.txt:
+ * GNUmakefile.am:
+ * JavaScriptCore.exp:
+ * JavaScriptCore.gypi:
+ * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
+ * JavaScriptCore.xcodeproj/project.pbxproj:
+ * interpreter/Interpreter.cpp:
+ (JSC::Interpreter::privateExecute):
+ * jit/JITStubs.cpp:
+ (JSC::DEFINE_STUB_FUNCTION):
+ * jsc.cpp:
+ (GlobalObject::GlobalObject):
+ * runtime/ArrayConstructor.cpp:
+ (JSC::ArrayConstructor::ArrayConstructor):
+ * runtime/ArrayConstructor.h:
+ * runtime/ArrayPrototype.cpp:
+ (JSC::ArrayPrototype::ArrayPrototype):
+ * runtime/ArrayPrototype.h:
+ (JSC::ArrayPrototype::createStructure):
+ * runtime/BooleanConstructor.cpp:
+ (JSC::BooleanConstructor::BooleanConstructor):
+ * runtime/BooleanConstructor.h:
+ * runtime/BooleanPrototype.cpp:
+ (JSC::BooleanPrototype::BooleanPrototype):
+ * runtime/BooleanPrototype.h:
+ * runtime/DateConstructor.cpp:
+ (JSC::DateConstructor::DateConstructor):
+ * runtime/DateConstructor.h:
+ * runtime/DatePrototype.cpp:
+ (JSC::DatePrototype::DatePrototype):
+ * runtime/DatePrototype.h:
+ * runtime/ErrorConstructor.cpp:
+ (JSC::ErrorConstructor::ErrorConstructor):
+ * runtime/ErrorConstructor.h:
+ * runtime/ErrorPrototype.cpp:
+ (JSC::ErrorPrototype::ErrorPrototype):
+ * runtime/ErrorPrototype.h:
+ * runtime/FunctionConstructor.cpp:
+ (JSC::FunctionConstructor::FunctionConstructor):
+ * runtime/FunctionConstructor.h:
+ * runtime/FunctionPrototype.cpp:
+ (JSC::FunctionPrototype::FunctionPrototype):
+ (JSC::FunctionPrototype::addFunctionProperties):
+ * runtime/FunctionPrototype.h:
+ * runtime/GlobalEvalFunction.cpp:
+ (JSC::GlobalEvalFunction::GlobalEvalFunction):
+ * runtime/GlobalEvalFunction.h:
+ * runtime/InternalFunction.cpp:
+ (JSC::InternalFunction::InternalFunction):
+ * runtime/InternalFunction.h:
+ * runtime/JSCell.h:
+ (JSC::JSValue::getCallData):
+ (JSC::JSValue::getConstructData):
+ * runtime/JSFunction.cpp:
+ (JSC::JSFunction::JSFunction):
+ * runtime/JSFunction.h:
+ * runtime/JSGlobalObject.cpp:
+ (JSC::JSGlobalObject::reset):
+ * runtime/JSGlobalObject.h:
+ (JSC::JSGlobalObject::JSGlobalObject):
+ * runtime/JSONObject.cpp:
+ (JSC::JSONObject::JSONObject):
+ * runtime/JSONObject.h:
+ * runtime/JSObject.h:
+ * runtime/JSObjectWithGlobalObject.cpp: Added.
+ (JSC::JSObjectWithGlobalObject::JSObjectWithGlobalObject):
+ * runtime/JSObjectWithGlobalObject.h: Added.
+ (JSC::JSObjectWithGlobalObject::createStructure):
+ (JSC::JSObjectWithGlobalObject::JSObjectWithGlobalObject):
+ * runtime/JSValue.cpp:
+ (JSC::JSValue::isValidCallee):
+ * runtime/JSValue.h:
+ * runtime/Lookup.cpp:
+ (JSC::setUpStaticFunctionSlot):
+ * runtime/MathObject.cpp:
+ (JSC::MathObject::MathObject):
+ * runtime/MathObject.h:
+ * runtime/NativeErrorConstructor.cpp:
+ (JSC::NativeErrorConstructor::NativeErrorConstructor):
+ * runtime/NativeErrorConstructor.h:
+ * runtime/NativeErrorPrototype.cpp:
+ (JSC::NativeErrorPrototype::NativeErrorPrototype):
+ * runtime/NativeErrorPrototype.h:
+ * runtime/NumberConstructor.cpp:
+ (JSC::NumberConstructor::NumberConstructor):
+ * runtime/NumberConstructor.h:
+ * runtime/NumberPrototype.cpp:
+ (JSC::NumberPrototype::NumberPrototype):
+ * runtime/NumberPrototype.h:
+ * runtime/ObjectConstructor.cpp:
+ (JSC::ObjectConstructor::ObjectConstructor):
+ * runtime/ObjectConstructor.h:
+ * runtime/ObjectPrototype.cpp:
+ (JSC::ObjectPrototype::ObjectPrototype):
+ * runtime/ObjectPrototype.h:
+ * runtime/PrototypeFunction.cpp:
+ (JSC::PrototypeFunction::PrototypeFunction):
+ * runtime/PrototypeFunction.h:
+ * runtime/RegExpConstructor.cpp:
+ (JSC::RegExpConstructor::RegExpConstructor):
+ (JSC::constructRegExp):
+ * runtime/RegExpConstructor.h:
+ * runtime/RegExpObject.cpp:
+ (JSC::RegExpObject::RegExpObject):
+ * runtime/RegExpObject.h:
+ * runtime/RegExpPrototype.cpp:
+ (JSC::RegExpPrototype::RegExpPrototype):
+ * runtime/RegExpPrototype.h:
+ * runtime/StringConstructor.cpp:
+ (JSC::StringConstructor::StringConstructor):
+ * runtime/StringConstructor.h:
+ * runtime/StringPrototype.cpp:
+ (JSC::StringPrototype::StringPrototype):
+ * runtime/StringPrototype.h:
+
+2010-05-21 Geoffrey Garen <ggaren@apple.com>
+
+ Reviewed by Oliver Hunt.
+
+ Removed the unused entry in the CallFrame
+ https://bugs.webkit.org/show_bug.cgi?id=39470
+
+ Removed the unused entry in the CallFrame, and reordered CallFrame
+ writes on the hot path to be in forwards order.
+
+ SunSpider says 0.3% faster.
+
+ * interpreter/RegisterFile.h:
+ (JSC::RegisterFile::):
+ * jit/JITCall.cpp:
+ (JSC::JIT::compileOpCall):
+
+2010-05-21 Jedrzej Nowacki <jedrzej.nowacki@nokia.com>
+
+ Reviewed by Kenneth Rohde Christiansen.
+
+ Split the QScriptValue autotest into smaller chunks.
+
+ File tst_qscriptvalue_generated.cpp was huge and it was difficult to compile
+ it with MSVS2008, because of the code optimization.
+
+ Tests were splited into a few files for better use of distributed
+ compilation.
+ Repeated calls to insert() and operator<<() where replaced by loops,
+ that should reduce time of code optimizing.
+
+ New files were generated by the same application, test logic wasn't changed.
+
+ [Qt] The QScriptValue autotest should be refactored.
+ https://bugs.webkit.org/show_bug.cgi?id=38987
+
+ * qt/tests/qscriptvalue/qscriptvalue.pro:
+ * qt/tests/qscriptvalue/tst_qscriptvalue.h:
+ * qt/tests/qscriptvalue/tst_qscriptvalue_generated.cpp: Removed.
+ * qt/tests/qscriptvalue/tst_qscriptvalue_generated_init.cpp: Added.
+ (tst_QScriptValue::initScriptValues):
+ * qt/tests/qscriptvalue/tst_qscriptvalue_generated_istype.cpp: Added.
+ (tst_QScriptValue::isValid_initData):
+ (tst_QScriptValue::isValid_makeData):
+ (tst_QScriptValue::isValid_test):
+ (tst_QScriptValue::isBool_initData):
+ (tst_QScriptValue::isBool_makeData):
+ (tst_QScriptValue::isBool_test):
+ (tst_QScriptValue::isBoolean_initData):
+ (tst_QScriptValue::isBoolean_makeData):
+ (tst_QScriptValue::isBoolean_test):
+ (tst_QScriptValue::isNumber_initData):
+ (tst_QScriptValue::isNumber_makeData):
+ (tst_QScriptValue::isNumber_test):
+ (tst_QScriptValue::isFunction_initData):
+ (tst_QScriptValue::isFunction_makeData):
+ (tst_QScriptValue::isFunction_test):
+ (tst_QScriptValue::isNull_initData):
+ (tst_QScriptValue::isNull_makeData):
+ (tst_QScriptValue::isNull_test):
+ (tst_QScriptValue::isString_initData):
+ (tst_QScriptValue::isString_makeData):
+ (tst_QScriptValue::isString_test):
+ (tst_QScriptValue::isUndefined_initData):
+ (tst_QScriptValue::isUndefined_makeData):
+ (tst_QScriptValue::isUndefined_test):
+ (tst_QScriptValue::isObject_initData):
+ (tst_QScriptValue::isObject_makeData):
+ (tst_QScriptValue::isObject_test):
+ * qt/tests/qscriptvalue/tst_qscriptvalue_generated_totype.cpp: Added.
+ (tst_QScriptValue::toString_initData):
+ (tst_QScriptValue::toString_makeData):
+ (tst_QScriptValue::toString_test):
+ (tst_QScriptValue::toNumber_initData):
+ (tst_QScriptValue::toNumber_makeData):
+ (tst_QScriptValue::toNumber_test):
+ (tst_QScriptValue::toBool_initData):
+ (tst_QScriptValue::toBool_makeData):
+ (tst_QScriptValue::toBool_test):
+ (tst_QScriptValue::toBoolean_initData):
+ (tst_QScriptValue::toBoolean_makeData):
+ (tst_QScriptValue::toBoolean_test):
+ (tst_QScriptValue::toInteger_initData):
+ (tst_QScriptValue::toInteger_makeData):
+ (tst_QScriptValue::toInteger_test):
+ (tst_QScriptValue::toInt32_initData):
+ (tst_QScriptValue::toInt32_makeData):
+ (tst_QScriptValue::toInt32_test):
+ (tst_QScriptValue::toUInt32_initData):
+ (tst_QScriptValue::toUInt32_makeData):
+ (tst_QScriptValue::toUInt32_test):
+ (tst_QScriptValue::toUInt16_initData):
+ (tst_QScriptValue::toUInt16_makeData):
+ (tst_QScriptValue::toUInt16_test):
+
+2010-05-21 Kwang Yul Seo <skyul@company100.net>
+
+ Reviewed by Eric Seidel.
+
+ Add COMPILER(MSVC) guard for strnstr
+ https://bugs.webkit.org/show_bug.cgi?id=39397
+
+ BREWMP uses MSVC for simulator build, but it is not OS(WINDOWS).
+ Add COMPILER(MSVC) guard for strnstr.
+
+ * wtf/StringExtras.h:
+
+2010-05-21 Kwang Yul Seo <skyul@company100.net>
+
+ Reviewed by Eric Seidel.
+
+ [BREWMP] Add !PLATFORM(BREWMP) guard for isMainThread
+ https://bugs.webkit.org/show_bug.cgi?id=39396
+
+ BREWMP sets ENABLE(SINGLE_THREADED), so it uses isMainThread from ThreadingNone.cpp.
+ Exclude isMainThread in MainThread.cpp.
+
+ * wtf/MainThread.cpp:
+
+2010-05-20 Kwang Yul Seo <skyul@company100.net>
+
+ Reviewed by Eric Seidel.
+
+ [BREWMP] Use skia as BREW MP's graphics backend.
+ https://bugs.webkit.org/show_bug.cgi?id=39407
+
+ Define WTF_PLATFORM_SKIA=1 for BREW MP.
+
+ * wtf/Platform.h:
+
+2010-05-20 Geoffrey Garen <ggaren@apple.com>
+
+ Reviewed by Beth Dakin.
+
+ Fixed naming mixup: it's op_call_put_result, not ret_result.
+
+ * bytecode/CodeBlock.cpp:
+ (JSC::CodeBlock::dump):
+ * interpreter/Interpreter.cpp:
+ (JSC::Interpreter::privateExecute):
+
+2010-05-20 Geoffrey Garen <ggaren@apple.com>
+
+ Reviewed by Oliver Hunt.
+
+ Whittling away at CodeBlock use: Removed a little wonkiness in closure lookup
+ https://bugs.webkit.org/show_bug.cgi?id=39444
+
+ Calculate all lookup depths at compile time. I'm not sure why we couldn't
+ do this before, but whatever the reason, it seems to be gone now.
+
+ * bytecompiler/BytecodeGenerator.cpp:
+ (JSC::BytecodeGenerator::findScopedProperty):
+ * bytecompiler/BytecodeGenerator.h:
+ * interpreter/Interpreter.cpp:
+ (JSC::Interpreter::resolveSkip):
+ (JSC::Interpreter::resolveGlobalDynamic):
+ (JSC::Interpreter::privateExecute):
+ * jit/JITOpcodes.cpp:
+ (JSC::JIT::emit_op_get_scoped_var):
+ (JSC::JIT::emit_op_put_scoped_var):
+ (JSC::JIT::emit_op_resolve_skip):
+ (JSC::JIT::emit_op_resolve_global_dynamic):
+ (JSC::JIT::emitSlow_op_resolve_global_dynamic):
+ * jit/JITOpcodes32_64.cpp:
+ (JSC::JIT::emit_op_get_scoped_var):
+ (JSC::JIT::emit_op_put_scoped_var):
+ (JSC::JIT::emit_op_resolve_skip):
+
+2010-05-20 Darin Adler <darin@apple.com>
+
+ Reviewed by Eric Seidel.
+
+ Fix warnings seen on the buildbots today
+ https://bugs.webkit.org/show_bug.cgi?id=39368
+
+ * profiler/ProfileNode.cpp:
+ (JSC::getCount): Removed unneeded initialization of global variable.
+ These are all initialized to zero anyway, so no need to try to initialize
+ it and get a warning.
+
+ * wtf/CurrentTime.cpp:
+ (WTF::currentTime): Removed unused global variable.
+
+2010-05-20 Geoffrey Garen <ggaren@apple.com>
+
+ Reviewed by Darin Adler.
+
+ Removed some reliance on callFame[CodeBlock] by storing CodeBlock in a
+ local variable in the Interpreter.
+ https://bugs.webkit.org/show_bug.cgi?id=39447
+
+ Small speedup on SunSpider in Interpreter mode.
+
+ * interpreter/Interpreter.cpp:
+ (JSC::Interpreter::privateExecute):
+ * jsc.cpp:
+ * wtf/Platform.h:
+
+2010-05-19 Gavin Barraclough <barraclough@apple.com>
+
+ Reviewed by Oliver Hunt.
+
+ Bug 39408 - Unify JIT/interpreter return behaviour.
+
+ Presently the JIT and the interpreter have differing implementations in how
+ they handle storing the result of a function call back to the register file.
+ In both cases the op_call ( / _eval / _varargs / op_construct) opcode has an
+ operand indicating the VM register in which the result should be stored.
+ The JIT plants code after the call to store the result, so the value will be
+ stored as soon as the callee has returned. In the interpreter the call
+ passes the return value register id into the callee via the callee callframe,
+ and the callee is responsible for writing the result back into its callers
+ register file after it has restored the parents callframe pointer, but before
+ returning.
+
+ Instead, move the task of writing the call result to the register file into a
+ new opcode (op_call_put_result), and after returning the callee should leave
+ the return value in a canonical location. In the case of the interpreter,
+ this canonical location is a local variable in privateExecute
+ (functionReturnValue), in the case of the JIT this is the normal return value
+ registers (regT0, or regT1:regT0 in JSVALUE32_64). op_call_put_result stores
+ the result from the canonical location to the registerfile.
+
+ In addition to unifying JIT & interpreter behaviour this change allows us to
+ remove a slot from the callframe, omit the write of the result where the
+ return value from the call is not used, and provides a 2% speedup on sunspider
+ in the interpreter.
+
+ * bytecode/CodeBlock.cpp:
+ (JSC::CodeBlock::dump):
+ * bytecode/Opcode.h:
+ * bytecompiler/BytecodeGenerator.cpp:
+ (JSC::BytecodeGenerator::emitCall):
+ (JSC::BytecodeGenerator::emitCallVarargs):
+ (JSC::BytecodeGenerator::emitConstruct):
+ * bytecompiler/BytecodeGenerator.h:
+ (JSC::BytecodeGenerator::finalDestinationOrIgnored):
+ * bytecompiler/NodesCodegen.cpp:
+ (JSC::NewExprNode::emitBytecode):
+ (JSC::FunctionCallValueNode::emitBytecode):
+ (JSC::FunctionCallResolveNode::emitBytecode):
+ (JSC::FunctionCallBracketNode::emitBytecode):
+ (JSC::FunctionCallDotNode::emitBytecode):
+ (JSC::CallFunctionCallDotNode::emitBytecode):
+ (JSC::ApplyFunctionCallDotNode::emitBytecode):
+ * interpreter/CallFrame.h:
+ (JSC::ExecState::init):
+ (JSC::ExecState::noCaller):
+ * interpreter/Interpreter.cpp:
+ (JSC::Interpreter::dumpRegisters):
+ (JSC::Interpreter::throwException):
+ (JSC::Interpreter::privateExecute):
+ * interpreter/RegisterFile.h:
+ (JSC::RegisterFile::):
+ * jit/JIT.cpp:
+ (JSC::JIT::privateCompileMainPass):
+ * jit/JIT.h:
+ * jit/JITCall.cpp:
+ (JSC::JIT::compileOpCallSetupArgs):
+ (JSC::JIT::compileOpConstructSetupArgs):
+ (JSC::JIT::emit_op_call_put_result):
+ (JSC::JIT::compileOpCallVarargs):
+ (JSC::JIT::compileOpCallVarargsSlowCase):
+ (JSC::JIT::compileOpCall):
+ (JSC::JIT::compileOpCallSlowCase):
+ (JSC::JIT::compileOpCallVarargsSetupArgs):
+
+2010-05-20 Steve Block <steveblock@google.com>
+
+ Reviewed by Jeremy Orlow.
+
+ Provide bindings for DeviceOrientation
+ https://bugs.webkit.org/show_bug.cgi?id=39210
+
+ Adds ENABLE_DEVICE_ORIENTATION to XCode project file, always disabled.
+
+ * Configurations/FeatureDefines.xcconfig:
+
+2010-05-19 Gavin Barraclough <barraclough@apple.com>
+
+ Reviewed by Geoff Garen.
+
+ Errk! rename op_constructor_ret as requested in review of Bug 39399.
+
+ * bytecode/CodeBlock.cpp:
+ (JSC::CodeBlock::dump):
+ * bytecode/Opcode.h:
+ * bytecompiler/BytecodeGenerator.cpp:
+ (JSC::BytecodeGenerator::emitReturn):
+ * interpreter/Interpreter.cpp:
+ (JSC::Interpreter::privateExecute):
+ * jit/JIT.cpp:
+ (JSC::JIT::privateCompileMainPass):
+ * jit/JIT.h:
+ * jit/JITCall.cpp:
+ (JSC::JIT::emit_op_ret_object_or_this):
+ * jit/JITOpcodes.cpp:
+ (JSC::JIT::emit_op_ret_object_or_this):
+
+2010-05-19 Gavin Barraclough <barraclough@apple.com>
+
+ Reviewed by Geoff Garen.
+
+ Bug 39399 - Move responsibility for verifying constructors return objects from the caller to the callee.
+
+ This is a necessary step to move object creation from caller to callee.
+
+ * bytecode/CodeBlock.cpp:
+ (JSC::CodeBlock::dump):
+ * bytecode/Opcode.h:
+ * bytecompiler/BytecodeGenerator.cpp:
+ (JSC::BytecodeGenerator::BytecodeGenerator):
+ (JSC::BytecodeGenerator::emitReturn):
+ (JSC::BytecodeGenerator::emitConstruct):
+ * bytecompiler/BytecodeGenerator.h:
+ (JSC::BytecodeGenerator::isConstructor):
+ * bytecompiler/NodesCodegen.cpp:
+ (JSC::FunctionBodyNode::emitBytecode):
+ * interpreter/Interpreter.cpp:
+ (JSC::Interpreter::privateExecute):
+ * jit/JIT.cpp:
+ (JSC::JIT::privateCompileMainPass):
+ (JSC::JIT::privateCompileSlowCases):
+ * jit/JIT.h:
+ * jit/JITCall.cpp:
+ (JSC::JIT::emit_op_constructor_ret):
+ * jit/JITOpcodes.cpp:
+ (JSC::JIT::emit_op_constructor_ret):
+
+2010-05-19 Gavin Barraclough <barraclough@apple.com>
+
+ Reviewed by NOBODY (build fix).
+
+ Fix windows build II.
+
+ * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:
+
+2010-05-19 Gavin Barraclough <barraclough@apple.com>
+
+ Reviewed by NOBODY (build fix).
+
+ Fix windows build.
+
+ * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:
+
+2010-05-19 Gavin Barraclough <barraclough@apple.com>
+
+ Reviewed by Oliver Hunt.
+
+ Bug 39393 - JSFunction need not be a subclass of InternalFunction.
+
+ re-landing r59800.
+
+ * JavaScriptCore.exp:
+ * interpreter/Interpreter.cpp:
+ (JSC::Interpreter::retrieveCaller):
+ (JSC::Interpreter::findFunctionCallFrame):
+ * interpreter/Interpreter.h:
+ * profiler/Profiler.cpp:
+ (JSC::Profiler::createCallIdentifier):
+ * runtime/FunctionPrototype.cpp:
+ (JSC::functionProtoFuncToString):
+ * runtime/JSFunction.cpp:
+ (JSC::):
+ (JSC::JSFunction::JSFunction):
+ (JSC::JSFunction::name):
+ (JSC::JSFunction::displayName):
+ (JSC::JSFunction::calculatedDisplayName):
+ * runtime/JSFunction.h:
+ * runtime/JSObject.cpp:
+ (JSC::JSObject::putDirectFunction):
+ (JSC::JSObject::putDirectFunctionWithoutTransition):
+ * runtime/JSObject.h:
+ * runtime/Lookup.cpp:
+ (JSC::setUpStaticFunctionSlot):
+
+2010-05-19 Gavin Barraclough <barraclough@apple.com>
+
+ Reviewed by NOBODY (build fix).
+
+ Reverting r59800, this b0rked stuff.
+
+ * JavaScriptCore.exp:
+ * interpreter/Interpreter.cpp:
+ (JSC::Interpreter::retrieveCaller):
+ (JSC::Interpreter::findFunctionCallFrame):
+ * interpreter/Interpreter.h:
+ * profiler/Profiler.cpp:
+ (JSC::Profiler::createCallIdentifier):
+ * runtime/FunctionPrototype.cpp:
+ (JSC::functionProtoFuncToString):
+ * runtime/JSFunction.cpp:
+ (JSC::):
+ (JSC::JSFunction::JSFunction):
+ * runtime/JSFunction.h:
+ * runtime/JSObject.cpp:
+ * runtime/JSObject.h:
+ * runtime/Lookup.cpp:
+ (JSC::setUpStaticFunctionSlot):
+
+2010-05-19 Gavin Barraclough <barraclough@apple.com>
+
+ Reviewed by Oliver Hunt.
+
+ Bug 39393 - JSFunction need not be a subclass of InternalFunction.
+
+ This may prevent us from introducing a more useful parent class to
+ JSFunction, e.g. a JSObject that holds an executable, which could
+ also reference an eval or program executable.
+
+ * JavaScriptCore.exp:
+ * interpreter/Interpreter.cpp:
+ (JSC::Interpreter::retrieveCaller):
+ (JSC::Interpreter::findFunctionCallFrame):
+ * interpreter/Interpreter.h:
+ * profiler/Profiler.cpp:
+ (JSC::Profiler::createCallIdentifier):
+ * runtime/FunctionPrototype.cpp:
+ (JSC::functionProtoFuncToString):
+ * runtime/JSFunction.cpp:
+ (JSC::):
+ (JSC::JSFunction::JSFunction):
+ (JSC::JSFunction::name):
+ (JSC::JSFunction::displayName):
+ (JSC::JSFunction::calculatedDisplayName):
+ * runtime/JSFunction.h:
+ * runtime/JSObject.cpp:
+ (JSC::JSObject::putDirectFunction):
+ (JSC::JSObject::putDirectFunctionWithoutTransition):
+ * runtime/JSObject.h:
+ * runtime/Lookup.cpp:
+ (JSC::setUpStaticFunctionSlot):
+
+2010-05-19 Oliver Hunt <oliver@apple.com>
+
+ Reviewed by Geoffrey Garen.
+
+ emitJumpIfNotJSCell should special case constant immediate values
+ https://bugs.webkit.org/show_bug.cgi?id=39392
+ <rdar://problem/8001324>
+
+ Make emitJumpSlowCaseIfNotJSCell special case constant immediate
+ values, in addition to the immediate JSCell optimisation.
+
+ Also add assertions to make sure no one else produces code that
+ attempts to load constants from the register file.
+
+ * jit/JITInlineMethods.h:
+ (JSC::JIT::emitJumpSlowCaseIfNotJSCell):
+ * jit/JSInterfaceJIT.h:
+ (JSC::JSInterfaceJIT::emitJumpIfNotJSCell):
+ (JSC::JSInterfaceJIT::emitLoadInt32):
+ (JSC::JSInterfaceJIT::tagFor):
+ (JSC::JSInterfaceJIT::payloadFor):
+ (JSC::JSInterfaceJIT::emitLoadDouble):
+ (JSC::JSInterfaceJIT::addressFor):
+ * jit/ThunkGenerators.cpp:
+
+2010-05-19 Geoffrey Garen <ggaren@apple.com>
+
+ Reviewed by Sam Weinig.
+
+ Slight refactoring to CodeBlock bytecode access
+ https://bugs.webkit.org/show_bug.cgi?id=39384
+
+ * bytecode/CodeBlock.h:
+ (JSC::CodeBlock::bytecodeOffset):
+ * interpreter/CallFrame.h:
+ (JSC::ExecState::returnPC):
+ * interpreter/Interpreter.cpp:
+ (JSC::Interpreter::unwindCallFrame):
+ (JSC::Interpreter::retrieveLastCaller): Moved bytecode access into a
+ CodeBlock helper function. Changed CallFrame to accurately represent
+ how the returnPC is stored in JIT vs Interpreter.
+
+2010-05-19 Geoffrey Garen <ggaren@apple.com>
+
+ Reviewed by Sam Weinig.
+
+ Don't build the Interpreter into JIT builds.
+ https://bugs.webkit.org/show_bug.cgi?id=39373
+
+ SunSpider says no change.
+
+ * interpreter/Interpreter.cpp:
+ (JSC::Interpreter::privateExecute):
+ * interpreter/Interpreter.h:
+ * wtf/Platform.h:
+
+2010-05-19 Geoffrey Garen <ggaren@apple.com>
+
+ Reviewed by Gavin Barraclough.
+
+ Standardized naming: "bytecode offset" wins; "bytecode index" loses.
+
+ Also renamed getBytecodeOffset to bytecodeOffset, to match the WebKit
+ naming style.
+
+ * bytecode/CodeBlock.h:
+ (JSC::CallReturnOffsetToBytecodeOffset::CallReturnOffsetToBytecodeOffset):
+ (JSC::getCallReturnOffset):
+ (JSC::CodeBlock::bytecodeOffset):
+ (JSC::CodeBlock::callReturnIndexVector):
+ * interpreter/Interpreter.cpp:
+ (JSC::bytecodeOffsetForPC):
+ * jit/JIT.cpp:
+ (JSC::JIT::JIT):
+ (JSC::JIT::privateCompileMainPass):
+ (JSC::JIT::privateCompileLinkPass):
+ (JSC::JIT::privateCompileSlowCases):
+ (JSC::JIT::privateCompile):
+ * jit/JIT.h:
+ (JSC::CallRecord::CallRecord):
+ (JSC::JumpTable::JumpTable):
+ (JSC::SwitchRecord::SwitchRecord):
+ * jit/JITCall.cpp:
+ (JSC::JIT::compileOpCallVarargsSlowCase):
+ (JSC::JIT::compileOpCall):
+ * jit/JITInlineMethods.h:
+ (JSC::JIT::emitNakedCall):
+ (JSC::JIT::addSlowCase):
+ (JSC::JIT::addJump):
+ (JSC::JIT::emitJumpSlowToHot):
+ (JSC::JIT::isLabeled):
+ (JSC::JIT::map):
+ (JSC::JIT::unmap):
+ (JSC::JIT::isMapped):
+ (JSC::JIT::getMappedPayload):
+ (JSC::JIT::getMappedTag):
+ (JSC::JIT::emitGetVirtualRegister):
+ * jit/JITOpcodes.cpp:
+ (JSC::JIT::emit_op_switch_imm):
+ (JSC::JIT::emit_op_switch_char):
+ (JSC::JIT::emit_op_switch_string):
+ (JSC::JIT::emit_op_new_error):
+ * jit/JITOpcodes32_64.cpp:
+ (JSC::JIT::emit_op_mov):
+ (JSC::JIT::emit_op_get_global_var):
+ (JSC::JIT::emit_op_put_global_var):
+ (JSC::JIT::emit_op_get_scoped_var):
+ (JSC::JIT::emit_op_put_scoped_var):
+ (JSC::JIT::emit_op_to_primitive):
+ (JSC::JIT::emit_op_resolve_global):
+ (JSC::JIT::emit_op_to_jsnumber):
+ (JSC::JIT::emit_op_catch):
+ (JSC::JIT::emit_op_switch_imm):
+ (JSC::JIT::emit_op_switch_char):
+ (JSC::JIT::emit_op_switch_string):
+ (JSC::JIT::emit_op_new_error):
+ (JSC::JIT::emit_op_convert_this):
+ * jit/JITPropertyAccess.cpp:
+ (JSC::JIT::emit_op_method_check):
+ (JSC::JIT::emitSlow_op_method_check):
+ * jit/JITPropertyAccess32_64.cpp:
+ (JSC::JIT::emit_op_method_check):
+ (JSC::JIT::emitSlow_op_method_check):
+ (JSC::JIT::emit_op_get_by_val):
+ (JSC::JIT::emit_op_get_by_id):
+ (JSC::JIT::emit_op_get_by_pname):
+ * jit/JITStubCall.h:
+ (JSC::JITStubCall::call):
+ * jit/JITStubs.cpp:
+ (JSC::DEFINE_STUB_FUNCTION):
+
+2010-05-19 Peter Varga <pvarga@inf.u-szeged.hu>
+
+ Reviewed by Darin Adler.
+
+ The backtrackParenthesesOnceEnd function should store the start position
+ of the subpattern's non-greedy match at the place of the subpattern's
+ start index in the output array instead of the place of the
+ subpattern's end index.
+ Add layout test for checking of non-greedy matching of subpattern in
+ regular expressions.
+ https://bugs.webkit.org/show_bug.cgi?id=39289
+
+ * yarr/RegexInterpreter.cpp:
+ (JSC::Yarr::Interpreter::backtrackParenthesesOnceEnd):
+
+2010-05-18 Gavin Barraclough <barraclough@apple.com>
+
+ Reviewed by Geoff Garen.
+
+ Bug 39343 - Dynamically generate a native call thunk per NativeFunction
+
+ https://bugs.webkit.org/show_bug.cgi?id=39252 regressed performance on i386,
+ by adding an extra indirection to making a native call. By introducing per-
+ NativeFunction thunks we can hard code the function pointer into the thunk
+ so that it need not be loaded from the callee.
+
+ * jit/JIT.h:
+ (JSC::JIT::compileCTINativeCall):
+ * jit/JITOpcodes.cpp:
+ (JSC::JIT::privateCompileCTINativeCall):
+ * jit/JITOpcodes32_64.cpp:
+ (JSC::JIT::privateCompileCTINativeCall):
+ * jit/JITPropertyAccess.cpp:
+ (JSC::JIT::emitSlow_op_get_by_val):
+ * jit/JITPropertyAccess32_64.cpp:
+ (JSC::JIT::emitSlow_op_get_by_val):
+ * jit/JITStubs.cpp:
+ (JSC::JITThunks::ctiStub):
+ (JSC::JITThunks::hostFunctionStub):
+ * jit/JITStubs.h:
+ * jit/SpecializedThunkJIT.h:
+ (JSC::SpecializedThunkJIT::finalize):
+ * jit/ThunkGenerators.cpp:
+ (JSC::charCodeAtThunkGenerator):
+ (JSC::charAtThunkGenerator):
+ (JSC::fromCharCodeThunkGenerator):
+ (JSC::sqrtThunkGenerator):
+ (JSC::powThunkGenerator):
+ * runtime/JSFunction.cpp:
+ (JSC::JSFunction::JSFunction):
+ * runtime/JSGlobalData.cpp:
+ (JSC::JSGlobalData::getHostFunction):
+ * runtime/JSGlobalData.h:
+ (JSC::JSGlobalData::getCTIStub):
+ * runtime/Lookup.cpp:
+ (JSC::setUpStaticFunctionSlot):
+ * runtime/StringConstructor.cpp:
+ (JSC::StringConstructor::StringConstructor):
+ * wtf/Platform.h:
+
+2010-05-18 Geoffrey Garen <ggaren@apple.com>
+
+ Reviewed by Darin Adler.
+
+ Simplified handling of 'arguments' -- 1.2% SunSpider speedup
+ https://bugs.webkit.org/show_bug.cgi?id=39200
+
+ Removed the reserved OptionalCalleeArguments slot from the CallFrame.
+ Now, slots for 'arguments' are allocated and initialized only by
+ functions that might need them.
+
+ * bytecode/CodeBlock.cpp:
+ (JSC::CodeBlock::dump): Updated for new bytecode operands.
+
+ (JSC::CodeBlock::CodeBlock):
+ * bytecode/CodeBlock.h:
+ (JSC::unmodifiedArgumentsRegister): Added a helper function for mapping
+ from the arguments register to its unmodified counterpart.
+
+ (JSC::CodeBlock::setArgumentsRegister):
+ (JSC::CodeBlock::argumentsRegister):
+ (JSC::CodeBlock::usesArguments): Changed from a "usesArguments" bool to
+ an optional int index representing the arguments register.
+
+ * bytecode/Opcode.h: Updated for new bytecode operands.
+
+ * bytecompiler/BytecodeGenerator.cpp:
+ (JSC::BytecodeGenerator::addVar): Factored out a helper function for
+ allocating an anonymous var.
+
+ (JSC::BytecodeGenerator::BytecodeGenerator): Merged / simplified some
+ arguments vs activation logic, and added code to allocate the arguments
+ registers when needed.
+
+ (JSC::BytecodeGenerator::createArgumentsIfNecessary): Updated for new bytecode operands.
+
+ (JSC::BytecodeGenerator::emitCallEval): No need to create the arguments
+ object before calling eval; the activation object will lazily create the
+ arguments object if eval resolves it.
+
+ (JSC::BytecodeGenerator::emitReturn): Updated for new bytecode operands.
+
+ (JSC::BytecodeGenerator::emitPushScope):
+ (JSC::BytecodeGenerator::emitPushNewScope): Ditto emitCallEval.
+
+ * bytecompiler/BytecodeGenerator.h:
+ (JSC::BytecodeGenerator::addVar): Factored out a helper function for
+ allocating an anonymous var.
+
+ (JSC::BytecodeGenerator::registerFor): No more need for special handling
+ of the arguments registers; they're allocated just like normal registers
+ now.
+
+ * interpreter/CallFrame.h:
+ (JSC::ExecState::callerFrame):
+ (JSC::ExecState::init):
+ * interpreter/CallFrameClosure.h:
+ (JSC::CallFrameClosure::resetCallFrame): Nixed optionalCalleeArguments.
+
+ * interpreter/Interpreter.cpp:
+ (JSC::Interpreter::dumpRegisters):
+ (JSC::Interpreter::unwindCallFrame):
+ (JSC::Interpreter::privateExecute):
+ (JSC::Interpreter::retrieveArguments): Opcodes accessing 'arguments' now
+ take operands specifying registers, just like all other opcodes.
+ JSActivation::copyRegisters is no longer responsible for tearing off the
+ arguments object; instead, the VM is responsible for both.
+
+ Also, a behavior change: Each access to f.arguments creates a new object,
+ unless f itself uses 'arguments'. This matches Chrome, and is necessary
+ for the optimization. f.arguments is a nonstandard, deprecated feature,
+ so high fidelity to a given implementation is not necessarily a goal.
+ Also, as illustrated by the new test case, the identity of f.arguments
+ has been broken since 2008, except in the case where f itself accesses
+ f.arguments -- but nobody seemed to notice. So, hopefully this change won't
+ break the web.
+
+ * interpreter/Register.h: Nixed the special arguments accessor. It's no
+ longer needed.
+
+ * interpreter/RegisterFile.h:
+ (JSC::RegisterFile::):
+ * jit/JITCall.cpp:
+ (JSC::JIT::compileOpCallInitializeCallFrame):
+ (JSC::JIT::compileOpCall):
+ * jit/JITOpcodes.cpp:
+ (JSC::JIT::emit_op_tear_off_activation):
+ (JSC::JIT::emit_op_tear_off_arguments):
+ (JSC::JIT::emit_op_create_arguments):
+ (JSC::JIT::emit_op_init_arguments):
+ * jit/JITOpcodes32_64.cpp:
+ (JSC::JIT::emit_op_tear_off_activation):
+ (JSC::JIT::emit_op_tear_off_arguments):
+ (JSC::JIT::emit_op_create_arguments):
+ (JSC::JIT::emit_op_init_arguments): The actual optimization: Removed
+ OptionalCalleeArguments from the callframe slot. Now, it doesn't need
+ to be initialized for most calls.
+
+ * jit/JITStubs.cpp:
+ (JSC::DEFINE_STUB_FUNCTION):
+ * jit/JITStubs.h:
+ (JSC::): Updated stubs to support arbitrary 'arguments' registers,
+ instead of hard-coding something in the call frame.
+
+ * runtime/Arguments.h:
+ (JSC::JSActivation::copyRegisters): Removed some obfuscatory abstraction.
+
+ * runtime/Executable.h:
+ (JSC::FunctionExecutable::generatedByteCode): Added a helper for accessing
+ the 'arguments' register. In a future patch, that kind of data should
+ probably move out of CodeBlock and into Executable.
+
+ * runtime/JSActivation.cpp:
+ (JSC::JSActivation::getOwnPropertySlot):
+ (JSC::JSActivation::argumentsGetter):
+ * runtime/JSActivation.h: Simplified / fixed access to 'arguments' via
+ the activation object. It now implements the same behavior implemented
+ by optimized variable access in the VM. This simplifies some other
+ things, too -- like eval code generation.
+
+2010-05-18 Sam Weinig <sam@webkit.org>
+
+ Try to fix the windows build.
+
+ * API/JSStringRefBSTR.cpp:
+
+2010-05-18 Anders Carlsson <andersca@apple.com>
+
+ Reviewed by Sam Weinig.
+
+ Add an inlineCapacity template parameter to ListHashSet and use it to shrink the positioned object list hash set.
+ https://bugs.webkit.org/show_bug.cgi?id=39304
+ <rdar://problem/7998366>
+
+ Add an inlineCapacity template parameter to ListHashSet.
+
+ * wtf/ListHashSet.h:
+ (WTF::::ListHashSet):
+ (WTF::::operator):
+ (WTF::::swap):
+ (WTF::::~ListHashSet):
+ (WTF::::size):
+ (WTF::::capacity):
+ (WTF::::isEmpty):
+ (WTF::::begin):
+ (WTF::::end):
+ (WTF::::find):
+ (WTF::::contains):
+ (WTF::::add):
+ (WTF::::insertBefore):
+ (WTF::::remove):
+ (WTF::::clear):
+ (WTF::::unlinkAndDelete):
+ (WTF::::appendNode):
+ (WTF::::insertNodeBefore):
+ (WTF::::deleteAllNodes):
+ (WTF::::makeIterator):
+ (WTF::::makeConstIterator):
+ (WTF::deleteAllValues):
+
+2010-05-18 Gabor Loki <loki@webkit.org>
+
+ Reviewed by Darin Adler.
+
+ Fix the interpreter after r59637
+ https://bugs.webkit.org/show_bug.cgi?id=39287
+
+ * runtime/Executable.h:
+ * runtime/JSFunction.cpp:
+ (JSC::JSFunction::JSFunction):
+ (JSC::JSFunction::getCallData):
+ * runtime/JSGlobalData.cpp:
+ * runtime/JSGlobalData.h:
+
+2010-05-17 Gavin Barraclough <barraclough@apple.com>
+
+ Reviewed by Geoff Garen.
+
+ Oops, meant ebx not eax there. Fix Qt (and probably Win too).
+
+ * jit/JITOpcodes32_64.cpp:
+
+2010-05-17 Gavin Barraclough <barraclough@apple.com>
+
+ Reviewed by Geoff Garen.
+
+ Bug 39252 - Move host/native JSFunction's NativeFunction onto NativeExecutable.
+
+ Currently host functions reuse JSFunction's ScopeChain as storage for their
+ NativeFunction (the C function pointer to the host function implementation).
+ Instead, move this onto NativeExecutable. This will allow host functions to
+ have a scopechain (which will be implemented as a separate patch).
+
+ * JavaScriptCore.xcodeproj/project.pbxproj:
+ * jit/JIT.h:
+ * jit/JITCall.cpp:
+ (JSC::JIT::compileOpCallInitializeCallFrame):
+ (JSC::JIT::compileOpCall):
+ * jit/JITOpcodes.cpp:
+ (JSC::JIT::privateCompileCTIMachineTrampolines):
+ * jit/JITOpcodes32_64.cpp:
+ * jit/JITPropertyAccess.cpp:
+ (JSC::JIT::stringGetByValStubGenerator):
+ (JSC::JIT::emitSlow_op_get_by_val):
+ * jit/JITPropertyAccess32_64.cpp:
+ (JSC::JIT::stringGetByValStubGenerator):
+ (JSC::JIT::emitSlow_op_get_by_val):
+ * jit/JITStubs.cpp:
+ (JSC::JITThunks::specializedThunk):
+ * jit/JITStubs.h:
+ (JSC::JITThunks::ctiNativeCall):
+ * jit/SpecializedThunkJIT.h:
+ (JSC::SpecializedThunkJIT::finalize):
+ * jit/ThunkGenerators.cpp:
+ (JSC::charCodeAtThunkGenerator):
+ (JSC::charAtThunkGenerator):
+ (JSC::fromCharCodeThunkGenerator):
+ (JSC::sqrtThunkGenerator):
+ (JSC::powThunkGenerator):
+ * jit/ThunkGenerators.h:
+ * runtime/Executable.h:
+ (JSC::NativeExecutable::create):
+ (JSC::NativeExecutable::function):
+ (JSC::NativeExecutable::NativeExecutable):
+ (JSC::JSFunction::nativeFunction):
+ * runtime/JSFunction.cpp:
+ (JSC::JSFunction::JSFunction):
+ (JSC::JSFunction::~JSFunction):
+ (JSC::JSFunction::markChildren):
+ (JSC::JSFunction::getCallData):
+ (JSC::JSFunction::call):
+ (JSC::JSFunction::getOwnPropertySlot):
+ (JSC::JSFunction::getConstructData):
+ (JSC::JSFunction::construct):
+ * runtime/JSFunction.h:
+ (JSC::JSFunction::scope):
+ * runtime/JSGlobalData.h:
+ (JSC::JSGlobalData::getThunk):
+ * runtime/Lookup.cpp:
+ (JSC::setUpStaticFunctionSlot):
+ * runtime/StringConstructor.cpp:
+ (JSC::StringConstructor::StringConstructor):
+
2010-05-17 Patrick Gansterer <paroga@paroga.com>
Reviewed by Laszlo Gombos.
diff --git a/JavaScriptCore/Configurations/FeatureDefines.xcconfig b/JavaScriptCore/Configurations/FeatureDefines.xcconfig
index 947f371..c64d94c 100644
--- a/JavaScriptCore/Configurations/FeatureDefines.xcconfig
+++ b/JavaScriptCore/Configurations/FeatureDefines.xcconfig
@@ -47,6 +47,7 @@ ENABLE_CLIENT_BASED_GEOLOCATION = ENABLE_CLIENT_BASED_GEOLOCATION;
ENABLE_DATABASE = ENABLE_DATABASE;
ENABLE_DATAGRID = ;
ENABLE_DATALIST = ENABLE_DATALIST;
+ENABLE_DEVICE_ORIENTATION = ;
ENABLE_DOM_STORAGE = ENABLE_DOM_STORAGE;
ENABLE_EVENTSOURCE = ENABLE_EVENTSOURCE;
ENABLE_FILTERS = ENABLE_FILTERS;
@@ -78,4 +79,4 @@ ENABLE_XHTMLMP = ;
ENABLE_XPATH = ENABLE_XPATH;
ENABLE_XSLT = ENABLE_XSLT;
-FEATURE_DEFINES = $(ENABLE_3D_CANVAS) $(ENABLE_3D_RENDERING) $(ENABLE_BLOB_SLICE) $(ENABLE_CHANNEL_MESSAGING) $(ENABLE_CLIENT_BASED_GEOLOCATION) $(ENABLE_DATABASE) $(ENABLE_DATAGRID) $(ENABLE_DATALIST) $(ENABLE_DOM_STORAGE) $(ENABLE_EVENTSOURCE) $(ENABLE_FILTERS) $(ENABLE_FILE_READER) $(ENABLE_FILE_WRITER) $(ENABLE_GEOLOCATION) $(ENABLE_ICONDATABASE) $(ENABLE_INDEXED_DATABASE) $(ENABLE_JAVASCRIPT_DEBUGGER) $(ENABLE_MATHML) $(ENABLE_NOTIFICATIONS) $(ENABLE_OFFLINE_WEB_APPLICATIONS) $(ENABLE_PROGRESS_TAG) $(ENABLE_RUBY) $(ENABLE_SANDBOX) $(ENABLE_SHARED_WORKERS) $(ENABLE_SVG) $(ENABLE_SVG_ANIMATION) $(ENABLE_SVG_AS_IMAGE) $(ENABLE_SVG_DOM_OBJC_BINDINGS) $(ENABLE_SVG_FONTS) $(ENABLE_SVG_FOREIGN_OBJECT) $(ENABLE_SVG_USE) $(ENABLE_VIDEO) $(ENABLE_WEB_SOCKETS) $(ENABLE_WML) $(ENABLE_WORKERS) $(ENABLE_XHTMLMP) $(ENABLE_XPATH) $(ENABLE_XSLT);
+FEATURE_DEFINES = $(ENABLE_3D_CANVAS) $(ENABLE_3D_RENDERING) $(ENABLE_BLOB_SLICE) $(ENABLE_CHANNEL_MESSAGING) $(ENABLE_CLIENT_BASED_GEOLOCATION) $(ENABLE_DATABASE) $(ENABLE_DATAGRID) $(ENABLE_DATALIST) $(ENABLE_DEVICE_ORIENTATION) $(ENABLE_DOM_STORAGE) $(ENABLE_EVENTSOURCE) $(ENABLE_FILTERS) $(ENABLE_FILE_READER) $(ENABLE_FILE_WRITER) $(ENABLE_GEOLOCATION) $(ENABLE_ICONDATABASE) $(ENABLE_INDEXED_DATABASE) $(ENABLE_JAVASCRIPT_DEBUGGER) $(ENABLE_MATHML) $(ENABLE_NOTIFICATIONS) $(ENABLE_OFFLINE_WEB_APPLICATIONS) $(ENABLE_PROGRESS_TAG) $(ENABLE_RUBY) $(ENABLE_SANDBOX) $(ENABLE_SHARED_WORKERS) $(ENABLE_SVG) $(ENABLE_SVG_ANIMATION) $(ENABLE_SVG_AS_IMAGE) $(ENABLE_SVG_DOM_OBJC_BINDINGS) $(ENABLE_SVG_FONTS) $(ENABLE_SVG_FOREIGN_OBJECT) $(ENABLE_SVG_USE) $(ENABLE_VIDEO) $(ENABLE_WEB_SOCKETS) $(ENABLE_WML) $(ENABLE_WORKERS) $(ENABLE_XHTMLMP) $(ENABLE_XPATH) $(ENABLE_XSLT);
diff --git a/JavaScriptCore/Configurations/Version.xcconfig b/JavaScriptCore/Configurations/Version.xcconfig
index daa79a9..6f999af 100644
--- a/JavaScriptCore/Configurations/Version.xcconfig
+++ b/JavaScriptCore/Configurations/Version.xcconfig
@@ -22,7 +22,7 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
MAJOR_VERSION = 534;
-MINOR_VERSION = 0;
+MINOR_VERSION = 1;
TINY_VERSION = 0;
FULL_VERSION = $(MAJOR_VERSION).$(MINOR_VERSION);
diff --git a/JavaScriptCore/GNUmakefile.am b/JavaScriptCore/GNUmakefile.am
index 8ed23e5..2c924ef 100644
--- a/JavaScriptCore/GNUmakefile.am
+++ b/JavaScriptCore/GNUmakefile.am
@@ -86,6 +86,7 @@ javascriptcore_sources += \
JavaScriptCore/jit/JITOpcodes.cpp \
JavaScriptCore/jit/JITOpcodes32_64.cpp \
JavaScriptCore/jit/JITCall.cpp \
+ JavaScriptCore/jit/JITCall32_64.cpp \
JavaScriptCore/jit/JITCode.h \
JavaScriptCore/jit/JITPropertyAccess.cpp \
JavaScriptCore/jit/JITPropertyAccess32_64.cpp \
@@ -463,6 +464,7 @@ javascriptcore_sources += \
JavaScriptCore/runtime/JSNumberCell.cpp \
JavaScriptCore/runtime/JSNumberCell.h \
JavaScriptCore/runtime/JSObject.cpp \
+ JavaScriptCore/runtime/JSObjectWithGlobalObject.cpp \
JavaScriptCore/runtime/JSObject.h \
JavaScriptCore/runtime/JSStaticScopeObject.cpp \
JavaScriptCore/runtime/JSStaticScopeObject.h \
diff --git a/JavaScriptCore/JavaScriptCore.exp b/JavaScriptCore/JavaScriptCore.exp
index 51850da..e14af7f 100644
--- a/JavaScriptCore/JavaScriptCore.exp
+++ b/JavaScriptCore/JavaScriptCore.exp
@@ -1,5 +1,3 @@
-__ZN7WebCore10StringImpl6createEPKcj
-__ZN7WebCore12AtomicString11addSlowCaseEPNS_10StringImplE
_JSCheckScriptSyntax
_JSClassCreate
_JSClassRelease
@@ -109,7 +107,9 @@ __ZN3JSC10Identifier3addEPNS_9ExecStateEPKc
__ZN3JSC10Identifier4fromEPNS_9ExecStateEi
__ZN3JSC10Identifier4fromEPNS_9ExecStateEj
__ZN3JSC10Identifier5equalEPKN7WebCore10StringImplEPKc
-__ZN3JSC10JSFunctionC1EPNS_9ExecStateEN3WTF17NonNullPassRefPtrINS_9StructureEEEiRKNS_10IdentifierEPFNS_7JSValueES2_PNS_8JSObjectESA_RKNS_7ArgListEE
+__ZN3JSC10JSFunction4infoE
+__ZN3JSC10JSFunction4nameEPNS_9ExecStateE
+__ZN3JSC10JSFunctionC1EPNS_9ExecStateEPNS_14JSGlobalObjectEN3WTF17NonNullPassRefPtrINS_9StructureEEEiRKNS_10IdentifierEPFNS_7JSValueES2_PNS_8JSObjectESC_RKNS_7ArgListEE
__ZN3JSC10throwErrorEPNS_9ExecStateENS_9ErrorTypeE
__ZN3JSC10throwErrorEPNS_9ExecStateENS_9ErrorTypeEPKc
__ZN3JSC10throwErrorEPNS_9ExecStateENS_9ErrorTypeERKNS_7UStringE
@@ -167,15 +167,14 @@ __ZN3JSC15createTypeErrorEPNS_9ExecStateEPKc
__ZN3JSC15toInt32SlowCaseEdRb
__ZN3JSC16InternalFunction4infoE
__ZN3JSC16InternalFunction4nameEPNS_9ExecStateE
-__ZN3JSC16InternalFunctionC2EPNS_12JSGlobalDataEN3WTF17NonNullPassRefPtrINS_9StructureEEERKNS_10IdentifierE
+__ZN3JSC16InternalFunctionC2EPNS_12JSGlobalDataEPNS_14JSGlobalObjectEN3WTF17NonNullPassRefPtrINS_9StructureEEERKNS_10IdentifierE
__ZN3JSC16JSVariableObject14deletePropertyEPNS_9ExecStateERKNS_10IdentifierE
__ZN3JSC16JSVariableObject14symbolTableGetERKNS_10IdentifierERNS_18PropertyDescriptorE
__ZN3JSC16JSVariableObject19getOwnPropertyNamesEPNS_9ExecStateERNS_17PropertyNameArrayENS_15EnumerationModeE
__ZN3JSC16toUInt32SlowCaseEdRb
__ZN3JSC17BytecodeGenerator21setDumpsGeneratedCodeEb
__ZN3JSC17PropertyNameArray3addEPN7WebCore10StringImplE
-__ZN3JSC17PrototypeFunctionC1EPNS_9ExecStateEN3WTF17NonNullPassRefPtrINS_9StructureEEEiRKNS_10IdentifierEPFNS_7JSValueES2_PNS_8JSObjectESA_RKNS_7ArgListEE
-__ZN3JSC17PrototypeFunctionC1EPNS_9ExecStateEiRKNS_10IdentifierEPFNS_7JSValueES2_PNS_8JSObjectES6_RKNS_7ArgListEE
+__ZN3JSC17PrototypeFunctionC1EPNS_9ExecStateEPNS_14JSGlobalObjectEN3WTF17NonNullPassRefPtrINS_9StructureEEEiRKNS_10IdentifierEPFNS_7JSValueES2_PNS_8JSObjectESC_RKNS_7ArgListEE
__ZN3JSC17constructFunctionEPNS_9ExecStateERKNS_7ArgListERKNS_10IdentifierERKNS_7UStringEi
__ZN3JSC18DebuggerActivationC1EPNS_8JSObjectE
__ZN3JSC18PropertyDescriptor11setWritableEb
@@ -192,6 +191,7 @@ __ZN3JSC20MarkedArgumentBuffer10slowAppendENS_7JSValueE
__ZN3JSC23AbstractSamplingCounter4dumpEv
__ZN3JSC23objectProtoFuncToStringEPNS_9ExecStateEPNS_8JSObjectENS_7JSValueERKNS_7ArgListE
__ZN3JSC23setUpStaticFunctionSlotEPNS_9ExecStateEPKNS_9HashEntryEPNS_8JSObjectERKNS_10IdentifierERNS_12PropertySlotE
+__ZN3JSC24JSObjectWithGlobalObjectC2EPNS_14JSGlobalObjectEN3WTF17NonNullPassRefPtrINS_9StructureEEE
__ZN3JSC24createStackOverflowErrorEPNS_9ExecStateE
__ZN3JSC25evaluateInGlobalCallFrameERKNS_7UStringERNS_7JSValueEPNS_14JSGlobalObjectE
__ZN3JSC35createInterruptedExecutionExceptionEPNS_12JSGlobalDataE
@@ -238,6 +238,7 @@ __ZN3JSC7JSArrayC1EN3WTF17NonNullPassRefPtrINS_9StructureEEE
__ZN3JSC7JSArrayC1EN3WTF17NonNullPassRefPtrINS_9StructureEEERKNS_7ArgListE
__ZN3JSC7JSArrayC2EN3WTF17NonNullPassRefPtrINS_9StructureEEE
__ZN3JSC7JSArrayD2Ev
+__ZN3JSC7JSValue13isValidCalleeEv
__ZN3JSC7Profile10restoreAllEv
__ZN3JSC7Profile5focusEPKNS_11ProfileNodeE
__ZN3JSC7Profile7excludeEPKNS_11ProfileNodeE
@@ -264,6 +265,7 @@ __ZN3JSC8JSObject15unwrappedObjectEv
__ZN3JSC8JSObject16getPropertyNamesEPNS_9ExecStateERNS_17PropertyNameArrayENS_15EnumerationModeE
__ZN3JSC8JSObject17createInheritorIDEv
__ZN3JSC8JSObject17defineOwnPropertyEPNS_9ExecStateERKNS_10IdentifierERNS_18PropertyDescriptorEb
+__ZN3JSC8JSObject17putDirectFunctionEPNS_9ExecStateEPNS_10JSFunctionEj
__ZN3JSC8JSObject17putDirectFunctionEPNS_9ExecStateEPNS_16InternalFunctionEj
__ZN3JSC8JSObject17putWithAttributesEPNS_9ExecStateERKNS_10IdentifierENS_7JSValueEj
__ZN3JSC8JSObject17putWithAttributesEPNS_9ExecStateERKNS_10IdentifierENS_7JSValueEjbRNS_15PutPropertySlotE
@@ -392,6 +394,7 @@ __ZN7WebCore10StringImpl5lowerEv
__ZN7WebCore10StringImpl5toIntEPb
__ZN7WebCore10StringImpl5upperEv
__ZN7WebCore10StringImpl6createEPKc
+__ZN7WebCore10StringImpl6createEPKcj
__ZN7WebCore10StringImpl6createEPKtj
__ZN7WebCore10StringImpl6createEPKtjN3WTF10PassRefPtrINS3_21CrossThreadRefCountedINS3_16OwnFastMallocPtrIS1_EEEEEE
__ZN7WebCore10StringImpl6secureEt
@@ -403,6 +406,7 @@ __ZN7WebCore10StringImpl8endsWithEPS0_b
__ZN7WebCore10StringImpl9substringEjj
__ZN7WebCore10StringImplD1Ev
__ZN7WebCore11commentAtomE
+__ZN7WebCore12AtomicString11addSlowCaseEPNS_10StringImplE
__ZN7WebCore12AtomicString3addEPKc
__ZN7WebCore12AtomicString3addEPKt
__ZN7WebCore12AtomicString3addEPKtj
@@ -452,7 +456,7 @@ __ZN7WebCoreplEPKcRKNS_6StringE
__ZN7WebCoreplERKNS_6StringEPKc
__ZN7WebCoreplERKNS_6StringES2_
__ZNK3JSC10JSFunction23isHostFunctionNonInlineEv
-__ZNK3JSC11Interpreter14retrieveCallerEPNS_9ExecStateEPNS_16InternalFunctionE
+__ZNK3JSC11Interpreter14retrieveCallerEPNS_9ExecStateEPNS_10JSFunctionE
__ZNK3JSC11Interpreter18retrieveLastCallerEPNS_9ExecStateERiRlRNS_7UStringERNS_7JSValueE
__ZNK3JSC12PropertySlot14functionGetterEPNS_9ExecStateE
__ZNK3JSC14JSGlobalObject14isDynamicScopeERb
@@ -470,9 +474,10 @@ __ZNK3JSC18PropertyDescriptor20isAccessorDescriptorEv
__ZNK3JSC18PropertyDescriptor6getterEv
__ZNK3JSC18PropertyDescriptor6setterEv
__ZNK3JSC18PropertyDescriptor8writableEv
-__ZNK3JSC4Heap4sizeEv
+__ZNK3JSC24JSObjectWithGlobalObject12globalObjectEv
__ZNK3JSC4Heap10statisticsEv
__ZNK3JSC4Heap11objectCountEv
+__ZNK3JSC4Heap4sizeEv
__ZNK3JSC6JSCell11toPrimitiveEPNS_9ExecStateENS_22PreferredPrimitiveTypeE
__ZNK3JSC6JSCell12toThisObjectEPNS_9ExecStateE
__ZNK3JSC6JSCell14isGetterSetterEv
diff --git a/JavaScriptCore/JavaScriptCore.gypi b/JavaScriptCore/JavaScriptCore.gypi
index 2d1f20a..c54ff17 100644
--- a/JavaScriptCore/JavaScriptCore.gypi
+++ b/JavaScriptCore/JavaScriptCore.gypi
@@ -117,6 +117,7 @@
'jit/JITArithmetic.cpp',
'jit/JITArithmetic32_64.cpp',
'jit/JITCall.cpp',
+ 'jit/JITCall32_64.cpp',
'jit/JITCode.h',
'jit/JITInlineMethods.h',
'jit/JITOpcodes.cpp',
@@ -247,6 +248,8 @@
'runtime/JSNumberCell.h',
'runtime/JSObject.cpp',
'runtime/JSObject.h',
+ 'runtime/JSObjectWithGlobalObject.cpp',
+ 'runtime/JSObjectWithGlobalObject.h',
'runtime/JSONObject.cpp',
'runtime/JSONObject.h',
'runtime/JSPropertyNameIterator.cpp',
@@ -400,6 +403,7 @@
'wtf/RefPtrHashMap.h',
'wtf/RetainPtr.h',
'wtf/SegmentedVector.h',
+ 'wtf/SizeLimits.cpp',
'wtf/StaticConstructors.h',
'wtf/StdLibExtras.h',
'wtf/StringExtras.h',
diff --git a/JavaScriptCore/JavaScriptCore.pro b/JavaScriptCore/JavaScriptCore.pro
index 5378857..a3d8358 100644
--- a/JavaScriptCore/JavaScriptCore.pro
+++ b/JavaScriptCore/JavaScriptCore.pro
@@ -101,6 +101,7 @@ SOURCES += \
jit/JITArithmetic.cpp \
jit/JITArithmetic32_64.cpp \
jit/JITCall.cpp \
+ jit/JITCall32_64.cpp \
jit/JIT.cpp \
jit/JITOpcodes.cpp \
jit/JITOpcodes32_64.cpp \
@@ -159,6 +160,7 @@ SOURCES += \
runtime/JSNotAnObject.cpp \
runtime/JSNumberCell.cpp \
runtime/JSObject.cpp \
+ runtime/JSObjectWithGlobalObject.cpp \
runtime/JSONObject.cpp \
runtime/JSPropertyNameIterator.cpp \
runtime/JSStaticScopeObject.cpp \
diff --git a/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def b/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def
index afd1ca0..e7d7eda 100644
--- a/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def
+++ b/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def
@@ -6,15 +6,14 @@ EXPORTS
??0DateInstance@JSC@@QAE@PAVExecState@1@N@Z
??0DateInstance@JSC@@QAE@PAVExecState@1@V?$NonNullPassRefPtr@VStructure@JSC@@@WTF@@N@Z
??0DropAllLocks@JSLock@JSC@@QAE@W4JSLockBehavior@2@@Z
- ??0InternalFunction@JSC@@IAE@PAVJSGlobalData@1@V?$NonNullPassRefPtr@VStructure@JSC@@@WTF@@ABVIdentifier@1@@Z
+ ??0InternalFunction@JSC@@IAE@PAVJSGlobalData@1@PAVJSGlobalObject@1@V?$NonNullPassRefPtr@VStructure@JSC@@@WTF@@ABVIdentifier@1@@Z
??0JSArray@JSC@@QAE@V?$NonNullPassRefPtr@VStructure@JSC@@@WTF@@@Z
??0JSArray@JSC@@QAE@V?$NonNullPassRefPtr@VStructure@JSC@@@WTF@@ABVArgList@1@@Z
??0JSByteArray@JSC@@QAE@PAVExecState@1@V?$NonNullPassRefPtr@VStructure@JSC@@@WTF@@PAVByteArray@4@PBUClassInfo@1@@Z
- ??0JSFunction@JSC@@QAE@PAVExecState@1@V?$NonNullPassRefPtr@VStructure@JSC@@@WTF@@HABVIdentifier@1@P6I?AVJSValue@1@0PAVJSObject@1@V61@ABVArgList@1@@Z@Z
+ ??0JSFunction@JSC@@QAE@PAVExecState@1@PAVJSGlobalObject@1@V?$NonNullPassRefPtr@VStructure@JSC@@@WTF@@HABVIdentifier@1@P6I?AVJSValue@1@0PAVJSObject@1@V71@ABVArgList@1@@Z@Z
+ ??0JSObjectWithGlobalObject@JSC@@IAE@PAVJSGlobalObject@1@V?$NonNullPassRefPtr@VStructure@JSC@@@WTF@@@Z
??0MD5@WTF@@QAE@XZ
??0Mutex@WTF@@QAE@XZ
- ??0PrototypeFunction@JSC@@QAE@PAVExecState@1@HABVIdentifier@1@P6I?AVJSValue@1@0PAVJSObject@1@V41@ABVArgList@1@@Z@Z
- ??0PrototypeFunction@JSC@@QAE@PAVExecState@1@V?$NonNullPassRefPtr@VStructure@JSC@@@WTF@@HABVIdentifier@1@P6I?AVJSValue@1@0PAVJSObject@1@V61@ABVArgList@1@@Z@Z
??0RefCountedLeakCounter@WTF@@QAE@PBD@Z
??0StringObject@JSC@@QAE@PAVExecState@1@V?$NonNullPassRefPtr@VStructure@JSC@@@WTF@@ABVUString@1@@Z
??0Structure@JSC@@AAE@VJSValue@1@ABVTypeInfo@1@I@Z
@@ -175,6 +174,7 @@ EXPORTS
?getter@PropertyDescriptor@JSC@@QBE?AVJSValue@2@XZ
?globalExec@JSGlobalObject@JSC@@UAEPAVExecState@2@XZ
?globalObjectCount@Heap@JSC@@QAEIXZ
+ ?globalObject@JSObjectWithGlobalObject@JSC@@QBEPAVJSGlobalObject@2@XZ
?hasInstance@JSObject@JSC@@UAE_NPAVExecState@2@VJSValue@2@1@Z
?hasProperty@JSObject@JSC@@QBE_NPAVExecState@2@ABVIdentifier@2@@Z
?hasProperty@JSObject@JSC@@QBE_NPAVExecState@2@I@Z
@@ -194,6 +194,7 @@ EXPORTS
?isGetterSetter@JSCell@JSC@@UBE_NXZ
?isHostFunctionNonInline@JSFunction@JSC@@ABE_NXZ
?isMainThread@WTF@@YA_NXZ
+ ?isValidCallee@JSValue@JSC@@QAE_NXZ
?isVariableObject@JSVariableObject@JSC@@UBE_NXZ
?jsNumberCell@JSC@@YA?AVJSValue@1@PAVExecState@1@N@Z
?jsOwnedString@JSC@@YAPAVJSString@1@PAVJSGlobalData@1@ABVUString@1@@Z
@@ -214,6 +215,7 @@ EXPORTS
?monthFromDayInYear@WTF@@YAHH_N@Z
?msToYear@WTF@@YAHN@Z
?name@InternalFunction@JSC@@QAEABVUString@2@PAVExecState@2@@Z
+ ?name@JSFunction@JSC@@QAEABVUString@2@PAVExecState@2@@Z
?newUninitialized@CString@WTF@@SA?AV12@IAAPAD@Z
?nonInlineNaN@JSC@@YANXZ
?objectCount@Heap@JSC@@QBEIXZ
@@ -232,6 +234,7 @@ EXPORTS
?put@JSObject@JSC@@UAEXPAVExecState@2@IVJSValue@2@@Z
?put@StringObject@JSC@@UAEXPAVExecState@2@ABVIdentifier@2@VJSValue@2@AAVPutPropertySlot@2@@Z
?putDirectFunction@JSObject@JSC@@QAEXPAVExecState@2@PAVInternalFunction@2@I@Z
+ ?putDirectFunction@JSObject@JSC@@QAEXPAVExecState@2@PAVJSFunction@2@I@Z
?putWithAttributes@JSGlobalObject@JSC@@UAEXPAVExecState@2@ABVIdentifier@2@VJSValue@2@I@Z
?putWithAttributes@JSObject@JSC@@UAEXPAVExecState@2@ABVIdentifier@2@VJSValue@2@I@Z
?putWithAttributes@JSObject@JSC@@UAEXPAVExecState@2@ABVIdentifier@2@VJSValue@2@I_NAAVPutPropertySlot@2@@Z
@@ -245,7 +248,7 @@ EXPORTS
?resetDateCache@JSGlobalData@JSC@@QAEXXZ
?resolveRope@JSString@JSC@@ABEXPAVExecState@2@@Z
?restoreAll@Profile@JSC@@QAEXXZ
- ?retrieveCaller@Interpreter@JSC@@QBE?AVJSValue@2@PAVExecState@2@PAVInternalFunction@2@@Z
+ ?retrieveCaller@Interpreter@JSC@@QBE?AVJSValue@2@PAVExecState@2@PAVJSFunction@2@@Z
?retrieveLastCaller@Interpreter@JSC@@QBEXPAVExecState@2@AAH1AAVUString@2@AAVJSValue@2@@Z
?setAccessorDescriptor@PropertyDescriptor@JSC@@QAEXVJSValue@2@0I@Z
?setConfigurable@PropertyDescriptor@JSC@@QAEX_N@Z
diff --git a/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj b/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj
index 5ace49c..effce51 100644
--- a/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj
+++ b/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj
@@ -853,6 +853,14 @@
>
</File>
<File
+ RelativePath="..\..\runtime\JSObjectWithGlobalObject.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\runtime\JSObjectWithGlobalObject.h"
+ >
+ </File>
+ <File
RelativePath="..\..\runtime\JSONObject.cpp"
>
</File>
@@ -1645,6 +1653,10 @@
>
</File>
<File
+ RelativePath="..\..\jit\JITCall32_64.cpp"
+ >
+ </File>
+ <File
RelativePath="..\..\jit\JITCode.h"
>
</File>
diff --git a/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj b/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
index 1edb0af..8d10ab3 100644
--- a/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
+++ b/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
@@ -43,6 +43,7 @@
0B4D7E630F319AC800AD7E58 /* TypeTraits.h in Headers */ = {isa = PBXBuildFile; fileRef = 0B4D7E620F319AC800AD7E58 /* TypeTraits.h */; settings = {ATTRIBUTES = (Private, ); }; };
0BDFFAE00FC6192900D69EF4 /* CrossThreadRefCounted.h in Headers */ = {isa = PBXBuildFile; fileRef = 0BDFFAD40FC6171000D69EF4 /* CrossThreadRefCounted.h */; settings = {ATTRIBUTES = (Private, ); }; };
0BDFFAE10FC6193100D69EF4 /* OwnFastMallocPtr.h in Headers */ = {isa = PBXBuildFile; fileRef = 0BDFFAD10FC616EC00D69EF4 /* OwnFastMallocPtr.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 0BF28A2911A33DC300638F84 /* SizeLimits.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0BF28A2811A33DC300638F84 /* SizeLimits.cpp */; };
14035DB110DBFB2A00FFFFE7 /* WeakGCPtr.h in Headers */ = {isa = PBXBuildFile; fileRef = 14035DB010DBFB2A00FFFFE7 /* WeakGCPtr.h */; settings = {ATTRIBUTES = (Private, ); }; };
140566C4107EC255005DBC8D /* JSAPIValueWrapper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC0894D50FAFBA2D00001865 /* JSAPIValueWrapper.cpp */; };
140566D1107EC267005DBC8D /* JSStaticScopeObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7E42C190E3938830065A544 /* JSStaticScopeObject.cpp */; };
@@ -111,6 +112,7 @@
14469DED107EC7E700650446 /* StringPrototype.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC18C3C50E16EE3300B34460 /* StringPrototype.cpp */; };
14469DEE107EC7E700650446 /* UString.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F692A8850255597D01FF60F7 /* UString.cpp */; };
146AAB380B66A94400E55F16 /* JSStringRefCF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 146AAB370B66A94400E55F16 /* JSStringRefCF.cpp */; };
+ 146FE51211A710430087AE66 /* JITCall32_64.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 146FE51111A710430087AE66 /* JITCall32_64.cpp */; };
147B83AC0E6DB8C9004775A4 /* BatchedTransitionOptimizer.h in Headers */ = {isa = PBXBuildFile; fileRef = 147B83AA0E6DB8C9004775A4 /* BatchedTransitionOptimizer.h */; };
147B84630E6DE6B1004775A4 /* PutPropertySlot.h in Headers */ = {isa = PBXBuildFile; fileRef = 147B84620E6DE6B1004775A4 /* PutPropertySlot.h */; settings = {ATTRIBUTES = (Private, ); }; };
147F39BD107EC37600427A48 /* ArgList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCF605110E203EF800B9A64D /* ArgList.cpp */; };
@@ -222,6 +224,9 @@
86B99AE3117E578100DF5A90 /* StringBuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = 86B99AE1117E578100DF5A90 /* StringBuffer.h */; settings = {ATTRIBUTES = (Private, ); }; };
86B99AE4117E578100DF5A90 /* StringImplBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 86B99AE2117E578100DF5A90 /* StringImplBase.h */; settings = {ATTRIBUTES = (Private, ); }; };
86C36EEA0EE1289D00B3DF59 /* MacroAssembler.h in Headers */ = {isa = PBXBuildFile; fileRef = 86C36EE90EE1289D00B3DF59 /* MacroAssembler.h */; };
+ 86C568E011A213EE0007F7F0 /* MacroAssemblerARM.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 86C568DD11A213EE0007F7F0 /* MacroAssemblerARM.cpp */; };
+ 86C568E111A213EE0007F7F0 /* MacroAssemblerMIPS.h in Headers */ = {isa = PBXBuildFile; fileRef = 86C568DE11A213EE0007F7F0 /* MacroAssemblerMIPS.h */; };
+ 86C568E211A213EE0007F7F0 /* MIPSAssembler.h in Headers */ = {isa = PBXBuildFile; fileRef = 86C568DF11A213EE0007F7F0 /* MIPSAssembler.h */; };
86CA032E1038E8440028A609 /* Executable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 86CA032D1038E8440028A609 /* Executable.cpp */; };
86CAFEE31035DDE60028A609 /* Executable.h in Headers */ = {isa = PBXBuildFile; fileRef = 86CAFEE21035DDE60028A609 /* Executable.h */; settings = {ATTRIBUTES = (); }; };
86CC85A10EE79A4700288682 /* JITInlineMethods.h in Headers */ = {isa = PBXBuildFile; fileRef = 86CC85A00EE79A4700288682 /* JITInlineMethods.h */; };
@@ -306,13 +311,14 @@
A76EE6590FAE59D5003F069A /* NativeFunctionWrapper.h in Headers */ = {isa = PBXBuildFile; fileRef = A76EE6580FAE59D5003F069A /* NativeFunctionWrapper.h */; settings = {ATTRIBUTES = (Private, ); }; };
A7795590101A74D500114E55 /* MarkStack.h in Headers */ = {isa = PBXBuildFile; fileRef = A779558F101A74D500114E55 /* MarkStack.h */; settings = {ATTRIBUTES = (Private, ); }; };
A782F1A50EEC9FA20036273F /* ExecutableAllocatorPosix.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A782F1A40EEC9FA20036273F /* ExecutableAllocatorPosix.cpp */; };
+ A783A0D111A36DCA00563D20 /* JSObjectWithGlobalObject.h in Headers */ = {isa = PBXBuildFile; fileRef = A783A0D011A36DCA00563D20 /* JSObjectWithGlobalObject.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ A783A2AB11A5BE8400563D20 /* JSObjectWithGlobalObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A783A2AA11A5BE8400563D20 /* JSObjectWithGlobalObject.cpp */; };
A791EF280F11E07900AE1F68 /* JSByteArray.h in Headers */ = {isa = PBXBuildFile; fileRef = A791EF260F11E07900AE1F68 /* JSByteArray.h */; settings = {ATTRIBUTES = (Private, ); }; };
A791EF290F11E07900AE1F68 /* JSByteArray.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A791EF270F11E07900AE1F68 /* JSByteArray.cpp */; };
A7A1F7AC0F252B3C00E184E2 /* ByteArray.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7A1F7AA0F252B3C00E184E2 /* ByteArray.cpp */; };
A7A1F7AD0F252B3C00E184E2 /* ByteArray.h in Headers */ = {isa = PBXBuildFile; fileRef = A7A1F7AB0F252B3C00E184E2 /* ByteArray.h */; settings = {ATTRIBUTES = (Private, ); }; };
A7B48F490EE8936F00DCBDB6 /* ExecutableAllocator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7B48DB60EE74CFC00DCBDB6 /* ExecutableAllocator.cpp */; };
A7C1E8E4112E72EF00A37F98 /* JITPropertyAccess32_64.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7C1E8C8112E701C00A37F98 /* JITPropertyAccess32_64.cpp */; };
- A7C2217810C7479400F97913 /* JSZombie.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7C2216B10C7469C00F97913 /* JSZombie.cpp */; };
A7C530E4102A3813005BC741 /* MarkStackPosix.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7C530E3102A3813005BC741 /* MarkStackPosix.cpp */; };
A7D649AA1015224E009B2E1B /* PossiblyNull.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D649A91015224E009B2E1B /* PossiblyNull.h */; settings = {ATTRIBUTES = (Private, ); }; };
A7E2EA6B0FB460CF00601F06 /* LiteralParser.h in Headers */ = {isa = PBXBuildFile; fileRef = A7E2EA690FB460CF00601F06 /* LiteralParser.h */; };
@@ -321,6 +327,8 @@
A7F993600FD7325100A0B2D0 /* JSONObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7F9935E0FD7325100A0B2D0 /* JSONObject.cpp */; };
A7FB60A4103F7DC20017A286 /* PropertyDescriptor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7FB60A3103F7DC20017A286 /* PropertyDescriptor.cpp */; };
A7FB61001040C38B0017A286 /* PropertyDescriptor.h in Headers */ = {isa = PBXBuildFile; fileRef = A7FB604B103F5EAB0017A286 /* PropertyDescriptor.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ BC01D4F111A8F1FF00A54B2A /* JSZombie.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC01D4EF11A8F1FF00A54B2A /* JSZombie.cpp */; };
+ BC01D4F211A8F1FF00A54B2A /* JSZombie.h in Headers */ = {isa = PBXBuildFile; fileRef = BC01D4F011A8F1FF00A54B2A /* JSZombie.h */; };
BC02E90D0E1839DB000F9297 /* ErrorConstructor.h in Headers */ = {isa = PBXBuildFile; fileRef = BC02E9050E1839DB000F9297 /* ErrorConstructor.h */; };
BC02E90F0E1839DB000F9297 /* ErrorPrototype.h in Headers */ = {isa = PBXBuildFile; fileRef = BC02E9070E1839DB000F9297 /* ErrorPrototype.h */; };
BC02E9110E1839DB000F9297 /* NativeErrorConstructor.h in Headers */ = {isa = PBXBuildFile; fileRef = BC02E9090E1839DB000F9297 /* NativeErrorConstructor.h */; };
@@ -589,6 +597,7 @@
0B4D7E620F319AC800AD7E58 /* TypeTraits.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TypeTraits.h; sourceTree = "<group>"; };
0BDFFAD10FC616EC00D69EF4 /* OwnFastMallocPtr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OwnFastMallocPtr.h; sourceTree = "<group>"; };
0BDFFAD40FC6171000D69EF4 /* CrossThreadRefCounted.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CrossThreadRefCounted.h; sourceTree = "<group>"; };
+ 0BF28A2811A33DC300638F84 /* SizeLimits.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SizeLimits.cpp; sourceTree = "<group>"; };
14035DB010DBFB2A00FFFFE7 /* WeakGCPtr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WeakGCPtr.h; sourceTree = "<group>"; };
140D17D60E8AD4A9000CD17D /* JSBasePrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSBasePrivate.h; sourceTree = "<group>"; };
141211020A48780900480255 /* minidom.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = minidom.c; path = tests/minidom.c; sourceTree = "<group>"; };
@@ -626,6 +635,7 @@
145C507F0D9DF63B0088F6B9 /* CallData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CallData.h; sourceTree = "<group>"; };
146AAB2A0B66A84900E55F16 /* JSStringRefCF.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSStringRefCF.h; sourceTree = "<group>"; };
146AAB370B66A94400E55F16 /* JSStringRefCF.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSStringRefCF.cpp; sourceTree = "<group>"; };
+ 146FE51111A710430087AE66 /* JITCall32_64.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JITCall32_64.cpp; sourceTree = "<group>"; };
14760863099C633800437128 /* JSImmediate.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSImmediate.cpp; sourceTree = "<group>"; };
147B83AA0E6DB8C9004775A4 /* BatchedTransitionOptimizer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BatchedTransitionOptimizer.h; sourceTree = "<group>"; };
147B84620E6DE6B1004775A4 /* PutPropertySlot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PutPropertySlot.h; sourceTree = "<group>"; };
@@ -777,6 +787,9 @@
86B99AE1117E578100DF5A90 /* StringBuffer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StringBuffer.h; path = text/StringBuffer.h; sourceTree = "<group>"; };
86B99AE2117E578100DF5A90 /* StringImplBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StringImplBase.h; path = text/StringImplBase.h; sourceTree = "<group>"; };
86C36EE90EE1289D00B3DF59 /* MacroAssembler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MacroAssembler.h; sourceTree = "<group>"; };
+ 86C568DD11A213EE0007F7F0 /* MacroAssemblerARM.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MacroAssemblerARM.cpp; sourceTree = "<group>"; };
+ 86C568DE11A213EE0007F7F0 /* MacroAssemblerMIPS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MacroAssemblerMIPS.h; sourceTree = "<group>"; };
+ 86C568DF11A213EE0007F7F0 /* MIPSAssembler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MIPSAssembler.h; sourceTree = "<group>"; };
86CA032D1038E8440028A609 /* Executable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Executable.cpp; sourceTree = "<group>"; };
86CAFEE21035DDE60028A609 /* Executable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Executable.h; sourceTree = "<group>"; };
86CC85A00EE79A4700288682 /* JITInlineMethods.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JITInlineMethods.h; sourceTree = "<group>"; };
@@ -892,6 +905,8 @@
A76EE6580FAE59D5003F069A /* NativeFunctionWrapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NativeFunctionWrapper.h; sourceTree = "<group>"; };
A779558F101A74D500114E55 /* MarkStack.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MarkStack.h; sourceTree = "<group>"; };
A782F1A40EEC9FA20036273F /* ExecutableAllocatorPosix.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ExecutableAllocatorPosix.cpp; sourceTree = "<group>"; };
+ A783A0D011A36DCA00563D20 /* JSObjectWithGlobalObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSObjectWithGlobalObject.h; sourceTree = "<group>"; };
+ A783A2AA11A5BE8400563D20 /* JSObjectWithGlobalObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSObjectWithGlobalObject.cpp; sourceTree = "<group>"; };
A791EF260F11E07900AE1F68 /* JSByteArray.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSByteArray.h; sourceTree = "<group>"; };
A791EF270F11E07900AE1F68 /* JSByteArray.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSByteArray.cpp; sourceTree = "<group>"; };
A79EDB0811531CD60019E912 /* JSObjectRefPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSObjectRefPrivate.h; sourceTree = "<group>"; };
@@ -900,8 +915,6 @@
A7B48DB50EE74CFC00DCBDB6 /* ExecutableAllocator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ExecutableAllocator.h; sourceTree = "<group>"; };
A7B48DB60EE74CFC00DCBDB6 /* ExecutableAllocator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ExecutableAllocator.cpp; sourceTree = "<group>"; };
A7C1E8C8112E701C00A37F98 /* JITPropertyAccess32_64.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JITPropertyAccess32_64.cpp; sourceTree = "<group>"; };
- A7C2216810C745E000F97913 /* JSZombie.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSZombie.h; sourceTree = "<group>"; };
- A7C2216B10C7469C00F97913 /* JSZombie.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSZombie.cpp; sourceTree = "<group>"; };
A7C530E3102A3813005BC741 /* MarkStackPosix.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MarkStackPosix.cpp; sourceTree = "<group>"; };
A7D649A91015224E009B2E1B /* PossiblyNull.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PossiblyNull.h; sourceTree = "<group>"; };
A7E2EA690FB460CF00601F06 /* LiteralParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LiteralParser.h; sourceTree = "<group>"; };
@@ -916,6 +929,8 @@
A7FB60A3103F7DC20017A286 /* PropertyDescriptor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PropertyDescriptor.cpp; sourceTree = "<group>"; };
A8E894310CD0602400367179 /* JSCallbackObjectFunctions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCallbackObjectFunctions.h; sourceTree = "<group>"; };
A8E894330CD0603F00367179 /* JSGlobalObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSGlobalObject.h; sourceTree = "<group>"; };
+ BC01D4EF11A8F1FF00A54B2A /* JSZombie.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSZombie.cpp; sourceTree = "<group>"; };
+ BC01D4F011A8F1FF00A54B2A /* JSZombie.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSZombie.h; sourceTree = "<group>"; };
BC02E9040E1839DB000F9297 /* ErrorConstructor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ErrorConstructor.cpp; sourceTree = "<group>"; };
BC02E9050E1839DB000F9297 /* ErrorConstructor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ErrorConstructor.h; sourceTree = "<group>"; };
BC02E9060E1839DB000F9297 /* ErrorPrototype.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ErrorPrototype.cpp; sourceTree = "<group>"; };
@@ -1231,6 +1246,7 @@
86A90ECF0EE7D51F00AB350D /* JITArithmetic.cpp */,
A75706DD118A2BCF0057F88F /* JITArithmetic32_64.cpp */,
86CC85A20EE79B7400288682 /* JITCall.cpp */,
+ 146FE51111A710430087AE66 /* JITCall32_64.cpp */,
86CCEFDD0F413F8900FD7F9E /* JITCode.h */,
86CC85A00EE79A4700288682 /* JITInlineMethods.h */,
BCDD51E90FB8DF74004A8BDC /* JITOpcodes.cpp */,
@@ -1427,6 +1443,7 @@
65C647B3093EF8D60022C380 /* RefPtr.h */,
148A1ECD0D10C23B0069A47C /* RefPtrHashMap.h */,
51F648D60BB4E2CA0033D760 /* RetainPtr.h */,
+ 0BF28A2811A33DC300638F84 /* SizeLimits.cpp */,
969A07290ED1CE6900F1F681 /* SegmentedVector.h */,
868BFA5F117D048200B908B1 /* StaticConstructors.h */,
FE1B44790ECCD73B004F4DD1 /* StdLibExtras.h */,
@@ -1604,6 +1621,8 @@
BC7F8FB80E19D1C3008632C0 /* JSNumberCell.h */,
BC22A3980E16E14800AF21C8 /* JSObject.cpp */,
BC22A3990E16E14800AF21C8 /* JSObject.h */,
+ A783A2AA11A5BE8400563D20 /* JSObjectWithGlobalObject.cpp */,
+ A783A0D011A36DCA00563D20 /* JSObjectWithGlobalObject.h */,
A7F9935E0FD7325100A0B2D0 /* JSONObject.cpp */,
A7F9935D0FD7325100A0B2D0 /* JSONObject.h */,
A727FF660DA3053B00E548D7 /* JSPropertyNameIterator.cpp */,
@@ -1621,10 +1640,8 @@
14F252560D08DD8D004ECFFF /* JSVariableObject.h */,
65C7A1710A8EAACB00FA37EA /* JSWrapperObject.cpp */,
65C7A1720A8EAACB00FA37EA /* JSWrapperObject.h */,
- A7C2216B10C7469C00F97913 /* JSZombie.cpp */,
- A7C2216B10C7469C00F97913 /* JSZombie.cpp */,
- A7C2216810C745E000F97913 /* JSZombie.h */,
- A7C2216810C745E000F97913 /* JSZombie.h */,
+ BC01D4EF11A8F1FF00A54B2A /* JSZombie.cpp */,
+ BC01D4F011A8F1FF00A54B2A /* JSZombie.h */,
A7E2EA6A0FB460CF00601F06 /* LiteralParser.cpp */,
A7E2EA690FB460CF00601F06 /* LiteralParser.h */,
F692A8680255597D01FF60F7 /* Lookup.cpp */,
@@ -1784,12 +1801,15 @@
86E116B00FE75AC800B512BC /* CodeLocation.h */,
86D3B3C110159D7F002865E7 /* LinkBuffer.h */,
86C36EE90EE1289D00B3DF59 /* MacroAssembler.h */,
+ 86C568DD11A213EE0007F7F0 /* MacroAssemblerARM.cpp */,
86D3B2C210156BDE002865E7 /* MacroAssemblerARM.h */,
86ADD1440FDDEA980006EEC2 /* MacroAssemblerARMv7.h */,
863B23DF0FC60E6200703AA4 /* MacroAssemblerCodeRef.h */,
+ 86C568DE11A213EE0007F7F0 /* MacroAssemblerMIPS.h */,
860161E00F3A83C100F84710 /* MacroAssemblerX86.h */,
860161E10F3A83C100F84710 /* MacroAssemblerX86_64.h */,
860161E20F3A83C100F84710 /* MacroAssemblerX86Common.h */,
+ 86C568DF11A213EE0007F7F0 /* MIPSAssembler.h */,
86D3B3C210159D7F002865E7 /* RepatchBuffer.h */,
9688CB140ED12B4E001D649F /* X86Assembler.h */,
);
@@ -2136,6 +2156,10 @@
A7386554118697B400540279 /* SpecializedThunkJIT.h in Headers */,
A7386556118697B400540279 /* ThunkGenerators.h in Headers */,
869D04AF1193B54D00803475 /* CachedTranscendentalFunction.h in Headers */,
+ 86C568E111A213EE0007F7F0 /* MacroAssemblerMIPS.h in Headers */,
+ 86C568E211A213EE0007F7F0 /* MIPSAssembler.h in Headers */,
+ A783A0D111A36DCA00563D20 /* JSObjectWithGlobalObject.h in Headers */,
+ BC01D4F211A8F1FF00A54B2A /* JSZombie.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -2511,7 +2535,6 @@
14BD5A320A3E91F600BAF59C /* JSValueRef.cpp in Sources */,
147F39D7107EC37600427A48 /* JSVariableObject.cpp in Sources */,
14280870107EC1340013E7B2 /* JSWrapperObject.cpp in Sources */,
- A7C2217810C7479400F97913 /* JSZombie.cpp in Sources */,
BCFD8C920EEB2EE700283848 /* JumpTable.cpp in Sources */,
148F21B0107EC5410042EC2C /* Lexer.cpp in Sources */,
A7E2EA6C0FB460CF00601F06 /* LiteralParser.cpp in Sources */,
@@ -2578,6 +2601,7 @@
E1EF79AA0CE97BA60088D500 /* UTF8.cpp in Sources */,
86565742115BE3DA00291F40 /* CString.cpp in Sources */,
A7482B9411671147003B0712 /* JSWeakObjectMapRefPrivate.cpp in Sources */,
+ 0BF28A2911A33DC300638F84 /* SizeLimits.cpp in Sources */,
86D08D5311793613006E5ED0 /* WTFThreadData.cpp in Sources */,
868BFA08117CEFD100B908B1 /* AtomicString.cpp in Sources */,
868BFA0E117CEFD100B908B1 /* StringImpl.cpp in Sources */,
@@ -2588,6 +2612,10 @@
A75706DE118A2BCF0057F88F /* JITArithmetic32_64.cpp in Sources */,
8626BECF11928E3900782FAB /* StringStatics.cpp in Sources */,
A71236E51195F33C00BD2174 /* JITOpcodes32_64.cpp in Sources */,
+ 86C568E011A213EE0007F7F0 /* MacroAssemblerARM.cpp in Sources */,
+ 146FE51211A710430087AE66 /* JITCall32_64.cpp in Sources */,
+ A783A2AB11A5BE8400563D20 /* JSObjectWithGlobalObject.cpp in Sources */,
+ BC01D4F111A8F1FF00A54B2A /* JSZombie.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
diff --git a/JavaScriptCore/bytecode/CodeBlock.cpp b/JavaScriptCore/bytecode/CodeBlock.cpp
index 01b06a4..d0132cf 100644
--- a/JavaScriptCore/bytecode/CodeBlock.cpp
+++ b/JavaScriptCore/bytecode/CodeBlock.cpp
@@ -490,11 +490,13 @@ void CodeBlock::dump(ExecState* exec, const Vector<Instruction>::const_iterator&
break;
}
case op_create_arguments: {
- printf("[%4d] create_arguments\n", location);
+ int r0 = (++it)->u.operand;
+ printf("[%4d] create_arguments\t %s\n", location, registerName(exec, r0).data());
break;
}
case op_init_arguments: {
- printf("[%4d] init_arguments\n", location);
+ int r0 = (++it)->u.operand;
+ printf("[%4d] init_arguments\t %s\n", location, registerName(exec, r0).data());
break;
}
case op_convert_this: {
@@ -1026,27 +1028,24 @@ void CodeBlock::dump(ExecState* exec, const Vector<Instruction>::const_iterator&
break;
}
case op_call: {
- int dst = (++it)->u.operand;
int func = (++it)->u.operand;
int argCount = (++it)->u.operand;
int registerOffset = (++it)->u.operand;
- printf("[%4d] call\t\t %s, %s, %d, %d\n", location, registerName(exec, dst).data(), registerName(exec, func).data(), argCount, registerOffset);
+ printf("[%4d] call\t\t %s, %d, %d\n", location, registerName(exec, func).data(), argCount, registerOffset);
break;
}
case op_call_eval: {
- int dst = (++it)->u.operand;
int func = (++it)->u.operand;
int argCount = (++it)->u.operand;
int registerOffset = (++it)->u.operand;
- printf("[%4d] call_eval\t %s, %s, %d, %d\n", location, registerName(exec, dst).data(), registerName(exec, func).data(), argCount, registerOffset);
+ printf("[%4d] call_eval\t %s, %d, %d\n", location, registerName(exec, func).data(), argCount, registerOffset);
break;
}
case op_call_varargs: {
- int dst = (++it)->u.operand;
int func = (++it)->u.operand;
int argCount = (++it)->u.operand;
int registerOffset = (++it)->u.operand;
- printf("[%4d] call_varargs\t %s, %s, %s, %d\n", location, registerName(exec, dst).data(), registerName(exec, func).data(), registerName(exec, argCount).data(), registerOffset);
+ printf("[%4d] call_varargs\t %s, %s, %d\n", location, registerName(exec, func).data(), registerName(exec, argCount).data(), registerOffset);
break;
}
case op_load_varargs: {
@@ -1055,11 +1054,13 @@ void CodeBlock::dump(ExecState* exec, const Vector<Instruction>::const_iterator&
}
case op_tear_off_activation: {
int r0 = (++it)->u.operand;
- printf("[%4d] tear_off_activation\t %s\n", location, registerName(exec, r0).data());
+ int r1 = (++it)->u.operand;
+ printf("[%4d] tear_off_activation\t %s, %s\n", location, registerName(exec, r0).data(), registerName(exec, r1).data());
break;
}
case op_tear_off_arguments: {
- printf("[%4d] tear_off_arguments\n", location);
+ int r0 = (++it)->u.operand;
+ printf("[%4d] tear_off_arguments\t %s\n", location, registerName(exec, r0).data());
break;
}
case op_ret: {
@@ -1067,20 +1068,24 @@ void CodeBlock::dump(ExecState* exec, const Vector<Instruction>::const_iterator&
printf("[%4d] ret\t\t %s\n", location, registerName(exec, r0).data());
break;
}
+ case op_call_put_result: {
+ int r0 = (++it)->u.operand;
+ printf("[%4d] op_call_put_result\t\t %s\n", location, registerName(exec, r0).data());
+ break;
+ }
+ case op_ret_object_or_this: {
+ int r0 = (++it)->u.operand;
+ int r1 = (++it)->u.operand;
+ printf("[%4d] constructor_ret\t\t %s %s\n", location, registerName(exec, r0).data(), registerName(exec, r1).data());
+ break;
+ }
case op_construct: {
- int dst = (++it)->u.operand;
int func = (++it)->u.operand;
int argCount = (++it)->u.operand;
int registerOffset = (++it)->u.operand;
int proto = (++it)->u.operand;
int thisRegister = (++it)->u.operand;
- printf("[%4d] construct\t %s, %s, %d, %d, %s, %s\n", location, registerName(exec, dst).data(), registerName(exec, func).data(), argCount, registerOffset, registerName(exec, proto).data(), registerName(exec, thisRegister).data());
- break;
- }
- case op_construct_verify: {
- int r0 = (++it)->u.operand;
- int r1 = (++it)->u.operand;
- printf("[%4d] construct_verify\t %s, %s\n", location, registerName(exec, r0).data(), registerName(exec, r1).data());
+ printf("[%4d] construct\t %s, %d, %d, %s, %s\n", location, registerName(exec, func).data(), argCount, registerOffset, registerName(exec, proto).data(), registerName(exec, thisRegister).data());
break;
}
case op_strcat: {
@@ -1340,9 +1345,9 @@ CodeBlock::CodeBlock(ScriptExecutable* ownerExecutable, CodeType codeType, PassR
#ifndef NDEBUG
, m_instructionCount(0)
#endif
+ , m_argumentsRegister(-1)
, m_needsFullScopeChain(ownerExecutable->needsActivation())
, m_usesEval(ownerExecutable->usesEval())
- , m_usesArguments(false)
, m_isNumericCompareFunction(false)
, m_codeType(codeType)
, m_source(sourceProvider)
diff --git a/JavaScriptCore/bytecode/CodeBlock.h b/JavaScriptCore/bytecode/CodeBlock.h
index 13956df..e5da2b2 100644
--- a/JavaScriptCore/bytecode/CodeBlock.h
+++ b/JavaScriptCore/bytecode/CodeBlock.h
@@ -62,6 +62,8 @@ namespace JSC {
enum CodeType { GlobalCode, EvalCode, FunctionCode };
+ inline int unmodifiedArgumentsRegister(int argumentsRegister) { return argumentsRegister - 1; }
+
static ALWAYS_INLINE int missingThisObjectMarker() { return std::numeric_limits<int>::max(); }
struct HandlerInfo {
@@ -107,7 +109,7 @@ namespace JSC {
{
}
- unsigned bytecodeIndex;
+ unsigned bytecodeOffset;
CodeLocationNearCall callReturnLocation;
CodeLocationDataLabelPtr hotPathBegin;
CodeLocationNearCall hotPathOther;
@@ -189,15 +191,15 @@ namespace JSC {
// (given as an offset in bytes into the JIT code) back to
// the bytecode index of the corresponding bytecode operation.
// This is then used to look up the corresponding handler.
- struct CallReturnOffsetToBytecodeIndex {
- CallReturnOffsetToBytecodeIndex(unsigned callReturnOffset, unsigned bytecodeIndex)
+ struct CallReturnOffsetToBytecodeOffset {
+ CallReturnOffsetToBytecodeOffset(unsigned callReturnOffset, unsigned bytecodeOffset)
: callReturnOffset(callReturnOffset)
- , bytecodeIndex(bytecodeIndex)
+ , bytecodeOffset(bytecodeOffset)
{
}
unsigned callReturnOffset;
- unsigned bytecodeIndex;
+ unsigned bytecodeOffset;
};
// valueAtPosition helpers for the binaryChop algorithm below.
@@ -217,7 +219,7 @@ namespace JSC {
return methodCallLinkInfo->callReturnLocation.executableAddress();
}
- inline unsigned getCallReturnOffset(CallReturnOffsetToBytecodeIndex* pc)
+ inline unsigned getCallReturnOffset(CallReturnOffsetToBytecodeOffset* pc)
{
return pc->callReturnOffset;
}
@@ -265,7 +267,7 @@ namespace JSC {
Vector<GetByIdExceptionInfo> m_getByIdExceptionInfo;
#if ENABLE(JIT)
- Vector<CallReturnOffsetToBytecodeIndex> m_callReturnIndexVector;
+ Vector<CallReturnOffsetToBytecodeOffset> m_callReturnIndexVector;
#endif
};
@@ -347,13 +349,18 @@ namespace JSC {
return *(binaryChop<MethodCallLinkInfo, void*, getMethodCallLinkInfoReturnLocation>(m_methodCallLinkInfos.begin(), m_methodCallLinkInfos.size(), returnAddress.value()));
}
- unsigned getBytecodeIndex(CallFrame* callFrame, ReturnAddressPtr returnAddress)
+ unsigned bytecodeOffset(CallFrame* callFrame, ReturnAddressPtr returnAddress)
{
reparseForExceptionInfoIfNecessary(callFrame);
- return binaryChop<CallReturnOffsetToBytecodeIndex, unsigned, getCallReturnOffset>(callReturnIndexVector().begin(), callReturnIndexVector().size(), getJITCode().offsetOf(returnAddress.value()))->bytecodeIndex;
+ return binaryChop<CallReturnOffsetToBytecodeOffset, unsigned, getCallReturnOffset>(callReturnIndexVector().begin(), callReturnIndexVector().size(), getJITCode().offsetOf(returnAddress.value()))->bytecodeOffset;
}
bool functionRegisterForBytecodeOffset(unsigned bytecodeOffset, int& functionRegisterIndex);
+#else
+ unsigned bytecodeOffset(CallFrame*, Instruction* returnAddress)
+ {
+ return static_cast<Instruction*>(returnAddress) - instructions().begin();
+ }
#endif
void setIsNumericCompareFunction(bool isNumericCompareFunction) { m_isNumericCompareFunction = isNumericCompareFunction; }
@@ -383,8 +390,19 @@ namespace JSC {
bool needsFullScopeChain() const { return m_needsFullScopeChain; }
void setUsesEval(bool usesEval) { m_usesEval = usesEval; }
bool usesEval() const { return m_usesEval; }
- void setUsesArguments(bool usesArguments) { m_usesArguments = usesArguments; }
- bool usesArguments() const { return m_usesArguments; }
+
+ void setArgumentsRegister(int argumentsRegister)
+ {
+ ASSERT(argumentsRegister != -1);
+ m_argumentsRegister = argumentsRegister;
+ ASSERT(usesArguments());
+ }
+ int argumentsRegister()
+ {
+ ASSERT(usesArguments());
+ return m_argumentsRegister;
+ }
+ bool usesArguments() const { return m_argumentsRegister != -1; }
CodeType codeType() const { return m_codeType; }
@@ -437,7 +455,7 @@ namespace JSC {
LineInfo& lastLineInfo() { ASSERT(m_exceptionInfo); return m_exceptionInfo->m_lineInfo.last(); }
#if ENABLE(JIT)
- Vector<CallReturnOffsetToBytecodeIndex>& callReturnIndexVector() { ASSERT(m_exceptionInfo); return m_exceptionInfo->m_callReturnIndexVector; }
+ Vector<CallReturnOffsetToBytecodeOffset>& callReturnIndexVector() { ASSERT(m_exceptionInfo); return m_exceptionInfo->m_callReturnIndexVector; }
#endif
// Constant Pool
@@ -520,10 +538,10 @@ namespace JSC {
#endif
int m_thisRegister;
+ int m_argumentsRegister;
bool m_needsFullScopeChain;
bool m_usesEval;
- bool m_usesArguments;
bool m_isNumericCompareFunction;
CodeType m_codeType;
diff --git a/JavaScriptCore/bytecode/Opcode.h b/JavaScriptCore/bytecode/Opcode.h
index db54782..30472d5 100644
--- a/JavaScriptCore/bytecode/Opcode.h
+++ b/JavaScriptCore/bytecode/Opcode.h
@@ -40,8 +40,8 @@ namespace JSC {
#define FOR_EACH_OPCODE_ID(macro) \
macro(op_enter, 1) \
macro(op_enter_with_activation, 2) \
- macro(op_init_arguments, 1) \
- macro(op_create_arguments, 1) \
+ macro(op_init_arguments, 2) \
+ macro(op_create_arguments, 2) \
macro(op_convert_this, 2) \
\
macro(op_new_object, 2) \
@@ -153,17 +153,18 @@ namespace JSC {
\
macro(op_new_func, 3) \
macro(op_new_func_exp, 3) \
- macro(op_call, 5) \
- macro(op_call_eval, 5) \
- macro(op_call_varargs, 5) \
+ macro(op_call, 4) \
+ macro(op_call_eval, 4) \
+ macro(op_call_varargs, 4) \
macro(op_load_varargs, 3) \
- macro(op_tear_off_activation, 2) \
- macro(op_tear_off_arguments, 1) \
+ macro(op_tear_off_activation, 3) \
+ macro(op_tear_off_arguments, 2) \
macro(op_ret, 2) \
+ macro(op_call_put_result, 2) \
+ macro(op_ret_object_or_this, 3) \
macro(op_method_check, 1) \
\
- macro(op_construct, 7) \
- macro(op_construct_verify, 3) \
+ macro(op_construct, 6) \
macro(op_strcat, 4) \
macro(op_to_primitive, 3) \
\
diff --git a/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp b/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
index e5f3d15..cdf87d2 100644
--- a/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
+++ b/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
@@ -174,8 +174,7 @@ bool BytecodeGenerator::addVar(const Identifier& ident, bool isConstant, Registe
return false;
}
- ++m_codeBlock->m_numVars;
- r0 = newRegister();
+ r0 = addVar();
return true;
}
@@ -295,6 +294,7 @@ BytecodeGenerator::BytecodeGenerator(FunctionBodyNode* functionBody, const Debug
, m_symbolTable(symbolTable)
, m_scopeNode(functionBody)
, m_codeBlock(codeBlock)
+ , m_activationRegister(0)
, m_finallyDepth(0)
, m_dynamicScopeDepth(0)
, m_baseScopeDepth(0)
@@ -312,29 +312,35 @@ BytecodeGenerator::BytecodeGenerator(FunctionBodyNode* functionBody, const Debug
codeBlock->setGlobalData(m_globalData);
- bool usesArguments = functionBody->usesArguments();
- codeBlock->setUsesArguments(usesArguments);
- if (usesArguments) {
- m_argumentsRegister.setIndex(RegisterFile::OptionalCalleeArguments);
- addVar(propertyNames().arguments, false);
- }
-
if (m_codeBlock->needsFullScopeChain()) {
- ++m_codeBlock->m_numVars;
- m_activationRegisterIndex = newRegister()->index();
+ m_activationRegister = addVar();
emitOpcode(op_enter_with_activation);
- instructions().append(m_activationRegisterIndex);
+ instructions().append(m_activationRegister->index());
} else
emitOpcode(op_enter);
- if (usesArguments) {
+ // Both op_tear_off_activation and op_tear_off_arguments tear off the 'arguments'
+ // object, if created.
+ if (m_codeBlock->needsFullScopeChain() || functionBody->usesArguments()) {
+ RegisterID* unmodifiedArgumentsRegister = addVar(); // Anonymous, so it can't be modified by user code.
+ RegisterID* argumentsRegister = addVar(propertyNames().arguments, false); // Can be changed by assigning to 'arguments'.
+
+ // We can save a little space by hard-coding the knowledge that the two
+ // 'arguments' values are stored in consecutive registers, and storing
+ // only the index of the assignable one.
+ codeBlock->setArgumentsRegister(argumentsRegister->index());
+ ASSERT_UNUSED(unmodifiedArgumentsRegister, unmodifiedArgumentsRegister->index() == JSC::unmodifiedArgumentsRegister(codeBlock->argumentsRegister()));
+
emitOpcode(op_init_arguments);
+ instructions().append(argumentsRegister->index());
// The debugger currently retrieves the arguments object from an activation rather than pulling
// it from a call frame. In the long-term it should stop doing that (<rdar://problem/6911886>),
// but for now we force eager creation of the arguments object when debugging.
- if (m_shouldEmitDebugHooks)
+ if (m_shouldEmitDebugHooks) {
emitOpcode(op_create_arguments);
+ instructions().append(argumentsRegister->index());
+ }
}
const DeclarationStacks::FunctionStack& functionStack = functionBody->functionStack();
@@ -359,7 +365,7 @@ BytecodeGenerator::BytecodeGenerator(FunctionBodyNode* functionBody, const Debug
++m_nextParameterIndex;
++m_codeBlock->m_numParameters;
- if (functionBody->usesThis() || m_shouldEmitDebugHooks) {
+ if (!isConstructor() && (functionBody->usesThis() || m_shouldEmitDebugHooks)) {
emitOpcode(op_convert_this);
instructions().append(m_thisRegister.index());
}
@@ -1025,7 +1031,7 @@ bool BytecodeGenerator::findScopedProperty(const Identifier& property, int& inde
globalObject = currentVariableObject;
return false;
}
- stackDepth = depth;
+ stackDepth = depth + m_codeBlock->needsFullScopeChain();
index = entry.getIndex();
if (++iter == end)
globalObject = currentVariableObject;
@@ -1037,7 +1043,7 @@ bool BytecodeGenerator::findScopedProperty(const Identifier& property, int& inde
requiresDynamicChecks |= scopeRequiresDynamicChecks;
}
// Can't locate the property but we're able to avoid a few lookups.
- stackDepth = depth;
+ stackDepth = depth + m_codeBlock->needsFullScopeChain();
index = missingSymbolMarker();
JSObject* scope = *iter;
if (++iter == end)
@@ -1385,7 +1391,6 @@ RegisterID* BytecodeGenerator::emitNewRegExp(RegisterID* dst, RegExp* regExp)
return dst;
}
-
RegisterID* BytecodeGenerator::emitNewFunctionExpression(RegisterID* r0, FuncExprNode* n)
{
FunctionBodyNode* function = n->body();
@@ -1404,13 +1409,16 @@ RegisterID* BytecodeGenerator::emitCall(RegisterID* dst, RegisterID* func, Regis
void BytecodeGenerator::createArgumentsIfNecessary()
{
- if (m_codeBlock->usesArguments() && m_codeType == FunctionCode)
- emitOpcode(op_create_arguments);
+ if (m_codeType != FunctionCode)
+ return;
+ ASSERT(m_codeBlock->usesArguments());
+
+ emitOpcode(op_create_arguments);
+ instructions().append(m_codeBlock->argumentsRegister());
}
RegisterID* BytecodeGenerator::emitCallEval(RegisterID* dst, RegisterID* func, RegisterID* thisRegister, ArgumentsNode* argumentsNode, unsigned divot, unsigned startOffset, unsigned endOffset)
{
- createArgumentsIfNecessary();
return emitCall(op_call_eval, dst, func, thisRegister, argumentsNode, divot, startOffset, endOffset);
}
@@ -1466,10 +1474,13 @@ RegisterID* BytecodeGenerator::emitCall(OpcodeID opcodeID, RegisterID* dst, Regi
// Emit call.
emitOpcode(opcodeID);
- instructions().append(dst->index()); // dst
instructions().append(func->index()); // func
instructions().append(argv.size()); // argCount
instructions().append(argv[0]->index() + argv.size() + RegisterFile::CallFrameHeaderSize); // registerOffset
+ if (dst != ignoredResult()) {
+ emitOpcode(op_call_put_result);
+ instructions().append(dst->index()); // dst
+ }
if (m_shouldEmitProfileHooks) {
emitOpcode(op_profile_did_call);
@@ -1511,10 +1522,13 @@ RegisterID* BytecodeGenerator::emitCallVarargs(RegisterID* dst, RegisterID* func
// Emit call.
emitOpcode(op_call_varargs);
- instructions().append(dst->index()); // dst
instructions().append(func->index()); // func
instructions().append(argCountRegister->index()); // arg count
instructions().append(thisRegister->index() + RegisterFile::CallFrameHeaderSize); // initial registerOffset
+ if (dst != ignoredResult()) {
+ emitOpcode(op_call_put_result);
+ instructions().append(dst->index()); // dst
+ }
if (m_shouldEmitProfileHooks) {
emitOpcode(op_profile_did_call);
instructions().append(func->index());
@@ -1526,10 +1540,22 @@ RegisterID* BytecodeGenerator::emitReturn(RegisterID* src)
{
if (m_codeBlock->needsFullScopeChain()) {
emitOpcode(op_tear_off_activation);
- instructions().append(m_activationRegisterIndex);
- } else if (m_codeBlock->usesArguments() && m_codeBlock->m_numParameters > 1)
+ instructions().append(m_activationRegister->index());
+ instructions().append(m_codeBlock->argumentsRegister());
+ } else if (m_codeBlock->usesArguments() && m_codeBlock->m_numParameters > 1) { // If there are no named parameters, there's nothing to tear off, since extra / unnamed parameters get copied to the arguments object at construct time.
emitOpcode(op_tear_off_arguments);
+ instructions().append(m_codeBlock->argumentsRegister());
+ }
+ // Constructors use op_ret_object_or_this to check the result is an
+ // object, unless we can trivially determine the check is not
+ // necessary (currently, if the return value is 'this').
+ if (isConstructor() && (src->index() != m_thisRegister.index())) {
+ emitOpcode(op_ret_object_or_this);
+ instructions().append(src->index());
+ instructions().append(m_thisRegister.index());
+ return src;
+ }
return emitUnaryNoDstOp(op_ret, src);
}
@@ -1589,16 +1615,15 @@ RegisterID* BytecodeGenerator::emitConstruct(RegisterID* dst, RegisterID* func,
#endif
emitOpcode(op_construct);
- instructions().append(dst->index()); // dst
instructions().append(func->index()); // func
instructions().append(argv.size()); // argCount
instructions().append(argv[0]->index() + argv.size() + RegisterFile::CallFrameHeaderSize); // registerOffset
instructions().append(funcProto->index()); // proto
instructions().append(argv[0]->index()); // thisRegister
-
- emitOpcode(op_construct_verify);
- instructions().append(dst->index());
- instructions().append(argv[0]->index());
+ if (dst != ignoredResult()) {
+ emitOpcode(op_call_put_result);
+ instructions().append(dst->index()); // dst
+ }
if (m_shouldEmitProfileHooks) {
emitOpcode(op_profile_did_call);
@@ -1635,7 +1660,6 @@ RegisterID* BytecodeGenerator::emitPushScope(RegisterID* scope)
context.isFinallyBlock = false;
m_scopeContextStack.append(context);
m_dynamicScopeDepth++;
- createArgumentsIfNecessary();
return emitUnaryNoDstOp(op_push_scope, scope);
}
@@ -1899,8 +1923,6 @@ void BytecodeGenerator::emitPushNewScope(RegisterID* dst, const Identifier& prop
context.isFinallyBlock = false;
m_scopeContextStack.append(context);
m_dynamicScopeDepth++;
-
- createArgumentsIfNecessary();
emitOpcode(op_push_new_scope);
instructions().append(dst->index());
diff --git a/JavaScriptCore/bytecompiler/BytecodeGenerator.h b/JavaScriptCore/bytecompiler/BytecodeGenerator.h
index 0a49392..7626bf4 100644
--- a/JavaScriptCore/bytecompiler/BytecodeGenerator.h
+++ b/JavaScriptCore/bytecompiler/BytecodeGenerator.h
@@ -83,6 +83,8 @@ namespace JSC {
JSGlobalData* globalData() const { return m_globalData; }
const CommonIdentifiers& propertyNames() const { return *m_globalData->propertyNames; }
+ bool isConstructor() { return m_codeBlock->m_isConstructor; }
+
void generate();
// Returns the register corresponding to a local variable, or 0 if no
@@ -103,9 +105,6 @@ namespace JSC {
// VariableObject that defines the property. If the property cannot be found
// statically, depth will contain the depth of the scope chain where dynamic
// lookup must begin.
- //
- // NB: depth does _not_ include the local scope. eg. a depth of 0 refers
- // to the scope containing this codeblock.
bool findScopedProperty(const Identifier&, int& index, size_t& depth, bool forWriting, bool& includesDynamicScopes, JSObject*& globalObject);
// Returns the register storing "this"
@@ -150,6 +149,17 @@ namespace JSC {
return newTemporary();
}
+ // Returns the place to write the final output of an operation.
+ RegisterID* finalDestinationOrIgnored(RegisterID* originalDst, RegisterID* tempDst = 0)
+ {
+ if (originalDst)
+ return originalDst;
+ ASSERT(tempDst != ignoredResult());
+ if (tempDst && tempDst->isTemporary())
+ return tempDst;
+ return newTemporary();
+ }
+
RegisterID* destinationForAssignResult(RegisterID* dst)
{
if (dst && dst != ignoredResult() && m_codeBlock->needsFullScopeChain())
@@ -404,15 +414,23 @@ namespace JSC {
RegisterID* newRegister();
- // Returns the RegisterID corresponding to ident.
+ // Adds a var slot and maps it to the name ident in symbolTable().
RegisterID* addVar(const Identifier& ident, bool isConstant)
{
RegisterID* local;
addVar(ident, isConstant, local);
return local;
}
- // Returns true if a new RegisterID was added, false if a pre-existing RegisterID was re-used.
+
+ // Ditto. Returns true if a new RegisterID was added, false if a pre-existing RegisterID was re-used.
bool addVar(const Identifier&, bool isConstant, RegisterID*&);
+
+ // Adds an anonymous var slot. To give this slot a name, add it to symbolTable().
+ RegisterID* addVar()
+ {
+ ++m_codeBlock->m_numVars;
+ return newRegister();
+ }
// Returns the RegisterID corresponding to ident.
RegisterID* addGlobalVar(const Identifier& ident, bool isConstant)
@@ -433,9 +451,6 @@ namespace JSC {
if (index >= 0)
return m_calleeRegisters[index];
- if (index == RegisterFile::OptionalCalleeArguments)
- return m_argumentsRegister;
-
if (m_parameters.size()) {
ASSERT(!m_globals.size());
return m_parameters[index + m_parameters.size() + RegisterFile::CallFrameHeaderSize];
@@ -482,8 +497,7 @@ namespace JSC {
HashSet<RefPtr<UString::Rep>, IdentifierRepHash> m_functions;
RegisterID m_ignoredResultRegister;
RegisterID m_thisRegister;
- RegisterID m_argumentsRegister;
- int m_activationRegisterIndex;
+ RegisterID* m_activationRegister;
SegmentedVector<RegisterID, 32> m_constantPoolRegisters;
SegmentedVector<RegisterID, 32> m_calleeRegisters;
SegmentedVector<RegisterID, 32> m_parameters;
diff --git a/JavaScriptCore/bytecompiler/NodesCodegen.cpp b/JavaScriptCore/bytecompiler/NodesCodegen.cpp
index cfd00da..c514b7a 100644
--- a/JavaScriptCore/bytecompiler/NodesCodegen.cpp
+++ b/JavaScriptCore/bytecompiler/NodesCodegen.cpp
@@ -316,7 +316,7 @@ RegisterID* ArgumentListNode::emitBytecode(BytecodeGenerator& generator, Registe
RegisterID* NewExprNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
{
RefPtr<RegisterID> func = generator.emitNode(m_expr);
- return generator.emitConstruct(generator.finalDestination(dst), func.get(), m_args, divot(), startOffset(), endOffset());
+ return generator.emitConstruct(generator.finalDestinationOrIgnored(dst), func.get(), m_args, divot(), startOffset(), endOffset());
}
// ------------------------------ EvalFunctionCallNode ----------------------------------
@@ -336,7 +336,7 @@ RegisterID* FunctionCallValueNode::emitBytecode(BytecodeGenerator& generator, Re
{
RefPtr<RegisterID> func = generator.emitNode(m_expr);
RefPtr<RegisterID> thisRegister = generator.emitLoad(generator.newTemporary(), jsNull());
- return generator.emitCall(generator.finalDestination(dst, func.get()), func.get(), thisRegister.get(), m_args, divot(), startOffset(), endOffset());
+ return generator.emitCall(generator.finalDestinationOrIgnored(dst, func.get()), func.get(), thisRegister.get(), m_args, divot(), startOffset(), endOffset());
}
// ------------------------------ FunctionCallResolveNode ----------------------------------
@@ -345,7 +345,7 @@ RegisterID* FunctionCallResolveNode::emitBytecode(BytecodeGenerator& generator,
{
if (RefPtr<RegisterID> local = generator.registerFor(m_ident)) {
RefPtr<RegisterID> thisRegister = generator.emitLoad(generator.newTemporary(), jsNull());
- return generator.emitCall(generator.finalDestination(dst, thisRegister.get()), local.get(), thisRegister.get(), m_args, divot(), startOffset(), endOffset());
+ return generator.emitCall(generator.finalDestinationOrIgnored(dst, thisRegister.get()), local.get(), thisRegister.get(), m_args, divot(), startOffset(), endOffset());
}
int index = 0;
@@ -355,7 +355,7 @@ RegisterID* FunctionCallResolveNode::emitBytecode(BytecodeGenerator& generator,
if (generator.findScopedProperty(m_ident, index, depth, false, requiresDynamicChecks, globalObject) && index != missingSymbolMarker() && !requiresDynamicChecks) {
RefPtr<RegisterID> func = generator.emitGetScopedVar(generator.newTemporary(), depth, index, globalObject);
RefPtr<RegisterID> thisRegister = generator.emitLoad(generator.newTemporary(), jsNull());
- return generator.emitCall(generator.finalDestination(dst, func.get()), func.get(), thisRegister.get(), m_args, divot(), startOffset(), endOffset());
+ return generator.emitCall(generator.finalDestinationOrIgnored(dst, func.get()), func.get(), thisRegister.get(), m_args, divot(), startOffset(), endOffset());
}
RefPtr<RegisterID> func = generator.newTemporary();
@@ -363,7 +363,7 @@ RegisterID* FunctionCallResolveNode::emitBytecode(BytecodeGenerator& generator,
int identifierStart = divot() - startOffset();
generator.emitExpressionInfo(identifierStart + m_ident.size(), m_ident.size(), 0);
generator.emitResolveWithBase(thisRegister.get(), func.get(), m_ident);
- return generator.emitCall(generator.finalDestination(dst, func.get()), func.get(), thisRegister.get(), m_args, divot(), startOffset(), endOffset());
+ return generator.emitCall(generator.finalDestinationOrIgnored(dst, func.get()), func.get(), thisRegister.get(), m_args, divot(), startOffset(), endOffset());
}
// ------------------------------ FunctionCallBracketNode ----------------------------------
@@ -375,7 +375,7 @@ RegisterID* FunctionCallBracketNode::emitBytecode(BytecodeGenerator& generator,
generator.emitExpressionInfo(divot() - m_subexpressionDivotOffset, startOffset() - m_subexpressionDivotOffset, m_subexpressionEndOffset);
RefPtr<RegisterID> function = generator.emitGetByVal(generator.tempDestination(dst), base.get(), property);
RefPtr<RegisterID> thisRegister = generator.emitMove(generator.newTemporary(), base.get());
- return generator.emitCall(generator.finalDestination(dst, function.get()), function.get(), thisRegister.get(), m_args, divot(), startOffset(), endOffset());
+ return generator.emitCall(generator.finalDestinationOrIgnored(dst, function.get()), function.get(), thisRegister.get(), m_args, divot(), startOffset(), endOffset());
}
// ------------------------------ FunctionCallDotNode ----------------------------------
@@ -388,7 +388,7 @@ RegisterID* FunctionCallDotNode::emitBytecode(BytecodeGenerator& generator, Regi
generator.emitExpressionInfo(divot() - m_subexpressionDivotOffset, startOffset() - m_subexpressionDivotOffset, m_subexpressionEndOffset);
generator.emitMethodCheck();
generator.emitGetById(function.get(), thisRegister.get(), m_ident);
- return generator.emitCall(generator.finalDestination(dst, function.get()), function.get(), thisRegister.get(), m_args, divot(), startOffset(), endOffset());
+ return generator.emitCall(generator.finalDestinationOrIgnored(dst, function.get()), function.get(), thisRegister.get(), m_args, divot(), startOffset(), endOffset());
}
RegisterID* CallFunctionCallDotNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
@@ -398,7 +398,7 @@ RegisterID* CallFunctionCallDotNode::emitBytecode(BytecodeGenerator& generator,
RefPtr<RegisterID> base = generator.emitNode(m_base);
generator.emitExpressionInfo(divot() - m_subexpressionDivotOffset, startOffset() - m_subexpressionDivotOffset, m_subexpressionEndOffset);
RefPtr<RegisterID> function = generator.emitGetById(generator.tempDestination(dst), base.get(), m_ident);
- RefPtr<RegisterID> finalDestination = generator.finalDestination(dst, function.get());
+ RefPtr<RegisterID> finalDestinationOrIgnored = generator.finalDestinationOrIgnored(dst, function.get());
generator.emitJumpIfNotFunctionCall(function.get(), realCall.get());
{
RefPtr<RegisterID> realFunction = generator.emitMove(generator.tempDestination(dst), base.get());
@@ -410,17 +410,17 @@ RegisterID* CallFunctionCallDotNode::emitBytecode(BytecodeGenerator& generator,
} else
generator.emitLoad(thisRegister.get(), jsNull());
- generator.emitCall(finalDestination.get(), realFunction.get(), thisRegister.get(), m_args, divot(), startOffset(), endOffset());
+ generator.emitCall(finalDestinationOrIgnored.get(), realFunction.get(), thisRegister.get(), m_args, divot(), startOffset(), endOffset());
generator.emitJump(end.get());
m_args->m_listNode = oldList;
}
generator.emitLabel(realCall.get());
{
RefPtr<RegisterID> thisRegister = generator.emitMove(generator.newTemporary(), base.get());
- generator.emitCall(finalDestination.get(), function.get(), thisRegister.get(), m_args, divot(), startOffset(), endOffset());
+ generator.emitCall(finalDestinationOrIgnored.get(), function.get(), thisRegister.get(), m_args, divot(), startOffset(), endOffset());
}
generator.emitLabel(end.get());
- return finalDestination.get();
+ return finalDestinationOrIgnored.get();
}
static bool areTrivialApplyArguments(ArgumentsNode* args)
@@ -441,7 +441,7 @@ RegisterID* ApplyFunctionCallDotNode::emitBytecode(BytecodeGenerator& generator,
RefPtr<RegisterID> base = generator.emitNode(m_base);
generator.emitExpressionInfo(divot() - m_subexpressionDivotOffset, startOffset() - m_subexpressionDivotOffset, m_subexpressionEndOffset);
RefPtr<RegisterID> function = generator.emitGetById(generator.tempDestination(dst), base.get(), m_ident);
- RefPtr<RegisterID> finalDestination = generator.finalDestination(dst, function.get());
+ RefPtr<RegisterID> finalDestinationOrIgnored = generator.finalDestinationOrIgnored(dst, function.get());
generator.emitJumpIfNotFunctionApply(function.get(), realCall.get());
{
if (mayBeCall) {
@@ -458,7 +458,7 @@ RegisterID* ApplyFunctionCallDotNode::emitBytecode(BytecodeGenerator& generator,
}
} else
generator.emitLoad(thisRegister.get(), jsNull());
- generator.emitCall(finalDestination.get(), realFunction.get(), thisRegister.get(), m_args, divot(), startOffset(), endOffset());
+ generator.emitCall(finalDestinationOrIgnored.get(), realFunction.get(), thisRegister.get(), m_args, divot(), startOffset(), endOffset());
m_args->m_listNode = oldList;
} else {
ASSERT(m_args->m_listNode && m_args->m_listNode->m_next);
@@ -481,17 +481,17 @@ RegisterID* ApplyFunctionCallDotNode::emitBytecode(BytecodeGenerator& generator,
generator.emitNode(args->m_expr);
generator.emitLoadVarargs(argsCountRegister.get(), argsRegister.get());
- generator.emitCallVarargs(finalDestination.get(), realFunction.get(), thisRegister.get(), argsCountRegister.get(), divot(), startOffset(), endOffset());
+ generator.emitCallVarargs(finalDestinationOrIgnored.get(), realFunction.get(), thisRegister.get(), argsCountRegister.get(), divot(), startOffset(), endOffset());
}
generator.emitJump(end.get());
}
generator.emitLabel(realCall.get());
{
RefPtr<RegisterID> thisRegister = generator.emitMove(generator.newTemporary(), base.get());
- generator.emitCall(finalDestination.get(), function.get(), thisRegister.get(), m_args, divot(), startOffset(), endOffset());
+ generator.emitCall(finalDestinationOrIgnored.get(), function.get(), thisRegister.get(), m_args, divot(), startOffset(), endOffset());
}
generator.emitLabel(end.get());
- return finalDestination.get();
+ return finalDestinationOrIgnored.get();
}
// ------------------------------ PostfixResolveNode ----------------------------------
@@ -1979,7 +1979,7 @@ RegisterID* FunctionBodyNode::emitBytecode(BytecodeGenerator& generator, Registe
return 0;
}
- RegisterID* r0 = generator.emitLoad(0, jsUndefined());
+ RegisterID* r0 = generator.isConstructor() ? generator.thisRegister() : generator.emitLoad(0, jsUndefined());
generator.emitDebugHook(WillLeaveCallFrame, firstLine(), lastLine());
generator.emitReturn(r0);
return 0;
diff --git a/JavaScriptCore/interpreter/CallFrame.h b/JavaScriptCore/interpreter/CallFrame.h
index e3ea689..a875119 100644
--- a/JavaScriptCore/interpreter/CallFrame.h
+++ b/JavaScriptCore/interpreter/CallFrame.h
@@ -24,6 +24,7 @@
#define CallFrame_h
#include "JSGlobalData.h"
+#include "MacroAssemblerCodeRef.h"
#include "RegisterFile.h"
#include "ScopeChain.h"
@@ -107,15 +108,17 @@ namespace JSC {
CallFrame& operator=(const Register& r) { *static_cast<Register*>(this) = r; return *this; }
CallFrame* callerFrame() const { return this[RegisterFile::CallerFrame].callFrame(); }
- Arguments* optionalCalleeArguments() const { return this[RegisterFile::OptionalCalleeArguments].arguments(); }
+#if ENABLE(JIT)
+ ReturnAddressPtr returnPC() const { return ReturnAddressPtr(this[RegisterFile::ReturnPC].vPC()); }
+#else
Instruction* returnPC() const { return this[RegisterFile::ReturnPC].vPC(); }
+#endif
- void setCalleeArguments(JSValue arguments) { static_cast<Register*>(this)[RegisterFile::OptionalCalleeArguments] = arguments; }
void setCallerFrame(CallFrame* callerFrame) { static_cast<Register*>(this)[RegisterFile::CallerFrame] = callerFrame; }
void setScopeChain(ScopeChainNode* scopeChain) { static_cast<Register*>(this)[RegisterFile::ScopeChain] = scopeChain; }
ALWAYS_INLINE void init(CodeBlock* codeBlock, Instruction* vPC, ScopeChainNode* scopeChain,
- CallFrame* callerFrame, int returnValueRegister, int argc, JSFunction* function)
+ CallFrame* callerFrame, int, int argc, JSFunction* function)
{
ASSERT(callerFrame); // Use noCaller() rather than 0 for the outer host call frame caller.
@@ -123,17 +126,14 @@ namespace JSC {
setScopeChain(scopeChain);
setCallerFrame(callerFrame);
static_cast<Register*>(this)[RegisterFile::ReturnPC] = vPC; // This is either an Instruction* or a pointer into JIT generated code stored as an Instruction*.
- static_cast<Register*>(this)[RegisterFile::ReturnValueRegister] = Register::withInt(returnValueRegister);
setArgumentCount(argc); // original argument count (for the sake of the "arguments" object)
setCallee(function);
- setCalleeArguments(JSValue());
}
// Read a register from the codeframe (or constant from the CodeBlock).
inline Register& r(int);
static CallFrame* noCaller() { return reinterpret_cast<CallFrame*>(HostCallFrameFlag); }
- int returnValueRegister() const { return this[RegisterFile::ReturnValueRegister].i(); }
bool hasHostCallFrameFlag() const { return reinterpret_cast<intptr_t>(this) & HostCallFrameFlag; }
CallFrame* addHostCallFrameFlag() const { return reinterpret_cast<CallFrame*>(reinterpret_cast<intptr_t>(this) | HostCallFrameFlag); }
diff --git a/JavaScriptCore/interpreter/CallFrameClosure.h b/JavaScriptCore/interpreter/CallFrameClosure.h
index a301060..b4b7efd 100644
--- a/JavaScriptCore/interpreter/CallFrameClosure.h
+++ b/JavaScriptCore/interpreter/CallFrameClosure.h
@@ -46,10 +46,10 @@ struct CallFrameClosure {
else
newCallFrame[arg - RegisterFile::CallFrameHeaderSize - expectedParams - providedParams] = value;
}
+
void resetCallFrame()
{
newCallFrame->setScopeChain(scopeChain);
- newCallFrame->setCalleeArguments(JSValue());
for (int i = providedParams; i < expectedParams; ++i)
newCallFrame[i - RegisterFile::CallFrameHeaderSize - expectedParams] = jsUndefined();
}
diff --git a/JavaScriptCore/interpreter/Interpreter.cpp b/JavaScriptCore/interpreter/Interpreter.cpp
index 7548cf9..1fbc9b7 100644
--- a/JavaScriptCore/interpreter/Interpreter.cpp
+++ b/JavaScriptCore/interpreter/Interpreter.cpp
@@ -71,16 +71,6 @@ using namespace std;
namespace JSC {
-static ALWAYS_INLINE unsigned bytecodeOffsetForPC(CallFrame* callFrame, CodeBlock* codeBlock, void* pc)
-{
-#if ENABLE(JIT)
- return codeBlock->getBytecodeIndex(callFrame, ReturnAddressPtr(pc));
-#else
- UNUSED_PARAM(callFrame);
- return static_cast<Instruction*>(pc) - codeBlock->instructions().begin();
-#endif
-}
-
// Returns the depth of the scope chain within a given call frame.
static int depth(CodeBlock* codeBlock, ScopeChain& sc)
{
@@ -89,7 +79,7 @@ static int depth(CodeBlock* codeBlock, ScopeChain& sc)
return sc.localDepth();
}
-#if USE(INTERPRETER)
+#if !ENABLE(JIT)
NEVER_INLINE bool Interpreter::resolve(CallFrame* callFrame, Instruction* vPC, JSValue& exceptionValue)
{
int dst = vPC[1].u.operand;
@@ -124,7 +114,7 @@ NEVER_INLINE bool Interpreter::resolveSkip(CallFrame* callFrame, Instruction* vP
int dst = vPC[1].u.operand;
int property = vPC[2].u.operand;
- int skip = vPC[3].u.operand + codeBlock->needsFullScopeChain();
+ int skip = vPC[3].u.operand;
ScopeChainNode* scopeChain = callFrame->scopeChain();
ScopeChainIterator iter = scopeChain->begin();
@@ -200,7 +190,7 @@ NEVER_INLINE bool Interpreter::resolveGlobalDynamic(CallFrame* callFrame, Instru
Structure* structure = vPC[4].u.structure;
int offset = vPC[5].u.operand;
CodeBlock* codeBlock = callFrame->codeBlock();
- int skip = vPC[6].u.operand + codeBlock->needsFullScopeChain();
+ int skip = vPC[6].u.operand;
ScopeChainNode* scopeChain = callFrame->scopeChain();
ScopeChainIterator iter = scopeChain->begin();
@@ -304,7 +294,7 @@ NEVER_INLINE bool Interpreter::resolveBaseAndProperty(CallFrame* callFrame, Inst
return false;
}
-#endif // USE(INTERPRETER)
+#endif // !ENABLE(JIT)
ALWAYS_INLINE CallFrame* Interpreter::slideRegisterWindowForCall(CodeBlock* newCodeBlock, RegisterFile* registerFile, CallFrame* callFrame, size_t registerOffset, int argc)
{
@@ -343,7 +333,7 @@ ALWAYS_INLINE CallFrame* Interpreter::slideRegisterWindowForCall(CodeBlock* newC
return CallFrame::create(r);
}
-#if USE(INTERPRETER)
+#if !ENABLE(JIT)
static NEVER_INLINE bool isInvalidParamForIn(CallFrame* callFrame, CodeBlock* codeBlock, const Instruction* vPC, JSValue value, JSValue& exceptionData)
{
if (value.isObject())
@@ -372,6 +362,8 @@ NEVER_INLINE JSValue Interpreter::callEval(CallFrame* callFrame, RegisterFile* r
return program;
UString programSource = asString(program)->value(callFrame);
+ if (callFrame->hadException())
+ return JSValue();
LiteralParser preparser(callFrame, programSource, LiteralParser::NonStrictJSON);
if (JSValue parsedObject = preparser.tryLiteralParse())
@@ -464,10 +456,9 @@ void Interpreter::dumpRegisters(CallFrame* callFrame)
printf("[ScopeChain] | %10p | %p \n", it, (*it).scopeChain()); ++it;
printf("[CallerRegisters] | %10p | %d \n", it, (*it).i()); ++it;
printf("[ReturnPC] | %10p | %p \n", it, (*it).vPC()); ++it;
- printf("[ReturnValueRegister] | %10p | %d \n", it, (*it).i()); ++it;
+ ++it;
printf("[ArgumentCount] | %10p | %d \n", it, (*it).i()); ++it;
printf("[Callee] | %10p | %p \n", it, (*it).function()); ++it;
- printf("[OptionalCalleeArguments] | %10p | %p \n", it, (*it).arguments()); ++it;
printf("-----------------------------------------------------------------------------\n");
int registerCount = 0;
@@ -540,22 +531,25 @@ NEVER_INLINE bool Interpreter::unwindCallFrame(CallFrame*& callFrame, JSValue ex
if (oldCodeBlock->codeType() == FunctionCode && oldCodeBlock->needsFullScopeChain()) {
while (!scopeChain->object->inherits(&JSActivation::info))
scopeChain = scopeChain->pop();
- static_cast<JSActivation*>(scopeChain->object)->copyRegisters(callFrame->optionalCalleeArguments());
- } else if (Arguments* arguments = callFrame->optionalCalleeArguments()) {
- if (!arguments->isTornOff())
- arguments->copyRegisters();
+ JSActivation* activation = asActivation(scopeChain->object);
+ activation->copyRegisters();
+ if (JSValue arguments = callFrame->r(unmodifiedArgumentsRegister(oldCodeBlock->argumentsRegister())).jsValue())
+ asArguments(arguments)->setActivation(activation);
+ } else if (oldCodeBlock->usesArguments()) {
+ if (JSValue arguments = callFrame->r(unmodifiedArgumentsRegister(oldCodeBlock->argumentsRegister())).jsValue())
+ asArguments(arguments)->copyRegisters();
}
if (oldCodeBlock->needsFullScopeChain())
scopeChain->deref();
- void* returnPC = callFrame->returnPC();
- callFrame = callFrame->callerFrame();
- if (callFrame->hasHostCallFrameFlag())
+ CallFrame* callerFrame = callFrame->callerFrame();
+ if (callerFrame->hasHostCallFrameFlag())
return false;
- codeBlock = callFrame->codeBlock();
- bytecodeOffset = bytecodeOffsetForPC(callFrame, codeBlock, returnPC);
+ codeBlock = callerFrame->codeBlock();
+ bytecodeOffset = codeBlock->bytecodeOffset(callerFrame, callFrame->returnPC());
+ callFrame = callerFrame;
return true;
}
@@ -614,10 +608,11 @@ NEVER_INLINE HandlerInfo* Interpreter::throwException(CallFrame*& callFrame, JSV
// we'll never reach the relevant op_profile_did_call.
if (Profiler* profiler = *Profiler::enabledProfilerReference()) {
#if !ENABLE(JIT)
+ // FIXME: Why 8? - work out what this magic value is, replace the constant with something more helpful.
if (isCallBytecode(codeBlock->instructions()[bytecodeOffset].u.opcode))
- profiler->didExecute(callFrame, callFrame->r(codeBlock->instructions()[bytecodeOffset + 2].u.operand).jsValue());
+ profiler->didExecute(callFrame, callFrame->r(codeBlock->instructions()[bytecodeOffset + 1].u.operand).jsValue());
else if (codeBlock->instructions().size() > (bytecodeOffset + 8) && codeBlock->instructions()[bytecodeOffset + 8].u.opcode == getOpcode(op_construct))
- profiler->didExecute(callFrame, callFrame->r(codeBlock->instructions()[bytecodeOffset + 10].u.operand).jsValue());
+ profiler->didExecute(callFrame, callFrame->r(codeBlock->instructions()[bytecodeOffset + 9].u.operand).jsValue());
#else
int functionRegisterIndex;
if (codeBlock->functionRegisterForBytecodeOffset(bytecodeOffset, functionRegisterIndex))
@@ -1020,7 +1015,7 @@ NEVER_INLINE void Interpreter::debug(CallFrame* callFrame, DebugHookID debugHook
}
}
-#if USE(INTERPRETER)
+#if !ENABLE(JIT)
NEVER_INLINE ScopeChainNode* Interpreter::createExceptionScope(CallFrame* callFrame, const Instruction* vPC)
{
int dst = vPC[1].u.operand;
@@ -1256,7 +1251,7 @@ NEVER_INLINE void Interpreter::uncacheGetByID(CodeBlock* codeBlock, Instruction*
vPC[4] = 0;
}
-#endif // USE(INTERPRETER)
+#endif // !ENABLE(JIT)
JSValue Interpreter::privateExecute(ExecutionFlag flag, RegisterFile* registerFile, CallFrame* callFrame, JSValue* exception)
{
@@ -1277,7 +1272,7 @@ JSValue Interpreter::privateExecute(ExecutionFlag flag, RegisterFile* registerFi
// Mixing Interpreter + JIT is not supported.
ASSERT_NOT_REACHED();
#endif
-#if !USE(INTERPRETER)
+#if !!ENABLE(JIT)
UNUSED_PARAM(registerFile);
UNUSED_PARAM(callFrame);
UNUSED_PARAM(exception);
@@ -1288,9 +1283,11 @@ JSValue Interpreter::privateExecute(ExecutionFlag flag, RegisterFile* registerFi
JSValue exceptionValue;
HandlerInfo* handler = 0;
- Instruction* vPC = callFrame->codeBlock()->instructions().begin();
+ CodeBlock* codeBlock = callFrame->codeBlock();
+ Instruction* vPC = codeBlock->instructions().begin();
Profiler** enabledProfilerReference = Profiler::enabledProfilerReference();
unsigned tickCount = globalData->timeoutChecker.ticksUntilNextCheck();
+ JSValue functionReturnValue;
#define CHECK_FOR_EXCEPTION() \
do { \
@@ -1320,7 +1317,7 @@ JSValue Interpreter::privateExecute(ExecutionFlag flag, RegisterFile* registerFi
#endif
#if HAVE(COMPUTED_GOTO)
- #define NEXT_INSTRUCTION() SAMPLE(callFrame->codeBlock(), vPC); goto *vPC->u.opcode
+ #define NEXT_INSTRUCTION() SAMPLE(codeBlock, vPC); goto *vPC->u.opcode
#if ENABLE(OPCODE_STATS)
#define DEFINE_OPCODE(opcode) opcode: OpcodeStats::recordInstruction(opcode);
#else
@@ -1328,7 +1325,7 @@ JSValue Interpreter::privateExecute(ExecutionFlag flag, RegisterFile* registerFi
#endif
NEXT_INSTRUCTION();
#else
- #define NEXT_INSTRUCTION() SAMPLE(callFrame->codeBlock(), vPC); goto interpreterLoopStart
+ #define NEXT_INSTRUCTION() SAMPLE(codeBlock, vPC); goto interpreterLoopStart
#if ENABLE(OPCODE_STATS)
#define DEFINE_OPCODE(opcode) case opcode: OpcodeStats::recordInstruction(opcode);
#else
@@ -1377,7 +1374,7 @@ JSValue Interpreter::privateExecute(ExecutionFlag flag, RegisterFile* registerFi
*/
int dst = vPC[1].u.operand;
int regExp = vPC[2].u.operand;
- callFrame->r(dst) = JSValue(new (globalData) RegExpObject(callFrame->scopeChain()->globalObject->regExpStructure(), callFrame->codeBlock()->regexp(regExp)));
+ callFrame->r(dst) = JSValue(new (globalData) RegExpObject(callFrame->lexicalGlobalObject(), callFrame->scopeChain()->globalObject->regExpStructure(), codeBlock->regexp(regExp)));
vPC += OPCODE_LENGTH(op_new_regexp);
NEXT_INSTRUCTION();
@@ -1484,7 +1481,9 @@ JSValue Interpreter::privateExecute(ExecutionFlag flag, RegisterFile* registerFi
int dst = vPC[1].u.operand;
JSValue src1 = callFrame->r(vPC[2].u.operand).jsValue();
JSValue src2 = callFrame->r(vPC[3].u.operand).jsValue();
- callFrame->r(dst) = jsBoolean(JSValue::strictEqual(callFrame, src1, src2));
+ bool result = JSValue::strictEqual(callFrame, src1, src2);
+ CHECK_FOR_EXCEPTION();
+ callFrame->r(dst) = jsBoolean(result);
vPC += OPCODE_LENGTH(op_stricteq);
NEXT_INSTRUCTION();
@@ -1499,7 +1498,9 @@ JSValue Interpreter::privateExecute(ExecutionFlag flag, RegisterFile* registerFi
int dst = vPC[1].u.operand;
JSValue src1 = callFrame->r(vPC[2].u.operand).jsValue();
JSValue src2 = callFrame->r(vPC[3].u.operand).jsValue();
- callFrame->r(dst) = jsBoolean(!JSValue::strictEqual(callFrame, src1, src2));
+ bool result = !JSValue::strictEqual(callFrame, src1, src2);
+ CHECK_FOR_EXCEPTION();
+ callFrame->r(dst) = jsBoolean(result);
vPC += OPCODE_LENGTH(op_nstricteq);
NEXT_INSTRUCTION();
@@ -1951,7 +1952,7 @@ JSValue Interpreter::privateExecute(ExecutionFlag flag, RegisterFile* registerFi
JSValue baseVal = callFrame->r(base).jsValue();
- if (isInvalidParamForInstanceOf(callFrame, callFrame->codeBlock(), vPC, baseVal, exceptionValue))
+ if (isInvalidParamForInstanceOf(callFrame, codeBlock, vPC, baseVal, exceptionValue))
goto vm_throw;
bool result = asObject(baseVal)->hasInstance(callFrame, callFrame->r(value).jsValue(), callFrame->r(baseProto).jsValue());
@@ -2073,7 +2074,7 @@ JSValue Interpreter::privateExecute(ExecutionFlag flag, RegisterFile* registerFi
int base = vPC[3].u.operand;
JSValue baseVal = callFrame->r(base).jsValue();
- if (isInvalidParamForIn(callFrame, callFrame->codeBlock(), vPC, baseVal, exceptionValue))
+ if (isInvalidParamForIn(callFrame, codeBlock, vPC, baseVal, exceptionValue))
goto vm_throw;
JSObject* baseObj = asObject(baseVal);
@@ -2184,11 +2185,11 @@ JSValue Interpreter::privateExecute(ExecutionFlag flag, RegisterFile* registerFi
/* get_scoped_var dst(r) index(n) skip(n)
Loads the contents of the index-th local from the scope skip nodes from
- the top of the scope chain, and places it in register dst
+ the top of the scope chain, and places it in register dst.
*/
int dst = vPC[1].u.operand;
int index = vPC[2].u.operand;
- int skip = vPC[3].u.operand + callFrame->codeBlock()->needsFullScopeChain();
+ int skip = vPC[3].u.operand;
ScopeChainNode* scopeChain = callFrame->scopeChain();
ScopeChainIterator iter = scopeChain->begin();
@@ -2209,7 +2210,7 @@ JSValue Interpreter::privateExecute(ExecutionFlag flag, RegisterFile* registerFi
*/
int index = vPC[1].u.operand;
- int skip = vPC[2].u.operand + callFrame->codeBlock()->needsFullScopeChain();
+ int skip = vPC[2].u.operand;
int value = vPC[3].u.operand;
ScopeChainNode* scopeChain = callFrame->scopeChain();
@@ -2268,7 +2269,6 @@ JSValue Interpreter::privateExecute(ExecutionFlag flag, RegisterFile* registerFi
int base = vPC[2].u.operand;
int property = vPC[3].u.operand;
- CodeBlock* codeBlock = callFrame->codeBlock();
Identifier& ident = codeBlock->identifier(property);
JSValue baseValue = callFrame->r(base).jsValue();
PropertySlot slot(baseValue);
@@ -2301,7 +2301,7 @@ JSValue Interpreter::privateExecute(ExecutionFlag flag, RegisterFile* registerFi
int dst = vPC[1].u.operand;
int offset = vPC[5].u.operand;
- ASSERT(baseObject->get(callFrame, callFrame->codeBlock()->identifier(vPC[3].u.operand)) == baseObject->getDirectOffset(offset));
+ ASSERT(baseObject->get(callFrame, codeBlock->identifier(vPC[3].u.operand)) == baseObject->getDirectOffset(offset));
callFrame->r(dst) = JSValue(baseObject->getDirectOffset(offset));
vPC += OPCODE_LENGTH(op_get_by_id_self);
@@ -2309,7 +2309,7 @@ JSValue Interpreter::privateExecute(ExecutionFlag flag, RegisterFile* registerFi
}
}
- uncacheGetByID(callFrame->codeBlock(), vPC);
+ uncacheGetByID(codeBlock, vPC);
NEXT_INSTRUCTION();
}
DEFINE_OPCODE(op_get_by_id_proto) {
@@ -2335,8 +2335,8 @@ JSValue Interpreter::privateExecute(ExecutionFlag flag, RegisterFile* registerFi
int dst = vPC[1].u.operand;
int offset = vPC[6].u.operand;
- ASSERT(protoObject->get(callFrame, callFrame->codeBlock()->identifier(vPC[3].u.operand)) == protoObject->getDirectOffset(offset));
- ASSERT(baseValue.get(callFrame, callFrame->codeBlock()->identifier(vPC[3].u.operand)) == protoObject->getDirectOffset(offset));
+ ASSERT(protoObject->get(callFrame, codeBlock->identifier(vPC[3].u.operand)) == protoObject->getDirectOffset(offset));
+ ASSERT(baseValue.get(callFrame, codeBlock->identifier(vPC[3].u.operand)) == protoObject->getDirectOffset(offset));
callFrame->r(dst) = JSValue(protoObject->getDirectOffset(offset));
vPC += OPCODE_LENGTH(op_get_by_id_proto);
@@ -2345,7 +2345,7 @@ JSValue Interpreter::privateExecute(ExecutionFlag flag, RegisterFile* registerFi
}
}
- uncacheGetByID(callFrame->codeBlock(), vPC);
+ uncacheGetByID(codeBlock, vPC);
NEXT_INSTRUCTION();
}
#if HAVE(COMPUTED_GOTO)
@@ -2387,7 +2387,7 @@ JSValue Interpreter::privateExecute(ExecutionFlag flag, RegisterFile* registerFi
}
}
}
- uncacheGetByID(callFrame->codeBlock(), vPC);
+ uncacheGetByID(codeBlock, vPC);
NEXT_INSTRUCTION();
}
#if HAVE(COMPUTED_GOTO)
@@ -2418,7 +2418,7 @@ JSValue Interpreter::privateExecute(ExecutionFlag flag, RegisterFile* registerFi
if (LIKELY(protoObject->structure() == prototypeStructure)) {
int dst = vPC[1].u.operand;
int property = vPC[3].u.operand;
- Identifier& ident = callFrame->codeBlock()->identifier(property);
+ Identifier& ident = codeBlock->identifier(property);
PropertySlot::GetValueFunc getter = vPC[6].u.getterFunc;
JSValue result = getter(callFrame, protoObject, ident);
@@ -2429,7 +2429,7 @@ JSValue Interpreter::privateExecute(ExecutionFlag flag, RegisterFile* registerFi
}
}
}
- uncacheGetByID(callFrame->codeBlock(), vPC);
+ uncacheGetByID(codeBlock, vPC);
NEXT_INSTRUCTION();
}
#if HAVE(COMPUTED_GOTO)
@@ -2506,8 +2506,8 @@ JSValue Interpreter::privateExecute(ExecutionFlag flag, RegisterFile* registerFi
int dst = vPC[1].u.operand;
int offset = vPC[7].u.operand;
- ASSERT(baseObject->get(callFrame, callFrame->codeBlock()->identifier(vPC[3].u.operand)) == baseObject->getDirectOffset(offset));
- ASSERT(baseValue.get(callFrame, callFrame->codeBlock()->identifier(vPC[3].u.operand)) == baseObject->getDirectOffset(offset));
+ ASSERT(baseObject->get(callFrame, codeBlock->identifier(vPC[3].u.operand)) == baseObject->getDirectOffset(offset));
+ ASSERT(baseValue.get(callFrame, codeBlock->identifier(vPC[3].u.operand)) == baseObject->getDirectOffset(offset));
callFrame->r(dst) = JSValue(baseObject->getDirectOffset(offset));
vPC += OPCODE_LENGTH(op_get_by_id_chain);
@@ -2520,7 +2520,7 @@ JSValue Interpreter::privateExecute(ExecutionFlag flag, RegisterFile* registerFi
}
}
- uncacheGetByID(callFrame->codeBlock(), vPC);
+ uncacheGetByID(codeBlock, vPC);
NEXT_INSTRUCTION();
}
#if HAVE(COMPUTED_GOTO)
@@ -2560,7 +2560,7 @@ JSValue Interpreter::privateExecute(ExecutionFlag flag, RegisterFile* registerFi
NEXT_INSTRUCTION();
}
}
- uncacheGetByID(callFrame->codeBlock(), vPC);
+ uncacheGetByID(codeBlock, vPC);
NEXT_INSTRUCTION();
}
#if HAVE(COMPUTED_GOTO)
@@ -2587,7 +2587,7 @@ JSValue Interpreter::privateExecute(ExecutionFlag flag, RegisterFile* registerFi
ASSERT(baseCell->isObject());
int dst = vPC[1].u.operand;
int property = vPC[3].u.operand;
- Identifier& ident = callFrame->codeBlock()->identifier(property);
+ Identifier& ident = codeBlock->identifier(property);
PropertySlot::GetValueFunc getter = vPC[5].u.getterFunc;
JSValue result = getter(callFrame, baseValue, ident);
@@ -2597,7 +2597,7 @@ JSValue Interpreter::privateExecute(ExecutionFlag flag, RegisterFile* registerFi
NEXT_INSTRUCTION();
}
}
- uncacheGetByID(callFrame->codeBlock(), vPC);
+ uncacheGetByID(codeBlock, vPC);
NEXT_INSTRUCTION();
}
#if HAVE(COMPUTED_GOTO)
@@ -2613,7 +2613,7 @@ skip_id_custom_self:
int base = vPC[2].u.operand;
int property = vPC[3].u.operand;
- Identifier& ident = callFrame->codeBlock()->identifier(property);
+ Identifier& ident = codeBlock->identifier(property);
JSValue baseValue = callFrame->r(base).jsValue();
PropertySlot slot(baseValue);
JSValue result = baseValue.get(callFrame, ident, slot);
@@ -2672,7 +2672,7 @@ skip_id_custom_self:
}
}
}
- uncacheGetByID(callFrame->codeBlock(), vPC);
+ uncacheGetByID(codeBlock, vPC);
NEXT_INSTRUCTION();
}
#if HAVE(COMPUTED_GOTO)
@@ -2709,7 +2709,7 @@ skip_id_custom_self:
if (++it == end) {
int dst = vPC[1].u.operand;
int property = vPC[3].u.operand;
- Identifier& ident = callFrame->codeBlock()->identifier(property);
+ Identifier& ident = codeBlock->identifier(property);
PropertySlot::GetValueFunc getter = vPC[7].u.getterFunc;
JSValue result = getter(callFrame, baseObject, ident);
@@ -2724,7 +2724,7 @@ skip_id_custom_self:
}
}
}
- uncacheGetByID(callFrame->codeBlock(), vPC);
+ uncacheGetByID(codeBlock, vPC);
NEXT_INSTRUCTION();
}
#if HAVE(COMPUTED_GOTO)
@@ -2747,7 +2747,7 @@ skip_id_custom_self:
NEXT_INSTRUCTION();
}
- uncacheGetByID(callFrame->codeBlock(), vPC);
+ uncacheGetByID(codeBlock, vPC);
NEXT_INSTRUCTION();
}
DEFINE_OPCODE(op_get_string_length) {
@@ -2767,7 +2767,7 @@ skip_id_custom_self:
NEXT_INSTRUCTION();
}
- uncacheGetByID(callFrame->codeBlock(), vPC);
+ uncacheGetByID(codeBlock, vPC);
NEXT_INSTRUCTION();
}
DEFINE_OPCODE(op_put_by_id) {
@@ -2784,7 +2784,6 @@ skip_id_custom_self:
int property = vPC[2].u.operand;
int value = vPC[3].u.operand;
- CodeBlock* codeBlock = callFrame->codeBlock();
JSValue baseValue = callFrame->r(base).jsValue();
Identifier& ident = codeBlock->identifier(property);
PutPropertySlot slot;
@@ -2824,7 +2823,7 @@ skip_id_custom_self:
JSValue proto = baseObject->structure()->prototypeForLookup(callFrame);
while (!proto.isNull()) {
if (UNLIKELY(asObject(proto)->structure() != (*it).get())) {
- uncachePutByID(callFrame->codeBlock(), vPC);
+ uncachePutByID(codeBlock, vPC);
NEXT_INSTRUCTION();
}
++it;
@@ -2835,7 +2834,7 @@ skip_id_custom_self:
int value = vPC[3].u.operand;
unsigned offset = vPC[7].u.operand;
- ASSERT(baseObject->offsetForLocation(baseObject->getDirectLocation(callFrame->codeBlock()->identifier(vPC[2].u.operand))) == offset);
+ ASSERT(baseObject->offsetForLocation(baseObject->getDirectLocation(codeBlock->identifier(vPC[2].u.operand))) == offset);
baseObject->putDirectOffset(offset, callFrame->r(value).jsValue());
vPC += OPCODE_LENGTH(op_put_by_id_transition);
@@ -2843,7 +2842,7 @@ skip_id_custom_self:
}
}
- uncachePutByID(callFrame->codeBlock(), vPC);
+ uncachePutByID(codeBlock, vPC);
NEXT_INSTRUCTION();
}
DEFINE_OPCODE(op_put_by_id_replace) {
@@ -2870,7 +2869,7 @@ skip_id_custom_self:
int value = vPC[3].u.operand;
unsigned offset = vPC[5].u.operand;
- ASSERT(baseObject->offsetForLocation(baseObject->getDirectLocation(callFrame->codeBlock()->identifier(vPC[2].u.operand))) == offset);
+ ASSERT(baseObject->offsetForLocation(baseObject->getDirectLocation(codeBlock->identifier(vPC[2].u.operand))) == offset);
baseObject->putDirectOffset(offset, callFrame->r(value).jsValue());
vPC += OPCODE_LENGTH(op_put_by_id_replace);
@@ -2878,7 +2877,7 @@ skip_id_custom_self:
}
}
- uncachePutByID(callFrame->codeBlock(), vPC);
+ uncachePutByID(codeBlock, vPC);
NEXT_INSTRUCTION();
}
DEFINE_OPCODE(op_put_by_id_generic) {
@@ -2895,7 +2894,7 @@ skip_id_custom_self:
int value = vPC[3].u.operand;
JSValue baseValue = callFrame->r(base).jsValue();
- Identifier& ident = callFrame->codeBlock()->identifier(property);
+ Identifier& ident = codeBlock->identifier(property);
PutPropertySlot slot;
baseValue.put(callFrame, ident, callFrame->r(value).jsValue(), slot);
CHECK_FOR_EXCEPTION();
@@ -2916,7 +2915,7 @@ skip_id_custom_self:
int property = vPC[3].u.operand;
JSObject* baseObj = callFrame->r(base).jsValue().toObject(callFrame);
- Identifier& ident = callFrame->codeBlock()->identifier(property);
+ Identifier& ident = codeBlock->identifier(property);
JSValue result = jsBoolean(baseObj->deleteProperty(callFrame, ident));
CHECK_FOR_EXCEPTION();
callFrame->r(dst) = result;
@@ -3409,12 +3408,12 @@ skip_id_custom_self:
int defaultOffset = vPC[2].u.operand;
JSValue scrutinee = callFrame->r(vPC[3].u.operand).jsValue();
if (scrutinee.isInt32())
- vPC += callFrame->codeBlock()->immediateSwitchJumpTable(tableIndex).offsetForValue(scrutinee.asInt32(), defaultOffset);
+ vPC += codeBlock->immediateSwitchJumpTable(tableIndex).offsetForValue(scrutinee.asInt32(), defaultOffset);
else {
double value;
int32_t intValue;
if (scrutinee.getNumber(value) && ((intValue = static_cast<int32_t>(value)) == value))
- vPC += callFrame->codeBlock()->immediateSwitchJumpTable(tableIndex).offsetForValue(intValue, defaultOffset);
+ vPC += codeBlock->immediateSwitchJumpTable(tableIndex).offsetForValue(intValue, defaultOffset);
else
vPC += defaultOffset;
}
@@ -3439,7 +3438,7 @@ skip_id_custom_self:
if (value->length() != 1)
vPC += defaultOffset;
else
- vPC += callFrame->codeBlock()->characterSwitchJumpTable(tableIndex).offsetForValue(value->characters()[0], defaultOffset);
+ vPC += codeBlock->characterSwitchJumpTable(tableIndex).offsetForValue(value->characters()[0], defaultOffset);
}
NEXT_INSTRUCTION();
}
@@ -3458,7 +3457,7 @@ skip_id_custom_self:
if (!scrutinee.isString())
vPC += defaultOffset;
else
- vPC += callFrame->codeBlock()->stringSwitchJumpTable(tableIndex).offsetForValue(asString(scrutinee)->value(callFrame).rep(), defaultOffset);
+ vPC += codeBlock->stringSwitchJumpTable(tableIndex).offsetForValue(asString(scrutinee)->value(callFrame).rep(), defaultOffset);
NEXT_INSTRUCTION();
}
DEFINE_OPCODE(op_new_func) {
@@ -3472,7 +3471,7 @@ skip_id_custom_self:
int dst = vPC[1].u.operand;
int func = vPC[2].u.operand;
- callFrame->r(dst) = JSValue(callFrame->codeBlock()->functionDecl(func)->make(callFrame, callFrame->scopeChain()));
+ callFrame->r(dst) = JSValue(codeBlock->functionDecl(func)->make(callFrame, callFrame->scopeChain()));
vPC += OPCODE_LENGTH(op_new_func);
NEXT_INSTRUCTION();
@@ -3488,7 +3487,7 @@ skip_id_custom_self:
int dst = vPC[1].u.operand;
int funcIndex = vPC[2].u.operand;
- FunctionExecutable* function = callFrame->codeBlock()->functionExpr(funcIndex);
+ FunctionExecutable* function = codeBlock->functionExpr(funcIndex);
JSFunction* func = function->make(callFrame, callFrame->scopeChain());
/*
@@ -3509,7 +3508,7 @@ skip_id_custom_self:
NEXT_INSTRUCTION();
}
DEFINE_OPCODE(op_call_eval) {
- /* call_eval dst(r) func(r) argCount(n) registerOffset(n)
+ /* call_eval func(r) argCount(n) registerOffset(n)
Call a function named "eval" with no explicit "this" value
(which may therefore be the eval operator). If register
@@ -3520,10 +3519,9 @@ skip_id_custom_self:
opcode). Otherwise, act exactly as the "call" opcode would.
*/
- int dst = vPC[1].u.operand;
- int func = vPC[2].u.operand;
- int argCount = vPC[3].u.operand;
- int registerOffset = vPC[4].u.operand;
+ int func = vPC[1].u.operand;
+ int argCount = vPC[2].u.operand;
+ int registerOffset = vPC[3].u.operand;
JSValue funcVal = callFrame->r(func).jsValue();
@@ -3536,7 +3534,7 @@ skip_id_custom_self:
JSValue result = callEval(callFrame, registerFile, argv, argCount, registerOffset, exceptionValue);
if (exceptionValue)
goto vm_throw;
- callFrame->r(dst) = result;
+ functionReturnValue = result;
vPC += OPCODE_LENGTH(op_call_eval);
NEXT_INSTRUCTION();
@@ -3547,7 +3545,7 @@ skip_id_custom_self:
// fall through to op_call
}
DEFINE_OPCODE(op_call) {
- /* call dst(r) func(r) argCount(n) registerOffset(n)
+ /* call func(r) argCount(n) registerOffset(n)
Perform a function call.
@@ -3557,10 +3555,9 @@ skip_id_custom_self:
dst is where op_ret should store its result.
*/
- int dst = vPC[1].u.operand;
- int func = vPC[2].u.operand;
- int argCount = vPC[3].u.operand;
- int registerOffset = vPC[4].u.operand;
+ int func = vPC[1].u.operand;
+ int argCount = vPC[2].u.operand;
+ int registerOffset = vPC[3].u.operand;
JSValue v = callFrame->r(func).jsValue();
@@ -3580,7 +3577,9 @@ skip_id_custom_self:
goto vm_throw;
}
- callFrame->init(newCodeBlock, vPC + 5, callDataScopeChain, previousCallFrame, dst, argCount, asFunction(v));
+ callFrame->init(newCodeBlock, vPC + OPCODE_LENGTH(op_call), callDataScopeChain, previousCallFrame, 0, argCount, asFunction(v));
+ codeBlock = newCodeBlock;
+ ASSERT(codeBlock == callFrame->codeBlock());
vPC = newCodeBlock->instructions().begin();
#if ENABLE(OPCODE_STATS)
@@ -3593,7 +3592,7 @@ skip_id_custom_self:
if (callType == CallTypeHost) {
ScopeChainNode* scopeChain = callFrame->scopeChain();
CallFrame* newCallFrame = CallFrame::create(callFrame->registers() + registerOffset);
- newCallFrame->init(0, vPC + 5, scopeChain, callFrame, dst, argCount, 0);
+ newCallFrame->init(0, vPC + OPCODE_LENGTH(op_call), scopeChain, callFrame, 0, argCount, 0);
Register* thisRegister = newCallFrame->registers() - RegisterFile::CallFrameHeaderSize - argCount;
ArgList args(thisRegister + 1, argCount - 1);
@@ -3610,7 +3609,7 @@ skip_id_custom_self:
}
CHECK_FOR_EXCEPTION();
- callFrame->r(dst) = returnValue;
+ functionReturnValue = returnValue;
vPC += OPCODE_LENGTH(op_call);
NEXT_INSTRUCTION();
@@ -3618,7 +3617,7 @@ skip_id_custom_self:
ASSERT(callType == CallTypeNone);
- exceptionValue = createNotAFunctionError(callFrame, v, vPC - callFrame->codeBlock()->instructions().begin(), callFrame->codeBlock());
+ exceptionValue = createNotAFunctionError(callFrame, v, vPC - codeBlock->instructions().begin(), codeBlock);
goto vm_throw;
}
DEFINE_OPCODE(op_load_varargs) {
@@ -3649,7 +3648,7 @@ skip_id_custom_self:
argStore[i] = callFrame->registers()[i - RegisterFile::CallFrameHeaderSize - expectedParams - argCount - 1];
} else if (!arguments.isUndefinedOrNull()) {
if (!arguments.isObject()) {
- exceptionValue = createInvalidParamError(callFrame, "Function.prototype.apply", arguments, vPC - callFrame->codeBlock()->instructions().begin(), callFrame->codeBlock());
+ exceptionValue = createInvalidParamError(callFrame, "Function.prototype.apply", arguments, vPC - codeBlock->instructions().begin(), codeBlock);
goto vm_throw;
}
if (asObject(arguments)->classInfo() == &Arguments::info) {
@@ -3688,7 +3687,7 @@ skip_id_custom_self:
}
} else {
if (!arguments.isObject()) {
- exceptionValue = createInvalidParamError(callFrame, "Function.prototype.apply", arguments, vPC - callFrame->codeBlock()->instructions().begin(), callFrame->codeBlock());
+ exceptionValue = createInvalidParamError(callFrame, "Function.prototype.apply", arguments, vPC - codeBlock->instructions().begin(), codeBlock);
goto vm_throw;
}
}
@@ -3699,7 +3698,7 @@ skip_id_custom_self:
NEXT_INSTRUCTION();
}
DEFINE_OPCODE(op_call_varargs) {
- /* call_varargs dst(r) func(r) argCountReg(r) baseRegisterOffset(n)
+ /* call_varargs func(r) argCountReg(r) baseRegisterOffset(n)
Perform a function call with a dynamic set of arguments.
@@ -3710,10 +3709,9 @@ skip_id_custom_self:
dst is where op_ret should store its result.
*/
- int dst = vPC[1].u.operand;
- int func = vPC[2].u.operand;
- int argCountReg = vPC[3].u.operand;
- int registerOffset = vPC[4].u.operand;
+ int func = vPC[1].u.operand;
+ int argCountReg = vPC[2].u.operand;
+ int registerOffset = vPC[3].u.operand;
JSValue v = callFrame->r(func).jsValue();
int argCount = callFrame->r(argCountReg).i();
@@ -3734,7 +3732,9 @@ skip_id_custom_self:
goto vm_throw;
}
- callFrame->init(newCodeBlock, vPC + 5, callDataScopeChain, previousCallFrame, dst, argCount, asFunction(v));
+ callFrame->init(newCodeBlock, vPC + OPCODE_LENGTH(op_call_varargs), callDataScopeChain, previousCallFrame, 0, argCount, asFunction(v));
+ codeBlock = newCodeBlock;
+ ASSERT(codeBlock == callFrame->codeBlock());
vPC = newCodeBlock->instructions().begin();
#if ENABLE(OPCODE_STATS)
@@ -3747,7 +3747,7 @@ skip_id_custom_self:
if (callType == CallTypeHost) {
ScopeChainNode* scopeChain = callFrame->scopeChain();
CallFrame* newCallFrame = CallFrame::create(callFrame->registers() + registerOffset);
- newCallFrame->init(0, vPC + 5, scopeChain, callFrame, dst, argCount, 0);
+ newCallFrame->init(0, vPC + OPCODE_LENGTH(op_call_varargs), scopeChain, callFrame, 0, argCount, 0);
Register* thisRegister = newCallFrame->registers() - RegisterFile::CallFrameHeaderSize - argCount;
ArgList args(thisRegister + 1, argCount - 1);
@@ -3764,7 +3764,7 @@ skip_id_custom_self:
}
CHECK_FOR_EXCEPTION();
- callFrame->r(dst) = returnValue;
+ functionReturnValue = returnValue;
vPC += OPCODE_LENGTH(op_call_varargs);
NEXT_INSTRUCTION();
@@ -3772,47 +3772,50 @@ skip_id_custom_self:
ASSERT(callType == CallTypeNone);
- exceptionValue = createNotAFunctionError(callFrame, v, vPC - callFrame->codeBlock()->instructions().begin(), callFrame->codeBlock());
+ exceptionValue = createNotAFunctionError(callFrame, v, vPC - codeBlock->instructions().begin(), codeBlock);
goto vm_throw;
}
DEFINE_OPCODE(op_tear_off_activation) {
- /* tear_off_activation activation(r)
+ /* tear_off_activation activation(r) arguments(r)
- Copy all locals and parameters to new memory allocated on
- the heap, and make the passed activation use this memory
- in the future when looking up entries in the symbol table.
- If there is an 'arguments' object, then it will also use
- this memory for storing the named parameters, but not any
- extra arguments.
+ Copy locals and named parameters from the register file to the heap.
+ Point the bindings in 'activation' and 'arguments' to this new backing
+ store. (Note that 'arguments' may not have been created. If created,
+ 'arguments' already holds a copy of any extra / unnamed parameters.)
- This opcode should only be used immediately before op_ret.
+ This opcode appears before op_ret in functions that require full scope chains.
*/
- int src = vPC[1].u.operand;
- ASSERT(callFrame->codeBlock()->needsFullScopeChain());
+ int src1 = vPC[1].u.operand;
+ int src2 = vPC[2].u.operand;
+ ASSERT(codeBlock->needsFullScopeChain());
+
+ JSActivation* activation = asActivation(callFrame->r(src1).jsValue());
+ activation->copyRegisters();
- asActivation(callFrame->r(src).jsValue())->copyRegisters(callFrame->optionalCalleeArguments());
+ if (JSValue arguments = callFrame->r(unmodifiedArgumentsRegister(src2)).jsValue())
+ asArguments(arguments)->setActivation(activation);
vPC += OPCODE_LENGTH(op_tear_off_activation);
NEXT_INSTRUCTION();
}
DEFINE_OPCODE(op_tear_off_arguments) {
- /* tear_off_arguments
+ /* tear_off_arguments arguments(r)
- Copy all arguments to new memory allocated on the heap,
- and make the 'arguments' object use this memory in the
- future when looking up named parameters, but not any
- extra arguments. If an activation object exists for the
- current function context, then the tear_off_activation
- opcode should be used instead.
+ Copy named parameters from the register file to the heap. Point the
+ bindings in 'arguments' to this new backing store. (Note that
+ 'arguments' may not have been created. If created, 'arguments' already
+ holds a copy of any extra / unnamed parameters.)
- This opcode should only be used immediately before op_ret.
+ This opcode appears before op_ret in functions that don't require full
+ scope chains, but do use 'arguments'.
*/
- ASSERT(callFrame->codeBlock()->usesArguments() && !callFrame->codeBlock()->needsFullScopeChain());
+ int src1 = vPC[1].u.operand;
+ ASSERT(!codeBlock->needsFullScopeChain() && codeBlock->ownerExecutable()->usesArguments());
- if (callFrame->optionalCalleeArguments())
- callFrame->optionalCalleeArguments()->copyRegisters();
+ if (JSValue arguments = callFrame->r(unmodifiedArgumentsRegister(src1)).jsValue())
+ asArguments(arguments)->copyRegisters();
vPC += OPCODE_LENGTH(op_tear_off_arguments);
NEXT_INSTRUCTION();
@@ -3821,6 +3824,47 @@ skip_id_custom_self:
/* ret result(r)
Return register result as the return value of the current
+ function call, writing it into functionReturnValue.
+ In addition, unwind one call frame and restore the scope
+ chain, code block instruction pointer and register base
+ to those of the calling function.
+ */
+
+ int result = vPC[1].u.operand;
+
+ if (callFrame->codeBlock()->needsFullScopeChain())
+ callFrame->scopeChain()->deref();
+
+ JSValue returnValue = callFrame->r(result).jsValue();
+
+ vPC = callFrame->returnPC();
+ callFrame = callFrame->callerFrame();
+
+ if (callFrame->hasHostCallFrameFlag())
+ return returnValue;
+
+ functionReturnValue = returnValue;
+ codeBlock = callFrame->codeBlock();
+ ASSERT(codeBlock == callFrame->codeBlock());
+
+ NEXT_INSTRUCTION();
+ }
+ DEFINE_OPCODE(op_call_put_result) {
+ /* op_call_put_result result(r)
+
+ Move call result from functionReturnValue to caller's
+ expected return value register.
+ */
+
+ callFrame->r(vPC[1].u.operand) = functionReturnValue;
+
+ vPC += OPCODE_LENGTH(op_call_put_result);
+ NEXT_INSTRUCTION();
+ }
+ DEFINE_OPCODE(op_ret_object_or_this) {
+ /* ret result(r)
+
+ Return register result as the return value of the current
function call, writing it into the caller's expected return
value register. In addition, unwind one call frame and
restore the scope chain, code block instruction pointer and
@@ -3829,36 +3873,36 @@ skip_id_custom_self:
int result = vPC[1].u.operand;
- if (callFrame->codeBlock()->needsFullScopeChain())
+ if (codeBlock->needsFullScopeChain())
callFrame->scopeChain()->deref();
JSValue returnValue = callFrame->r(result).jsValue();
+ if (UNLIKELY(!returnValue.isObject()))
+ returnValue = callFrame->r(vPC[2].u.operand).jsValue();
+
vPC = callFrame->returnPC();
- int dst = callFrame->returnValueRegister();
callFrame = callFrame->callerFrame();
if (callFrame->hasHostCallFrameFlag())
return returnValue;
- callFrame->r(dst) = returnValue;
+ functionReturnValue = returnValue;
+ codeBlock = callFrame->codeBlock();
+ ASSERT(codeBlock == callFrame->codeBlock());
NEXT_INSTRUCTION();
}
DEFINE_OPCODE(op_enter) {
/* enter
- Initializes local variables to undefined and fills constant
- registers with their values. If the code block requires an
- activation, enter_with_activation should be used instead.
+ Initializes local variables to undefined. If the code block requires
+ an activation, enter_with_activation is used instead.
- This opcode should only be used at the beginning of a code
- block.
+ This opcode appears only at the beginning of a code block.
*/
size_t i = 0;
- CodeBlock* codeBlock = callFrame->codeBlock();
-
for (size_t count = codeBlock->m_numVars; i < count; ++i)
callFrame->r(i) = jsUndefined();
@@ -3868,19 +3912,13 @@ skip_id_custom_self:
DEFINE_OPCODE(op_enter_with_activation) {
/* enter_with_activation dst(r)
- Initializes local variables to undefined, fills constant
- registers with their values, creates an activation object,
- and places the new activation both in dst and at the top
- of the scope chain. If the code block does not require an
- activation, enter should be used instead.
+ Initializes local variables to undefined, creates an activation object,
+ places it in dst, and pushes it onto the scope chain.
- This opcode should only be used at the beginning of a code
- block.
+ This opcode appears only at the beginning of a code block.
*/
size_t i = 0;
- CodeBlock* codeBlock = callFrame->codeBlock();
-
for (size_t count = codeBlock->m_numVars; i < count; ++i)
callFrame->r(i) = jsUndefined();
@@ -3913,37 +3951,39 @@ skip_id_custom_self:
NEXT_INSTRUCTION();
}
DEFINE_OPCODE(op_init_arguments) {
- /* create_arguments
+ /* create_arguments dst(r)
- Initialises the arguments object reference to null to ensure
- we can correctly detect that we need to create it later (or
- avoid creating it altogether).
+ Initialises 'arguments' to JSValue().
- This opcode should only be used at the beginning of a code
- block.
+ This opcode appears only at the beginning of a code block.
*/
- callFrame->r(RegisterFile::ArgumentsRegister) = JSValue();
+ int dst = vPC[1].u.operand;
+
+ callFrame->r(dst) = JSValue();
+ callFrame->r(unmodifiedArgumentsRegister(dst)) = JSValue();
vPC += OPCODE_LENGTH(op_init_arguments);
NEXT_INSTRUCTION();
}
DEFINE_OPCODE(op_create_arguments) {
- /* create_arguments
+ /* create_arguments dst(r)
Creates the 'arguments' object and places it in both the
'arguments' call frame slot and the local 'arguments'
register, if it has not already been initialised.
*/
- if (!callFrame->r(RegisterFile::ArgumentsRegister).jsValue()) {
- Arguments* arguments = new (globalData) Arguments(callFrame);
- callFrame->setCalleeArguments(arguments);
- callFrame->r(RegisterFile::ArgumentsRegister) = JSValue(arguments);
- }
+ int dst = vPC[1].u.operand;
+
+ if (!callFrame->r(dst).jsValue()) {
+ Arguments* arguments = new (globalData) Arguments(callFrame);
+ callFrame->r(dst) = JSValue(arguments);
+ callFrame->r(unmodifiedArgumentsRegister(dst)) = JSValue(arguments);
+ }
vPC += OPCODE_LENGTH(op_create_arguments);
NEXT_INSTRUCTION();
}
DEFINE_OPCODE(op_construct) {
- /* construct dst(r) func(r) argCount(n) registerOffset(n) proto(r) thisRegister(r)
+ /* construct func(r) argCount(n) registerOffset(n) proto(r) thisRegister(r)
Invoke register "func" as a constructor. For JS
functions, the calling convention is exactly as for the
@@ -3957,12 +3997,11 @@ skip_id_custom_self:
caching of this lookup.
*/
- int dst = vPC[1].u.operand;
- int func = vPC[2].u.operand;
- int argCount = vPC[3].u.operand;
- int registerOffset = vPC[4].u.operand;
- int proto = vPC[5].u.operand;
- int thisRegister = vPC[6].u.operand;
+ int func = vPC[1].u.operand;
+ int argCount = vPC[2].u.operand;
+ int registerOffset = vPC[3].u.operand;
+ int proto = vPC[4].u.operand;
+ int thisRegister = vPC[5].u.operand;
JSValue v = callFrame->r(func).jsValue();
@@ -3992,7 +4031,8 @@ skip_id_custom_self:
goto vm_throw;
}
- callFrame->init(newCodeBlock, vPC + 7, callDataScopeChain, previousCallFrame, dst, argCount, asFunction(v));
+ callFrame->init(newCodeBlock, vPC + OPCODE_LENGTH(op_construct), callDataScopeChain, previousCallFrame, 0, argCount, asFunction(v));
+ codeBlock = newCodeBlock;
vPC = newCodeBlock->instructions().begin();
#if ENABLE(OPCODE_STATS)
@@ -4007,7 +4047,7 @@ skip_id_custom_self:
ScopeChainNode* scopeChain = callFrame->scopeChain();
CallFrame* newCallFrame = CallFrame::create(callFrame->registers() + registerOffset);
- newCallFrame->init(0, vPC + 7, scopeChain, callFrame, dst, argCount, 0);
+ newCallFrame->init(0, vPC + OPCODE_LENGTH(op_construct), scopeChain, callFrame, 0, argCount, 0);
JSValue returnValue;
{
@@ -4015,7 +4055,7 @@ skip_id_custom_self:
returnValue = constructData.native.function(newCallFrame, asObject(v), args);
}
CHECK_FOR_EXCEPTION();
- callFrame->r(dst) = JSValue(returnValue);
+ functionReturnValue = JSValue(returnValue);
vPC += OPCODE_LENGTH(op_construct);
NEXT_INSTRUCTION();
@@ -4023,28 +4063,9 @@ skip_id_custom_self:
ASSERT(constructType == ConstructTypeNone);
- exceptionValue = createNotAConstructorError(callFrame, v, vPC - callFrame->codeBlock()->instructions().begin(), callFrame->codeBlock());
+ exceptionValue = createNotAConstructorError(callFrame, v, vPC - codeBlock->instructions().begin(), codeBlock);
goto vm_throw;
}
- DEFINE_OPCODE(op_construct_verify) {
- /* construct_verify dst(r) override(r)
-
- Verifies that register dst holds an object. If not, moves
- the object in register override to register dst.
- */
-
- int dst = vPC[1].u.operand;
- if (LIKELY(callFrame->r(dst).jsValue().isObject())) {
- vPC += OPCODE_LENGTH(op_construct_verify);
- NEXT_INSTRUCTION();
- }
-
- int override = vPC[2].u.operand;
- callFrame->r(dst) = callFrame->r(override);
-
- vPC += OPCODE_LENGTH(op_construct_verify);
- NEXT_INSTRUCTION();
- }
DEFINE_OPCODE(op_strcat) {
int dst = vPC[1].u.operand;
int src = vPC[2].u.operand;
@@ -4143,6 +4164,7 @@ skip_id_custom_self:
JSPropertyNameIterator* it = callFrame->r(iter).propertyNameIterator();
while (callFrame->r(i).i() != callFrame->r(size).i()) {
JSValue key = it->get(callFrame, asObject(callFrame->r(base).jsValue()), callFrame->r(i).i());
+ CHECK_FOR_EXCEPTION();
callFrame->r(i) = Register::withInt(callFrame->r(i).i() + 1);
if (key) {
CHECK_FOR_TIMEOUT();
@@ -4222,13 +4244,14 @@ skip_id_custom_self:
int ex = vPC[1].u.operand;
exceptionValue = callFrame->r(ex).jsValue();
- handler = throwException(callFrame, exceptionValue, vPC - callFrame->codeBlock()->instructions().begin(), true);
+ handler = throwException(callFrame, exceptionValue, vPC - codeBlock->instructions().begin(), true);
if (!handler) {
*exception = exceptionValue;
return jsNull();
}
- vPC = callFrame->codeBlock()->instructions().begin() + handler->target;
+ codeBlock = callFrame->codeBlock();
+ vPC = codeBlock->instructions().begin() + handler->target;
NEXT_INSTRUCTION();
}
DEFINE_OPCODE(op_new_error) {
@@ -4243,7 +4266,6 @@ skip_id_custom_self:
int type = vPC[2].u.operand;
int message = vPC[3].u.operand;
- CodeBlock* codeBlock = callFrame->codeBlock();
callFrame->r(dst) = JSValue(Error::create(callFrame, (ErrorType)type, callFrame->r(message).jsValue().toString(callFrame), codeBlock->lineNumberForBytecodeOffset(callFrame, vPC - codeBlock->instructions().begin()), codeBlock->ownerExecutable()->sourceID(), codeBlock->ownerExecutable()->sourceURL()));
vPC += OPCODE_LENGTH(op_new_error);
@@ -4256,7 +4278,7 @@ skip_id_custom_self:
program. Return control to the calling native code.
*/
- if (callFrame->codeBlock()->needsFullScopeChain()) {
+ if (codeBlock->needsFullScopeChain()) {
ScopeChainNode* scopeChain = callFrame->scopeChain();
ASSERT(scopeChain->refCount > 1);
scopeChain->deref();
@@ -4281,7 +4303,7 @@ skip_id_custom_self:
ASSERT(callFrame->r(base).jsValue().isObject());
JSObject* baseObj = asObject(callFrame->r(base).jsValue());
- Identifier& ident = callFrame->codeBlock()->identifier(property);
+ Identifier& ident = codeBlock->identifier(property);
ASSERT(callFrame->r(function).jsValue().isObject());
baseObj->defineGetter(callFrame, ident, asObject(callFrame->r(function).jsValue()));
@@ -4305,7 +4327,7 @@ skip_id_custom_self:
ASSERT(callFrame->r(base).jsValue().isObject());
JSObject* baseObj = asObject(callFrame->r(base).jsValue());
- Identifier& ident = callFrame->codeBlock()->identifier(property);
+ Identifier& ident = codeBlock->identifier(property);
ASSERT(callFrame->r(function).jsValue().isObject());
baseObj->defineSetter(callFrame, ident, asObject(callFrame->r(function).jsValue()), 0);
@@ -4390,24 +4412,25 @@ skip_id_custom_self:
// cannot fathom if we don't assign to the exceptionValue before branching)
exceptionValue = createInterruptedExecutionException(globalData);
}
- handler = throwException(callFrame, exceptionValue, vPC - callFrame->codeBlock()->instructions().begin(), false);
+ handler = throwException(callFrame, exceptionValue, vPC - codeBlock->instructions().begin(), false);
if (!handler) {
*exception = exceptionValue;
return jsNull();
}
- vPC = callFrame->codeBlock()->instructions().begin() + handler->target;
+ codeBlock = callFrame->codeBlock();
+ vPC = codeBlock->instructions().begin() + handler->target;
NEXT_INSTRUCTION();
}
}
#if !HAVE(COMPUTED_GOTO)
} // iterator loop ends
#endif
-#endif // USE(INTERPRETER)
#undef NEXT_INSTRUCTION
#undef DEFINE_OPCODE
#undef CHECK_FOR_EXCEPTION
#undef CHECK_FOR_TIMEOUT
+#endif // !ENABLE(JIT)
}
JSValue Interpreter::retrieveArguments(CallFrame* callFrame, JSFunction* function) const
@@ -4419,27 +4442,21 @@ JSValue Interpreter::retrieveArguments(CallFrame* callFrame, JSFunction* functio
CodeBlock* codeBlock = functionCallFrame->codeBlock();
if (codeBlock->usesArguments()) {
ASSERT(codeBlock->codeType() == FunctionCode);
- SymbolTable& symbolTable = *codeBlock->symbolTable();
- int argumentsIndex = symbolTable.get(functionCallFrame->propertyNames().arguments.ustring().rep()).getIndex();
- if (!functionCallFrame->r(argumentsIndex).jsValue()) {
- Arguments* arguments = new (callFrame) Arguments(functionCallFrame);
- functionCallFrame->setCalleeArguments(arguments);
- functionCallFrame->r(RegisterFile::ArgumentsRegister) = JSValue(arguments);
+ int argumentsRegister = codeBlock->argumentsRegister();
+ if (!functionCallFrame->r(argumentsRegister).jsValue()) {
+ JSValue arguments = JSValue(new (callFrame) Arguments(functionCallFrame));
+ functionCallFrame->r(argumentsRegister) = arguments;
+ functionCallFrame->r(unmodifiedArgumentsRegister(argumentsRegister)) = arguments;
}
- return functionCallFrame->r(argumentsIndex).jsValue();
- }
-
- Arguments* arguments = functionCallFrame->optionalCalleeArguments();
- if (!arguments) {
- arguments = new (functionCallFrame) Arguments(functionCallFrame);
- arguments->copyRegisters();
- callFrame->setCalleeArguments(arguments);
+ return functionCallFrame->r(argumentsRegister).jsValue();
}
+ Arguments* arguments = new (functionCallFrame) Arguments(functionCallFrame);
+ arguments->copyRegisters();
return arguments;
}
-JSValue Interpreter::retrieveCaller(CallFrame* callFrame, InternalFunction* function) const
+JSValue Interpreter::retrieveCaller(CallFrame* callFrame, JSFunction* function) const
{
CallFrame* functionCallFrame = findFunctionCallFrame(callFrame, function);
if (!functionCallFrame)
@@ -4470,14 +4487,14 @@ void Interpreter::retrieveLastCaller(CallFrame* callFrame, int& lineNumber, intp
if (!callerCodeBlock)
return;
- unsigned bytecodeOffset = bytecodeOffsetForPC(callerFrame, callerCodeBlock, callFrame->returnPC());
+ unsigned bytecodeOffset = callerCodeBlock->bytecodeOffset(callerFrame, callFrame->returnPC());
lineNumber = callerCodeBlock->lineNumberForBytecodeOffset(callerFrame, bytecodeOffset - 1);
sourceID = callerCodeBlock->ownerExecutable()->sourceID();
sourceURL = callerCodeBlock->ownerExecutable()->sourceURL();
function = callerFrame->callee();
}
-CallFrame* Interpreter::findFunctionCallFrame(CallFrame* callFrame, InternalFunction* function)
+CallFrame* Interpreter::findFunctionCallFrame(CallFrame* callFrame, JSFunction* function)
{
for (CallFrame* candidate = callFrame; candidate; candidate = candidate->callerFrame()->removeHostCallFrameFlag()) {
if (candidate->callee() == function)
diff --git a/JavaScriptCore/interpreter/Interpreter.h b/JavaScriptCore/interpreter/Interpreter.h
index 0a5d592..3572617 100644
--- a/JavaScriptCore/interpreter/Interpreter.h
+++ b/JavaScriptCore/interpreter/Interpreter.h
@@ -44,7 +44,6 @@ namespace JSC {
class CodeBlock;
class EvalExecutable;
class FunctionExecutable;
- class InternalFunction;
class JSFunction;
class JSGlobalObject;
class ProgramExecutable;
@@ -101,7 +100,7 @@ namespace JSC {
JSValue execute(EvalExecutable* evalNode, CallFrame* exec, JSObject* thisObj, ScopeChainNode* scopeChain, JSValue* exception);
JSValue retrieveArguments(CallFrame*, JSFunction*) const;
- JSValue retrieveCaller(CallFrame*, InternalFunction*) const;
+ JSValue retrieveCaller(CallFrame*, JSFunction*) const;
void retrieveLastCaller(CallFrame*, int& lineNumber, intptr_t& sourceID, UString& sourceURL, JSValue& function) const;
void getArgumentsData(CallFrame*, JSFunction*&, ptrdiff_t& firstParameterIndex, Register*& argv, int& argc);
@@ -124,7 +123,7 @@ namespace JSC {
JSValue execute(EvalExecutable*, CallFrame*, JSObject* thisObject, int globalRegisterOffset, ScopeChainNode*, JSValue* exception);
-#if USE(INTERPRETER)
+#if !ENABLE(JIT)
NEVER_INLINE bool resolve(CallFrame*, Instruction*, JSValue& exceptionValue);
NEVER_INLINE bool resolveSkip(CallFrame*, Instruction*, JSValue& exceptionValue);
NEVER_INLINE bool resolveGlobal(CallFrame*, Instruction*, JSValue& exceptionValue);
@@ -137,13 +136,13 @@ namespace JSC {
void uncacheGetByID(CodeBlock*, Instruction* vPC);
void tryCachePutByID(CallFrame*, CodeBlock*, Instruction*, JSValue baseValue, const PutPropertySlot&);
void uncachePutByID(CodeBlock*, Instruction* vPC);
-#endif
+#endif // !ENABLE(JIT)
NEVER_INLINE bool unwindCallFrame(CallFrame*&, JSValue, unsigned& bytecodeOffset, CodeBlock*&);
static ALWAYS_INLINE CallFrame* slideRegisterWindowForCall(CodeBlock*, RegisterFile*, CallFrame*, size_t registerOffset, int argc);
- static CallFrame* findFunctionCallFrame(CallFrame*, InternalFunction*);
+ static CallFrame* findFunctionCallFrame(CallFrame*, JSFunction*);
JSValue privateExecute(ExecutionFlag, RegisterFile*, CallFrame*, JSValue* exception);
diff --git a/JavaScriptCore/interpreter/Register.h b/JavaScriptCore/interpreter/Register.h
index ecd7403..723112e 100644
--- a/JavaScriptCore/interpreter/Register.h
+++ b/JavaScriptCore/interpreter/Register.h
@@ -36,7 +36,6 @@
namespace JSC {
- class Arguments;
class CodeBlock;
class ExecState;
class JSActivation;
@@ -66,7 +65,6 @@ namespace JSC {
int32_t i() const;
JSActivation* activation() const;
- Arguments* arguments() const;
CallFrame* callFrame() const;
CodeBlock* codeBlock() const;
JSFunction* function() const;
diff --git a/JavaScriptCore/interpreter/RegisterFile.h b/JavaScriptCore/interpreter/RegisterFile.h
index def9e25..e9b8204 100644
--- a/JavaScriptCore/interpreter/RegisterFile.h
+++ b/JavaScriptCore/interpreter/RegisterFile.h
@@ -97,20 +97,17 @@ namespace JSC {
friend class JIT;
public:
enum CallFrameHeaderEntry {
- CallFrameHeaderSize = 8,
-
- CodeBlock = -8,
- ScopeChain = -7,
- CallerFrame = -6,
- ReturnPC = -5, // This is either an Instruction* or a pointer into JIT generated code stored as an Instruction*.
- ReturnValueRegister = -4,
- ArgumentCount = -3,
- Callee = -2,
- OptionalCalleeArguments = -1,
+ CallFrameHeaderSize = 6,
+
+ ArgumentCount = -6,
+ CallerFrame = -5,
+ Callee = -4,
+ ScopeChain = -3,
+ ReturnPC = -2, // This is either an Instruction* or a pointer into JIT generated code stored as an Instruction*.
+ CodeBlock = -1,
};
enum { ProgramCodeThisRegister = -CallFrameHeaderSize - 1 };
- enum { ArgumentsRegister = 0 };
static const size_t defaultCapacity = 524288;
static const size_t defaultMaxGlobals = 8192;
diff --git a/JavaScriptCore/jit/JIT.cpp b/JavaScriptCore/jit/JIT.cpp
index c7a4056..eeffd5c 100644
--- a/JavaScriptCore/jit/JIT.cpp
+++ b/JavaScriptCore/jit/JIT.cpp
@@ -24,6 +24,8 @@
*/
#include "config.h"
+
+#if ENABLE(JIT)
#include "JIT.h"
// This probably does not belong here; adding here for now as a quick Windows build fix.
@@ -32,8 +34,6 @@
JSC::MacroAssemblerX86Common::SSE2CheckState JSC::MacroAssemblerX86Common::s_sse2CheckState = NotCheckedSSE2;
#endif
-#if ENABLE(JIT)
-
#include "CodeBlock.h"
#include "Interpreter.h"
#include "JITInlineMethods.h"
@@ -78,10 +78,10 @@ JIT::JIT(JSGlobalData* globalData, CodeBlock* codeBlock)
, m_labels(codeBlock ? codeBlock->instructions().size() : 0)
, m_propertyAccessCompilationInfo(codeBlock ? codeBlock->numberOfStructureStubInfos() : 0)
, m_callStructureStubCompilationInfo(codeBlock ? codeBlock->numberOfCallLinkInfos() : 0)
- , m_bytecodeIndex((unsigned)-1)
+ , m_bytecodeOffset((unsigned)-1)
#if USE(JSVALUE32_64)
, m_jumpTargetIndex(0)
- , m_mappedBytecodeIndex((unsigned)-1)
+ , m_mappedBytecodeOffset((unsigned)-1)
, m_mappedVirtualRegisterIndex((unsigned)-1)
, m_mappedTag((RegisterID)-1)
, m_mappedPayload((RegisterID)-1)
@@ -114,7 +114,7 @@ void JIT::emitTimeoutCheck()
#endif
#define NEXT_OPCODE(name) \
- m_bytecodeIndex += OPCODE_LENGTH(name); \
+ m_bytecodeOffset += OPCODE_LENGTH(name); \
break;
#if USE(JSVALUE32_64)
@@ -176,21 +176,21 @@ void JIT::privateCompileMainPass()
m_globalResolveInfoIndex = 0;
m_callLinkInfoIndex = 0;
- for (m_bytecodeIndex = 0; m_bytecodeIndex < instructionCount; ) {
- Instruction* currentInstruction = instructionsBegin + m_bytecodeIndex;
- ASSERT_WITH_MESSAGE(m_interpreter->isOpcode(currentInstruction->u.opcode), "privateCompileMainPass gone bad @ %d", m_bytecodeIndex);
+ for (m_bytecodeOffset = 0; m_bytecodeOffset < instructionCount; ) {
+ Instruction* currentInstruction = instructionsBegin + m_bytecodeOffset;
+ ASSERT_WITH_MESSAGE(m_interpreter->isOpcode(currentInstruction->u.opcode), "privateCompileMainPass gone bad @ %d", m_bytecodeOffset);
#if ENABLE(OPCODE_SAMPLING)
- if (m_bytecodeIndex > 0) // Avoid the overhead of sampling op_enter twice.
+ if (m_bytecodeOffset > 0) // Avoid the overhead of sampling op_enter twice.
sampleInstruction(currentInstruction);
#endif
#if !USE(JSVALUE32_64)
- if (m_labels[m_bytecodeIndex].isUsed())
+ if (m_labels[m_bytecodeOffset].isUsed())
killLastResultRegister();
#endif
- m_labels[m_bytecodeIndex] = label();
+ m_labels[m_bytecodeOffset] = label();
switch (m_interpreter->getOpcodeID(currentInstruction->u.opcode)) {
DEFINE_BINARY_OP(op_del_by_val)
@@ -221,7 +221,6 @@ void JIT::privateCompileMainPass()
DEFINE_OP(op_call_varargs)
DEFINE_OP(op_catch)
DEFINE_OP(op_construct)
- DEFINE_OP(op_construct_verify)
DEFINE_OP(op_convert_this)
DEFINE_OP(op_init_arguments)
DEFINE_OP(op_create_arguments)
@@ -302,6 +301,8 @@ void JIT::privateCompileMainPass()
DEFINE_OP(op_resolve_skip)
DEFINE_OP(op_resolve_with_base)
DEFINE_OP(op_ret)
+ DEFINE_OP(op_call_put_result)
+ DEFINE_OP(op_ret_object_or_this)
DEFINE_OP(op_rshift)
DEFINE_OP(op_urshift)
DEFINE_OP(op_sret)
@@ -347,7 +348,7 @@ void JIT::privateCompileMainPass()
#ifndef NDEBUG
// Reset this, in order to guard its use with ASSERTs.
- m_bytecodeIndex = (unsigned)-1;
+ m_bytecodeOffset = (unsigned)-1;
#endif
}
@@ -356,7 +357,7 @@ void JIT::privateCompileLinkPass()
{
unsigned jmpTableCount = m_jmpTable.size();
for (unsigned i = 0; i < jmpTableCount; ++i)
- m_jmpTable[i].from.linkTo(m_labels[m_jmpTable[i].toBytecodeIndex], this);
+ m_jmpTable[i].from.linkTo(m_labels[m_jmpTable[i].toBytecodeOffset], this);
m_jmpTable.clear();
}
@@ -373,11 +374,11 @@ void JIT::privateCompileSlowCases()
killLastResultRegister();
#endif
- m_bytecodeIndex = iter->to;
+ m_bytecodeOffset = iter->to;
#ifndef NDEBUG
- unsigned firstTo = m_bytecodeIndex;
+ unsigned firstTo = m_bytecodeOffset;
#endif
- Instruction* currentInstruction = instructionsBegin + m_bytecodeIndex;
+ Instruction* currentInstruction = instructionsBegin + m_bytecodeOffset;
switch (m_interpreter->getOpcodeID(currentInstruction->u.opcode)) {
DEFINE_SLOWCASE_OP(op_add)
@@ -389,7 +390,6 @@ void JIT::privateCompileSlowCases()
DEFINE_SLOWCASE_OP(op_call_eval)
DEFINE_SLOWCASE_OP(op_call_varargs)
DEFINE_SLOWCASE_OP(op_construct)
- DEFINE_SLOWCASE_OP(op_construct_verify)
DEFINE_SLOWCASE_OP(op_convert_this)
#if !USE(JSVALUE32)
DEFINE_SLOWCASE_OP(op_div)
@@ -450,7 +450,7 @@ void JIT::privateCompileSlowCases()
#ifndef NDEBUG
// Reset this, in order to guard its use with ASSERTs.
- m_bytecodeIndex = (unsigned)-1;
+ m_bytecodeOffset = (unsigned)-1;
#endif
}
@@ -483,10 +483,10 @@ JITCode JIT::privateCompile()
if (m_codeBlock->codeType() == FunctionCode) {
registerFileCheck.link(this);
- m_bytecodeIndex = 0;
+ m_bytecodeOffset = 0;
JITStubCall(this, cti_register_file_check).call();
#ifndef NDEBUG
- m_bytecodeIndex = (unsigned)-1; // Reset this, in order to guard its use with ASSERTs.
+ m_bytecodeOffset = (unsigned)-1; // Reset this, in order to guard its use with ASSERTs.
#endif
jump(functionBody);
}
@@ -498,27 +498,27 @@ JITCode JIT::privateCompile()
// Translate vPC offsets into addresses in JIT generated code, for switch tables.
for (unsigned i = 0; i < m_switches.size(); ++i) {
SwitchRecord record = m_switches[i];
- unsigned bytecodeIndex = record.bytecodeIndex;
+ unsigned bytecodeOffset = record.bytecodeOffset;
if (record.type != SwitchRecord::String) {
ASSERT(record.type == SwitchRecord::Immediate || record.type == SwitchRecord::Character);
ASSERT(record.jumpTable.simpleJumpTable->branchOffsets.size() == record.jumpTable.simpleJumpTable->ctiOffsets.size());
- record.jumpTable.simpleJumpTable->ctiDefault = patchBuffer.locationOf(m_labels[bytecodeIndex + record.defaultOffset]);
+ record.jumpTable.simpleJumpTable->ctiDefault = patchBuffer.locationOf(m_labels[bytecodeOffset + record.defaultOffset]);
for (unsigned j = 0; j < record.jumpTable.simpleJumpTable->branchOffsets.size(); ++j) {
unsigned offset = record.jumpTable.simpleJumpTable->branchOffsets[j];
- record.jumpTable.simpleJumpTable->ctiOffsets[j] = offset ? patchBuffer.locationOf(m_labels[bytecodeIndex + offset]) : record.jumpTable.simpleJumpTable->ctiDefault;
+ record.jumpTable.simpleJumpTable->ctiOffsets[j] = offset ? patchBuffer.locationOf(m_labels[bytecodeOffset + offset]) : record.jumpTable.simpleJumpTable->ctiDefault;
}
} else {
ASSERT(record.type == SwitchRecord::String);
- record.jumpTable.stringJumpTable->ctiDefault = patchBuffer.locationOf(m_labels[bytecodeIndex + record.defaultOffset]);
+ record.jumpTable.stringJumpTable->ctiDefault = patchBuffer.locationOf(m_labels[bytecodeOffset + record.defaultOffset]);
StringJumpTable::StringOffsetTable::iterator end = record.jumpTable.stringJumpTable->offsetTable.end();
for (StringJumpTable::StringOffsetTable::iterator it = record.jumpTable.stringJumpTable->offsetTable.begin(); it != end; ++it) {
unsigned offset = it->second.branchOffset;
- it->second.ctiOffset = offset ? patchBuffer.locationOf(m_labels[bytecodeIndex + offset]) : record.jumpTable.stringJumpTable->ctiDefault;
+ it->second.ctiOffset = offset ? patchBuffer.locationOf(m_labels[bytecodeOffset + offset]) : record.jumpTable.stringJumpTable->ctiDefault;
}
}
}
@@ -536,7 +536,7 @@ JITCode JIT::privateCompile()
if (m_codeBlock->hasExceptionInfo()) {
m_codeBlock->callReturnIndexVector().reserveCapacity(m_calls.size());
for (Vector<CallRecord>::iterator iter = m_calls.begin(); iter != m_calls.end(); ++iter)
- m_codeBlock->callReturnIndexVector().append(CallReturnOffsetToBytecodeIndex(patchBuffer.returnAddressOffset(iter->from), iter->bytecodeIndex));
+ m_codeBlock->callReturnIndexVector().append(CallReturnOffsetToBytecodeOffset(patchBuffer.returnAddressOffset(iter->from), iter->bytecodeOffset));
}
// Link absolute addresses for jsr
diff --git a/JavaScriptCore/jit/JIT.h b/JavaScriptCore/jit/JIT.h
index b857351..928c80b 100644
--- a/JavaScriptCore/jit/JIT.h
+++ b/JavaScriptCore/jit/JIT.h
@@ -66,16 +66,16 @@ namespace JSC {
struct CallRecord {
MacroAssembler::Call from;
- unsigned bytecodeIndex;
+ unsigned bytecodeOffset;
void* to;
CallRecord()
{
}
- CallRecord(MacroAssembler::Call from, unsigned bytecodeIndex, void* to = 0)
+ CallRecord(MacroAssembler::Call from, unsigned bytecodeOffset, void* to = 0)
: from(from)
- , bytecodeIndex(bytecodeIndex)
+ , bytecodeOffset(bytecodeOffset)
, to(to)
{
}
@@ -83,11 +83,11 @@ namespace JSC {
struct JumpTable {
MacroAssembler::Jump from;
- unsigned toBytecodeIndex;
+ unsigned toBytecodeOffset;
JumpTable(MacroAssembler::Jump f, unsigned t)
: from(f)
- , toBytecodeIndex(t)
+ , toBytecodeOffset(t)
{
}
};
@@ -119,20 +119,20 @@ namespace JSC {
StringJumpTable* stringJumpTable;
} jumpTable;
- unsigned bytecodeIndex;
+ unsigned bytecodeOffset;
unsigned defaultOffset;
- SwitchRecord(SimpleJumpTable* jumpTable, unsigned bytecodeIndex, unsigned defaultOffset, Type type)
+ SwitchRecord(SimpleJumpTable* jumpTable, unsigned bytecodeOffset, unsigned defaultOffset, Type type)
: type(type)
- , bytecodeIndex(bytecodeIndex)
+ , bytecodeOffset(bytecodeOffset)
, defaultOffset(defaultOffset)
{
this->jumpTable.simpleJumpTable = jumpTable;
}
- SwitchRecord(StringJumpTable* jumpTable, unsigned bytecodeIndex, unsigned defaultOffset)
+ SwitchRecord(StringJumpTable* jumpTable, unsigned bytecodeOffset, unsigned defaultOffset)
: type(String)
- , bytecodeIndex(bytecodeIndex)
+ , bytecodeOffset(bytecodeOffset)
, defaultOffset(defaultOffset)
{
this->jumpTable.stringJumpTable = jumpTable;
@@ -223,6 +223,12 @@ namespace JSC {
jit.privateCompileCTIMachineTrampolines(executablePool, globalData, trampolines);
}
+ static CodePtr compileCTINativeCall(JSGlobalData* globalData, PassRefPtr<ExecutablePool> executablePool, NativeFunction func)
+ {
+ JIT jit(globalData);
+ return jit.privateCompileCTINativeCall(executablePool, globalData, func);
+ }
+
static void patchGetByIdSelf(CodeBlock* codeblock, StructureStubInfo*, Structure*, size_t cachedOffset, ReturnAddressPtr returnAddress);
static void patchPutByIdReplace(CodeBlock* codeblock, StructureStubInfo*, Structure*, size_t cachedOffset, ReturnAddressPtr returnAddress);
static void patchMethodCallProto(CodeBlock* codeblock, MethodCallLinkInfo&, JSFunction*, Structure*, JSObject*, ReturnAddressPtr);
@@ -263,6 +269,7 @@ namespace JSC {
void privateCompilePutByIdTransition(StructureStubInfo*, Structure*, Structure*, size_t cachedOffset, StructureChain*, ReturnAddressPtr returnAddress);
void privateCompileCTIMachineTrampolines(RefPtr<ExecutablePool>* executablePool, JSGlobalData* data, TrampolineStructure *trampolines);
+ CodePtr privateCompileCTINativeCall(PassRefPtr<ExecutablePool> executablePool, JSGlobalData* data, NativeFunction func);
void privateCompilePatchGetArrayLength(ReturnAddressPtr returnAddress);
void addSlowCase(Jump);
@@ -306,8 +313,8 @@ namespace JSC {
void emitStoreBool(unsigned index, RegisterID tag, bool indexIsBool = false);
void emitStoreDouble(unsigned index, FPRegisterID value);
- bool isLabeled(unsigned bytecodeIndex);
- void map(unsigned bytecodeIndex, unsigned virtualRegisterIndex, RegisterID tag, RegisterID payload);
+ bool isLabeled(unsigned bytecodeOffset);
+ void map(unsigned bytecodeOffset, unsigned virtualRegisterIndex, RegisterID tag, RegisterID payload);
void unmap(RegisterID);
void unmap();
bool isMapped(unsigned virtualRegisterIndex);
@@ -644,9 +651,9 @@ namespace JSC {
void emit_op_call(Instruction*);
void emit_op_call_eval(Instruction*);
void emit_op_call_varargs(Instruction*);
+ void emit_op_call_put_result(Instruction*);
void emit_op_catch(Instruction*);
void emit_op_construct(Instruction*);
- void emit_op_construct_verify(Instruction*);
void emit_op_convert_this(Instruction*);
void emit_op_create_arguments(Instruction*);
void emit_op_debug(Instruction*);
@@ -723,6 +730,7 @@ namespace JSC {
void emit_op_resolve_skip(Instruction*);
void emit_op_resolve_with_base(Instruction*);
void emit_op_ret(Instruction*);
+ void emit_op_ret_object_or_this(Instruction*);
void emit_op_rshift(Instruction*);
void emit_op_sret(Instruction*);
void emit_op_strcat(Instruction*);
@@ -751,7 +759,6 @@ namespace JSC {
void emitSlow_op_call_eval(Instruction*, Vector<SlowCaseEntry>::iterator&);
void emitSlow_op_call_varargs(Instruction*, Vector<SlowCaseEntry>::iterator&);
void emitSlow_op_construct(Instruction*, Vector<SlowCaseEntry>::iterator&);
- void emitSlow_op_construct_verify(Instruction*, Vector<SlowCaseEntry>::iterator&);
void emitSlow_op_convert_this(Instruction*, Vector<SlowCaseEntry>::iterator&);
void emitSlow_op_div(Instruction*, Vector<SlowCaseEntry>::iterator&);
void emitSlow_op_eq(Instruction*, Vector<SlowCaseEntry>::iterator&);
@@ -879,7 +886,7 @@ namespace JSC {
Vector<MethodCallCompilationInfo> m_methodCallCompilationInfo;
Vector<JumpTable> m_jmpTable;
- unsigned m_bytecodeIndex;
+ unsigned m_bytecodeOffset;
Vector<JSRInfo> m_jsrSites;
Vector<SlowCaseEntry> m_slowCases;
Vector<SwitchRecord> m_switches;
@@ -890,7 +897,7 @@ namespace JSC {
#if USE(JSVALUE32_64)
unsigned m_jumpTargetIndex;
- unsigned m_mappedBytecodeIndex;
+ unsigned m_mappedBytecodeOffset;
unsigned m_mappedVirtualRegisterIndex;
RegisterID m_mappedTag;
RegisterID m_mappedPayload;
@@ -905,7 +912,7 @@ namespace JSC {
int m_uninterruptedConstantSequenceBegin;
#endif
#endif
- static PassRefPtr<NativeExecutable> stringGetByValStubGenerator(JSGlobalData* globalData, ExecutablePool* pool);
+ static CodePtr stringGetByValStubGenerator(JSGlobalData* globalData, ExecutablePool* pool);
} JIT_CLASS_ALIGNMENT;
inline void JIT::emit_op_loop(Instruction* currentInstruction)
diff --git a/JavaScriptCore/jit/JITArithmetic.cpp b/JavaScriptCore/jit/JITArithmetic.cpp
index cd39b3a..0e5bb45 100644
--- a/JavaScriptCore/jit/JITArithmetic.cpp
+++ b/JavaScriptCore/jit/JITArithmetic.cpp
@@ -24,9 +24,10 @@
*/
#include "config.h"
-#include "JIT.h"
#if ENABLE(JIT)
+#if !USE(JSVALUE32_64)
+#include "JIT.h"
#include "CodeBlock.h"
#include "JITInlineMethods.h"
@@ -46,8 +47,6 @@ using namespace std;
namespace JSC {
-#if !USE(JSVALUE32_64)
-
void JIT::emit_op_lshift(Instruction* currentInstruction)
{
unsigned result = currentInstruction[1].u.operand;
@@ -1834,8 +1833,7 @@ void JIT::emitSlow_op_sub(Instruction* currentInstruction, Vector<SlowCaseEntry>
/* ------------------------------ END: OP_ADD, OP_SUB, OP_MUL ------------------------------ */
-#endif // !USE(JSVALUE32_64)
-
} // namespace JSC
+#endif // !USE(JSVALUE32_64)
#endif // ENABLE(JIT)
diff --git a/JavaScriptCore/jit/JITArithmetic32_64.cpp b/JavaScriptCore/jit/JITArithmetic32_64.cpp
index 97c8d32..023426e 100644
--- a/JavaScriptCore/jit/JITArithmetic32_64.cpp
+++ b/JavaScriptCore/jit/JITArithmetic32_64.cpp
@@ -24,9 +24,10 @@
*/
#include "config.h"
-#include "JIT.h"
#if ENABLE(JIT)
+#if USE(JSVALUE32_64)
+#include "JIT.h"
#include "CodeBlock.h"
#include "JITInlineMethods.h"
@@ -46,8 +47,6 @@ using namespace std;
namespace JSC {
-#if USE(JSVALUE32_64)
-
void JIT::emit_op_negate(Instruction* currentInstruction)
{
unsigned dst = currentInstruction[1].u.operand;
@@ -1404,8 +1403,7 @@ void JIT::emitSlow_op_mod(Instruction* currentInstruction, Vector<SlowCaseEntry>
/* ------------------------------ END: OP_MOD ------------------------------ */
-#endif // USE(JSVALUE32_64)
-
-}
+} // namespace JSC
+#endif // USE(JSVALUE32_64)
#endif // ENABLE(JIT)
diff --git a/JavaScriptCore/jit/JITCall.cpp b/JavaScriptCore/jit/JITCall.cpp
index 9979c8e..c0de9d1 100644
--- a/JavaScriptCore/jit/JITCall.cpp
+++ b/JavaScriptCore/jit/JITCall.cpp
@@ -24,9 +24,10 @@
*/
#include "config.h"
-#include "JIT.h"
#if ENABLE(JIT)
+#if !USE(JSVALUE32_64)
+#include "JIT.h"
#include "CodeBlock.h"
#include "JITInlineMethods.h"
@@ -45,406 +46,20 @@ using namespace std;
namespace JSC {
-#if USE(JSVALUE32_64)
-
-void JIT::compileOpCallInitializeCallFrame()
-{
- // regT0 holds callee, regT1 holds argCount
- store32(regT1, Address(callFrameRegister, RegisterFile::ArgumentCount * static_cast<int>(sizeof(Register))));
-
- loadPtr(Address(regT0, OBJECT_OFFSETOF(JSFunction, m_data) + OBJECT_OFFSETOF(ScopeChain, m_node)), regT1); // scopeChain
-
- emitStore(static_cast<unsigned>(RegisterFile::OptionalCalleeArguments), JSValue());
- storePtr(regT0, Address(callFrameRegister, RegisterFile::Callee * static_cast<int>(sizeof(Register)))); // callee
- storePtr(regT1, Address(callFrameRegister, RegisterFile::ScopeChain * static_cast<int>(sizeof(Register)))); // scopeChain
-}
-
-void JIT::compileOpCallSetupArgs(Instruction* instruction)
-{
- int argCount = instruction[3].u.operand;
- int registerOffset = instruction[4].u.operand;
-
- emitPutJITStubArg(regT1, regT0, 0);
- emitPutJITStubArgConstant(registerOffset, 1);
- emitPutJITStubArgConstant(argCount, 2);
-}
-
-void JIT::compileOpConstructSetupArgs(Instruction* instruction)
-{
- int argCount = instruction[3].u.operand;
- int registerOffset = instruction[4].u.operand;
- int proto = instruction[5].u.operand;
- int thisRegister = instruction[6].u.operand;
-
- emitPutJITStubArg(regT1, regT0, 0);
- emitPutJITStubArgConstant(registerOffset, 1);
- emitPutJITStubArgConstant(argCount, 2);
- emitPutJITStubArgFromVirtualRegister(proto, 3, regT2, regT3);
- emitPutJITStubArgConstant(thisRegister, 4);
-}
-
-void JIT::compileOpCallVarargsSetupArgs(Instruction*)
-{
- emitPutJITStubArg(regT1, regT0, 0);
- emitPutJITStubArg(regT3, 1); // registerOffset
- emitPutJITStubArg(regT2, 2); // argCount
-}
-
-void JIT::compileOpCallVarargs(Instruction* instruction)
-{
- int dst = instruction[1].u.operand;
- int callee = instruction[2].u.operand;
- int argCountRegister = instruction[3].u.operand;
- int registerOffset = instruction[4].u.operand;
-
- emitLoad(callee, regT1, regT0);
- emitLoadPayload(argCountRegister, regT2); // argCount
- addPtr(Imm32(registerOffset), regT2, regT3); // registerOffset
-
- compileOpCallVarargsSetupArgs(instruction);
-
- emitJumpSlowCaseIfNotJSCell(callee, regT1);
- addSlowCase(branchPtr(NotEqual, Address(regT0), ImmPtr(m_globalData->jsFunctionVPtr)));
-
- // Speculatively roll the callframe, assuming argCount will match the arity.
- mul32(Imm32(sizeof(Register)), regT3, regT3);
- addPtr(callFrameRegister, regT3);
- storePtr(callFrameRegister, Address(regT3, RegisterFile::CallerFrame * static_cast<int>(sizeof(Register))));
- move(regT3, callFrameRegister);
-
- move(regT2, regT1); // argCount
-
- emitNakedCall(m_globalData->jitStubs.ctiVirtualCall());
-
- emitStore(dst, regT1, regT0);
-
- sampleCodeBlock(m_codeBlock);
-}
-
-void JIT::compileOpCallVarargsSlowCase(Instruction* instruction, Vector<SlowCaseEntry>::iterator& iter)
-{
- int dst = instruction[1].u.operand;
- int callee = instruction[2].u.operand;
-
- linkSlowCaseIfNotJSCell(iter, callee);
- linkSlowCase(iter);
-
- JITStubCall stubCall(this, cti_op_call_NotJSFunction);
- stubCall.call(dst); // In the interpreter, the callee puts the return value in dst.
-
- map(m_bytecodeIndex + OPCODE_LENGTH(op_call_varargs), dst, regT1, regT0);
- sampleCodeBlock(m_codeBlock);
-}
-
-void JIT::emit_op_ret(Instruction* currentInstruction)
-{
- unsigned dst = currentInstruction[1].u.operand;
-
- // We could JIT generate the deref, only calling out to C when the refcount hits zero.
- if (m_codeBlock->needsFullScopeChain())
- JITStubCall(this, cti_op_ret_scopeChain).call();
-
- emitLoad(dst, regT1, regT0);
- emitGetFromCallFrameHeaderPtr(RegisterFile::ReturnPC, regT2);
- emitGetFromCallFrameHeaderPtr(RegisterFile::CallerFrame, callFrameRegister);
-
- restoreReturnAddressBeforeReturn(regT2);
- ret();
-}
-
-void JIT::emit_op_construct_verify(Instruction* currentInstruction)
-{
- unsigned dst = currentInstruction[1].u.operand;
-
- emitLoad(dst, regT1, regT0);
- addSlowCase(branch32(NotEqual, regT1, Imm32(JSValue::CellTag)));
- loadPtr(Address(regT0, OBJECT_OFFSETOF(JSCell, m_structure)), regT2);
- addSlowCase(branch8(NotEqual, Address(regT2, OBJECT_OFFSETOF(Structure, m_typeInfo) + OBJECT_OFFSETOF(TypeInfo, m_type)), Imm32(ObjectType)));
-}
-
-void JIT::emitSlow_op_construct_verify(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
-{
- unsigned dst = currentInstruction[1].u.operand;
- unsigned src = currentInstruction[2].u.operand;
-
- linkSlowCase(iter);
- linkSlowCase(iter);
- emitLoad(src, regT1, regT0);
- emitStore(dst, regT1, regT0);
-}
-
-void JIT::emitSlow_op_call(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
-{
- compileOpCallSlowCase(currentInstruction, iter, m_callLinkInfoIndex++, op_call);
-}
-
-void JIT::emitSlow_op_call_eval(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
-{
- compileOpCallSlowCase(currentInstruction, iter, m_callLinkInfoIndex++, op_call_eval);
-}
-
-void JIT::emitSlow_op_call_varargs(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
-{
- compileOpCallVarargsSlowCase(currentInstruction, iter);
-}
-
-void JIT::emitSlow_op_construct(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
-{
- compileOpCallSlowCase(currentInstruction, iter, m_callLinkInfoIndex++, op_construct);
-}
-
-void JIT::emit_op_call(Instruction* currentInstruction)
-{
- compileOpCall(op_call, currentInstruction, m_callLinkInfoIndex++);
-}
-
-void JIT::emit_op_call_eval(Instruction* currentInstruction)
-{
- compileOpCall(op_call_eval, currentInstruction, m_callLinkInfoIndex++);
-}
-
-void JIT::emit_op_load_varargs(Instruction* currentInstruction)
-{
- int argCountDst = currentInstruction[1].u.operand;
- int argsOffset = currentInstruction[2].u.operand;
-
- JITStubCall stubCall(this, cti_op_load_varargs);
- stubCall.addArgument(Imm32(argsOffset));
- stubCall.call();
- // Stores a naked int32 in the register file.
- store32(returnValueRegister, Address(callFrameRegister, argCountDst * sizeof(Register)));
-}
-
-void JIT::emit_op_call_varargs(Instruction* currentInstruction)
-{
- compileOpCallVarargs(currentInstruction);
-}
-
-void JIT::emit_op_construct(Instruction* currentInstruction)
-{
- compileOpCall(op_construct, currentInstruction, m_callLinkInfoIndex++);
-}
-
-#if !ENABLE(JIT_OPTIMIZE_CALL)
-
-/* ------------------------------ BEGIN: !ENABLE(JIT_OPTIMIZE_CALL) ------------------------------ */
-
-void JIT::compileOpCall(OpcodeID opcodeID, Instruction* instruction, unsigned)
-{
- int dst = instruction[1].u.operand;
- int callee = instruction[2].u.operand;
- int argCount = instruction[3].u.operand;
- int registerOffset = instruction[4].u.operand;
-
- Jump wasEval;
- if (opcodeID == op_call_eval) {
- JITStubCall stubCall(this, cti_op_call_eval);
- stubCall.addArgument(callee);
- stubCall.addArgument(JIT::Imm32(registerOffset));
- stubCall.addArgument(JIT::Imm32(argCount));
- stubCall.call();
- wasEval = branch32(NotEqual, regT1, Imm32(JSValue::EmptyValueTag));
- }
-
- emitLoad(callee, regT1, regT0);
-
- if (opcodeID == op_call)
- compileOpCallSetupArgs(instruction);
- else if (opcodeID == op_construct)
- compileOpConstructSetupArgs(instruction);
-
- emitJumpSlowCaseIfNotJSCell(callee, regT1);
- addSlowCase(branchPtr(NotEqual, Address(regT0), ImmPtr(m_globalData->jsFunctionVPtr)));
-
- // First, in the case of a construct, allocate the new object.
- if (opcodeID == op_construct) {
- JITStubCall(this, cti_op_construct_JSConstruct).call(registerOffset - RegisterFile::CallFrameHeaderSize - argCount);
- emitLoad(callee, regT1, regT0);
- }
-
- // Speculatively roll the callframe, assuming argCount will match the arity.
- storePtr(callFrameRegister, Address(callFrameRegister, (RegisterFile::CallerFrame + registerOffset) * static_cast<int>(sizeof(Register))));
- addPtr(Imm32(registerOffset * static_cast<int>(sizeof(Register))), callFrameRegister);
- move(Imm32(argCount), regT1);
-
- emitNakedCall(opcodeID == op_construct ? m_globalData->jitStubs.ctiVirtualConstruct() : m_globalData->jitStubs.ctiVirtualCall());
-
- if (opcodeID == op_call_eval)
- wasEval.link(this);
-
- emitStore(dst, regT1, regT0);
-
- sampleCodeBlock(m_codeBlock);
-}
-
-void JIT::compileOpCallSlowCase(Instruction* instruction, Vector<SlowCaseEntry>::iterator& iter, unsigned, OpcodeID opcodeID)
-{
- int dst = instruction[1].u.operand;
- int callee = instruction[2].u.operand;
-
- linkSlowCaseIfNotJSCell(iter, callee);
- linkSlowCase(iter);
-
- JITStubCall stubCall(this, opcodeID == op_construct ? cti_op_construct_NotJSConstruct : cti_op_call_NotJSFunction);
- stubCall.call(dst); // In the interpreter, the callee puts the return value in dst.
-
- sampleCodeBlock(m_codeBlock);
-}
-
-#else // !ENABLE(JIT_OPTIMIZE_CALL)
-
-/* ------------------------------ BEGIN: ENABLE(JIT_OPTIMIZE_CALL) ------------------------------ */
-
-void JIT::compileOpCall(OpcodeID opcodeID, Instruction* instruction, unsigned callLinkInfoIndex)
-{
- int dst = instruction[1].u.operand;
- int callee = instruction[2].u.operand;
- int argCount = instruction[3].u.operand;
- int registerOffset = instruction[4].u.operand;
-
- Jump wasEval;
- if (opcodeID == op_call_eval) {
- JITStubCall stubCall(this, cti_op_call_eval);
- stubCall.addArgument(callee);
- stubCall.addArgument(JIT::Imm32(registerOffset));
- stubCall.addArgument(JIT::Imm32(argCount));
- stubCall.call();
- wasEval = branch32(NotEqual, regT1, Imm32(JSValue::EmptyValueTag));
- }
-
- emitLoad(callee, regT1, regT0);
-
- DataLabelPtr addressOfLinkedFunctionCheck;
-
- BEGIN_UNINTERRUPTED_SEQUENCE(sequenceOpCall);
-
- Jump jumpToSlow = branchPtrWithPatch(NotEqual, regT0, addressOfLinkedFunctionCheck, ImmPtr(0));
-
- END_UNINTERRUPTED_SEQUENCE(sequenceOpCall);
-
- addSlowCase(jumpToSlow);
- ASSERT(differenceBetween(addressOfLinkedFunctionCheck, jumpToSlow) == patchOffsetOpCallCompareToJump);
- m_callStructureStubCompilationInfo[callLinkInfoIndex].hotPathBegin = addressOfLinkedFunctionCheck;
-
- addSlowCase(branch32(NotEqual, regT1, Imm32(JSValue::CellTag)));
-
- // The following is the fast case, only used whan a callee can be linked.
-
- // In the case of OpConstruct, call out to a cti_ function to create the new object.
- if (opcodeID == op_construct) {
- int proto = instruction[5].u.operand;
- int thisRegister = instruction[6].u.operand;
-
- JITStubCall stubCall(this, cti_op_construct_JSConstruct);
- stubCall.addArgument(regT1, regT0);
- stubCall.addArgument(Imm32(0)); // FIXME: Remove this unused JITStub argument.
- stubCall.addArgument(Imm32(0)); // FIXME: Remove this unused JITStub argument.
- stubCall.addArgument(proto);
- stubCall.call(thisRegister);
-
- emitLoad(callee, regT1, regT0);
- }
-
- // Fast version of stack frame initialization, directly relative to edi.
- // Note that this omits to set up RegisterFile::CodeBlock, which is set in the callee
- emitStore(registerOffset + RegisterFile::OptionalCalleeArguments, JSValue());
- emitStore(registerOffset + RegisterFile::Callee, regT1, regT0);
-
- loadPtr(Address(regT0, OBJECT_OFFSETOF(JSFunction, m_data) + OBJECT_OFFSETOF(ScopeChain, m_node)), regT1); // newScopeChain
- store32(Imm32(argCount), Address(callFrameRegister, (registerOffset + RegisterFile::ArgumentCount) * static_cast<int>(sizeof(Register))));
- storePtr(callFrameRegister, Address(callFrameRegister, (registerOffset + RegisterFile::CallerFrame) * static_cast<int>(sizeof(Register))));
- storePtr(regT1, Address(callFrameRegister, (registerOffset + RegisterFile::ScopeChain) * static_cast<int>(sizeof(Register))));
- addPtr(Imm32(registerOffset * sizeof(Register)), callFrameRegister);
-
- // Call to the callee
- m_callStructureStubCompilationInfo[callLinkInfoIndex].hotPathOther = emitNakedCall();
-
- if (opcodeID == op_call_eval)
- wasEval.link(this);
-
- // Put the return value in dst. In the interpreter, op_ret does this.
- emitStore(dst, regT1, regT0);
- map(m_bytecodeIndex + opcodeLengths[opcodeID], dst, regT1, regT0);
-
- sampleCodeBlock(m_codeBlock);
-}
-
-void JIT::compileOpCallSlowCase(Instruction* instruction, Vector<SlowCaseEntry>::iterator& iter, unsigned callLinkInfoIndex, OpcodeID opcodeID)
-{
- int dst = instruction[1].u.operand;
- int callee = instruction[2].u.operand;
- int argCount = instruction[3].u.operand;
- int registerOffset = instruction[4].u.operand;
-
- linkSlowCase(iter);
- linkSlowCase(iter);
-
- // The arguments have been set up on the hot path for op_call_eval
- if (opcodeID == op_call)
- compileOpCallSetupArgs(instruction);
- else if (opcodeID == op_construct)
- compileOpConstructSetupArgs(instruction);
-
- // Fast check for JS function.
- Jump callLinkFailNotObject = branch32(NotEqual, regT1, Imm32(JSValue::CellTag));
- Jump callLinkFailNotJSFunction = branchPtr(NotEqual, Address(regT0), ImmPtr(m_globalData->jsFunctionVPtr));
-
- // First, in the case of a construct, allocate the new object.
- if (opcodeID == op_construct) {
- JITStubCall(this, cti_op_construct_JSConstruct).call(registerOffset - RegisterFile::CallFrameHeaderSize - argCount);
- emitLoad(callee, regT1, regT0);
- }
-
- // Speculatively roll the callframe, assuming argCount will match the arity.
- storePtr(callFrameRegister, Address(callFrameRegister, (RegisterFile::CallerFrame + registerOffset) * static_cast<int>(sizeof(Register))));
- addPtr(Imm32(registerOffset * static_cast<int>(sizeof(Register))), callFrameRegister);
- move(Imm32(argCount), regT1);
-
- m_callStructureStubCompilationInfo[callLinkInfoIndex].callReturnLocation = emitNakedCall(opcodeID == op_construct ? m_globalData->jitStubs.ctiVirtualConstructLink() : m_globalData->jitStubs.ctiVirtualCallLink());
-
- // Put the return value in dst.
- emitStore(dst, regT1, regT0);;
- sampleCodeBlock(m_codeBlock);
-
- // If not, we need an extra case in the if below!
- ASSERT(OPCODE_LENGTH(op_call) == OPCODE_LENGTH(op_call_eval));
-
- // Done! - return back to the hot path.
- if (opcodeID == op_construct)
- emitJumpSlowToHot(jump(), OPCODE_LENGTH(op_construct));
- else
- emitJumpSlowToHot(jump(), OPCODE_LENGTH(op_call));
-
- // This handles host functions
- callLinkFailNotObject.link(this);
- callLinkFailNotJSFunction.link(this);
- JITStubCall(this, opcodeID == op_construct ? cti_op_construct_NotJSConstruct : cti_op_call_NotJSFunction).call();
-
- emitStore(dst, regT1, regT0);;
- sampleCodeBlock(m_codeBlock);
-}
-
-/* ------------------------------ END: !ENABLE / ENABLE(JIT_OPTIMIZE_CALL) ------------------------------ */
-
-#endif // !ENABLE(JIT_OPTIMIZE_CALL)
-
-#else // USE(JSVALUE32_64)
-
void JIT::compileOpCallInitializeCallFrame()
{
store32(regT1, Address(callFrameRegister, RegisterFile::ArgumentCount * static_cast<int>(sizeof(Register))));
- loadPtr(Address(regT0, OBJECT_OFFSETOF(JSFunction, m_data) + OBJECT_OFFSETOF(ScopeChain, m_node)), regT1); // newScopeChain
+ loadPtr(Address(regT0, OBJECT_OFFSETOF(JSFunction, m_scopeChain) + OBJECT_OFFSETOF(ScopeChain, m_node)), regT1); // newScopeChain
- storePtr(ImmPtr(JSValue::encode(JSValue())), Address(callFrameRegister, RegisterFile::OptionalCalleeArguments * static_cast<int>(sizeof(Register))));
storePtr(regT0, Address(callFrameRegister, RegisterFile::Callee * static_cast<int>(sizeof(Register))));
storePtr(regT1, Address(callFrameRegister, RegisterFile::ScopeChain * static_cast<int>(sizeof(Register))));
}
void JIT::compileOpCallSetupArgs(Instruction* instruction)
{
- int argCount = instruction[3].u.operand;
- int registerOffset = instruction[4].u.operand;
+ int argCount = instruction[2].u.operand;
+ int registerOffset = instruction[3].u.operand;
// ecx holds func
emitPutJITStubArg(regT0, 0);
@@ -454,7 +69,7 @@ void JIT::compileOpCallSetupArgs(Instruction* instruction)
void JIT::compileOpCallVarargsSetupArgs(Instruction* instruction)
{
- int registerOffset = instruction[4].u.operand;
+ int registerOffset = instruction[3].u.operand;
// ecx holds func
emitPutJITStubArg(regT0, 0);
@@ -465,10 +80,10 @@ void JIT::compileOpCallVarargsSetupArgs(Instruction* instruction)
void JIT::compileOpConstructSetupArgs(Instruction* instruction)
{
- int argCount = instruction[3].u.operand;
- int registerOffset = instruction[4].u.operand;
- int proto = instruction[5].u.operand;
- int thisRegister = instruction[6].u.operand;
+ int argCount = instruction[2].u.operand;
+ int registerOffset = instruction[3].u.operand;
+ int proto = instruction[4].u.operand;
+ int thisRegister = instruction[5].u.operand;
// ecx holds func
emitPutJITStubArg(regT0, 0);
@@ -478,11 +93,16 @@ void JIT::compileOpConstructSetupArgs(Instruction* instruction)
emitPutJITStubArgConstant(thisRegister, 4);
}
-void JIT::compileOpCallVarargs(Instruction* instruction)
+void JIT::emit_op_call_put_result(Instruction* instruction)
{
int dst = instruction[1].u.operand;
- int callee = instruction[2].u.operand;
- int argCountRegister = instruction[3].u.operand;
+ emitPutVirtualRegister(dst);
+}
+
+void JIT::compileOpCallVarargs(Instruction* instruction)
+{
+ int callee = instruction[1].u.operand;
+ int argCountRegister = instruction[2].u.operand;
emitGetVirtualRegister(argCountRegister, regT1);
emitGetVirtualRegister(callee, regT0);
@@ -501,20 +121,15 @@ void JIT::compileOpCallVarargs(Instruction* instruction)
addPtr(regT2, callFrameRegister);
emitNakedCall(m_globalData->jitStubs.ctiVirtualCall());
- // Put the return value in dst. In the interpreter, op_ret does this.
- emitPutVirtualRegister(dst);
-
sampleCodeBlock(m_codeBlock);
}
-void JIT::compileOpCallVarargsSlowCase(Instruction* instruction, Vector<SlowCaseEntry>::iterator& iter)
+void JIT::compileOpCallVarargsSlowCase(Instruction*, Vector<SlowCaseEntry>::iterator& iter)
{
- int dst = instruction[1].u.operand;
-
linkSlowCase(iter);
linkSlowCase(iter);
JITStubCall stubCall(this, cti_op_call_NotJSFunction);
- stubCall.call(dst); // In the interpreter, the callee puts the return value in dst.
+ stubCall.call();
sampleCodeBlock(m_codeBlock);
}
@@ -525,10 +140,9 @@ void JIT::compileOpCallVarargsSlowCase(Instruction* instruction, Vector<SlowCase
void JIT::compileOpCall(OpcodeID opcodeID, Instruction* instruction, unsigned)
{
- int dst = instruction[1].u.operand;
- int callee = instruction[2].u.operand;
- int argCount = instruction[3].u.operand;
- int registerOffset = instruction[4].u.operand;
+ int callee = instruction[1].u.operand;
+ int argCount = instruction[2].u.operand;
+ int registerOffset = instruction[3].u.operand;
// Handle eval
Jump wasEval;
@@ -568,20 +182,15 @@ void JIT::compileOpCall(OpcodeID opcodeID, Instruction* instruction, unsigned)
if (opcodeID == op_call_eval)
wasEval.link(this);
- // Put the return value in dst. In the interpreter, op_ret does this.
- emitPutVirtualRegister(dst);
-
sampleCodeBlock(m_codeBlock);
}
void JIT::compileOpCallSlowCase(Instruction* instruction, Vector<SlowCaseEntry>::iterator& iter, unsigned, OpcodeID opcodeID)
{
- int dst = instruction[1].u.operand;
-
linkSlowCase(iter);
linkSlowCase(iter);
JITStubCall stubCall(this, opcodeID == op_construct ? cti_op_construct_NotJSConstruct : cti_op_call_NotJSFunction);
- stubCall.call(dst); // In the interpreter, the callee puts the return value in dst.
+ stubCall.call();
sampleCodeBlock(m_codeBlock);
}
@@ -592,10 +201,9 @@ void JIT::compileOpCallSlowCase(Instruction* instruction, Vector<SlowCaseEntry>:
void JIT::compileOpCall(OpcodeID opcodeID, Instruction* instruction, unsigned callLinkInfoIndex)
{
- int dst = instruction[1].u.operand;
- int callee = instruction[2].u.operand;
- int argCount = instruction[3].u.operand;
- int registerOffset = instruction[4].u.operand;
+ int callee = instruction[1].u.operand;
+ int argCount = instruction[2].u.operand;
+ int registerOffset = instruction[3].u.operand;
// Handle eval
Jump wasEval;
@@ -627,8 +235,8 @@ void JIT::compileOpCall(OpcodeID opcodeID, Instruction* instruction, unsigned ca
// In the case of OpConstruct, call out to a cti_ function to create the new object.
if (opcodeID == op_construct) {
- int proto = instruction[5].u.operand;
- int thisRegister = instruction[6].u.operand;
+ int proto = instruction[4].u.operand;
+ int thisRegister = instruction[5].u.operand;
emitPutJITStubArg(regT0, 0);
emitPutJITStubArgFromVirtualRegister(proto, 3, regT2);
@@ -639,11 +247,12 @@ void JIT::compileOpCall(OpcodeID opcodeID, Instruction* instruction, unsigned ca
// Fast version of stack frame initialization, directly relative to edi.
// Note that this omits to set up RegisterFile::CodeBlock, which is set in the callee
- storePtr(ImmPtr(JSValue::encode(JSValue())), Address(callFrameRegister, (registerOffset + RegisterFile::OptionalCalleeArguments) * static_cast<int>(sizeof(Register))));
- storePtr(regT0, Address(callFrameRegister, (registerOffset + RegisterFile::Callee) * static_cast<int>(sizeof(Register))));
- loadPtr(Address(regT0, OBJECT_OFFSETOF(JSFunction, m_data) + OBJECT_OFFSETOF(ScopeChain, m_node)), regT1); // newScopeChain
+
+ loadPtr(Address(regT0, OBJECT_OFFSETOF(JSFunction, m_scopeChain) + OBJECT_OFFSETOF(ScopeChain, m_node)), regT1); // newScopeChain
+
store32(Imm32(argCount), Address(callFrameRegister, (registerOffset + RegisterFile::ArgumentCount) * static_cast<int>(sizeof(Register))));
storePtr(callFrameRegister, Address(callFrameRegister, (registerOffset + RegisterFile::CallerFrame) * static_cast<int>(sizeof(Register))));
+ storePtr(regT0, Address(callFrameRegister, (registerOffset + RegisterFile::Callee) * static_cast<int>(sizeof(Register))));
storePtr(regT1, Address(callFrameRegister, (registerOffset + RegisterFile::ScopeChain) * static_cast<int>(sizeof(Register))));
addPtr(Imm32(registerOffset * sizeof(Register)), callFrameRegister);
@@ -653,18 +262,14 @@ void JIT::compileOpCall(OpcodeID opcodeID, Instruction* instruction, unsigned ca
if (opcodeID == op_call_eval)
wasEval.link(this);
- // Put the return value in dst. In the interpreter, op_ret does this.
- emitPutVirtualRegister(dst);
-
sampleCodeBlock(m_codeBlock);
}
void JIT::compileOpCallSlowCase(Instruction* instruction, Vector<SlowCaseEntry>::iterator& iter, unsigned callLinkInfoIndex, OpcodeID opcodeID)
{
- int dst = instruction[1].u.operand;
- int callee = instruction[2].u.operand;
- int argCount = instruction[3].u.operand;
- int registerOffset = instruction[4].u.operand;
+ int callee = instruction[1].u.operand;
+ int argCount = instruction[2].u.operand;
+ int registerOffset = instruction[3].u.operand;
linkSlowCase(iter);
@@ -693,10 +298,6 @@ void JIT::compileOpCallSlowCase(Instruction* instruction, Vector<SlowCaseEntry>:
m_callStructureStubCompilationInfo[callLinkInfoIndex].callReturnLocation = emitNakedCall(opcodeID == op_construct ? m_globalData->jitStubs.ctiVirtualConstructLink() : m_globalData->jitStubs.ctiVirtualCallLink());
- // Put the return value in dst.
- emitPutVirtualRegister(dst);
- sampleCodeBlock(m_codeBlock);
-
// If not, we need an extra case in the if below!
ASSERT(OPCODE_LENGTH(op_call) == OPCODE_LENGTH(op_call_eval));
@@ -711,7 +312,6 @@ void JIT::compileOpCallSlowCase(Instruction* instruction, Vector<SlowCaseEntry>:
callLinkFailNotJSFunction.link(this);
JITStubCall(this, opcodeID == op_construct ? cti_op_construct_NotJSConstruct : cti_op_call_NotJSFunction).call();
- emitPutVirtualRegister(dst);
sampleCodeBlock(m_codeBlock);
}
@@ -719,8 +319,7 @@ void JIT::compileOpCallSlowCase(Instruction* instruction, Vector<SlowCaseEntry>:
#endif // !ENABLE(JIT_OPTIMIZE_CALL)
-#endif // USE(JSVALUE32_64)
-
} // namespace JSC
+#endif // !USE(JSVALUE32_64)
#endif // ENABLE(JIT)
diff --git a/JavaScriptCore/jit/JITCall32_64.cpp b/JavaScriptCore/jit/JITCall32_64.cpp
new file mode 100644
index 0000000..9b5451a
--- /dev/null
+++ b/JavaScriptCore/jit/JITCall32_64.cpp
@@ -0,0 +1,427 @@
+/*
+ * Copyright (C) 2008 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(JIT)
+#if USE(JSVALUE32_64)
+#include "JIT.h"
+
+#include "CodeBlock.h"
+#include "Interpreter.h"
+#include "JITInlineMethods.h"
+#include "JITStubCall.h"
+#include "JSArray.h"
+#include "JSFunction.h"
+#include "ResultType.h"
+#include "SamplingTool.h"
+
+#ifndef NDEBUG
+#include <stdio.h>
+#endif
+
+using namespace std;
+
+namespace JSC {
+
+void JIT::compileOpCallInitializeCallFrame()
+{
+ // regT0 holds callee, regT1 holds argCount
+ store32(regT1, Address(callFrameRegister, RegisterFile::ArgumentCount * static_cast<int>(sizeof(Register))));
+
+ loadPtr(Address(regT0, OBJECT_OFFSETOF(JSFunction, m_scopeChain) + OBJECT_OFFSETOF(ScopeChain, m_node)), regT1); // scopeChain
+
+ storePtr(regT0, Address(callFrameRegister, RegisterFile::Callee * static_cast<int>(sizeof(Register)))); // callee
+ storePtr(regT1, Address(callFrameRegister, RegisterFile::ScopeChain * static_cast<int>(sizeof(Register)))); // scopeChain
+}
+
+void JIT::compileOpCallSetupArgs(Instruction* instruction)
+{
+ int argCount = instruction[2].u.operand;
+ int registerOffset = instruction[3].u.operand;
+
+ emitPutJITStubArg(regT1, regT0, 0);
+ emitPutJITStubArgConstant(registerOffset, 1);
+ emitPutJITStubArgConstant(argCount, 2);
+}
+
+void JIT::compileOpConstructSetupArgs(Instruction* instruction)
+{
+ int argCount = instruction[2].u.operand;
+ int registerOffset = instruction[3].u.operand;
+ int proto = instruction[4].u.operand;
+ int thisRegister = instruction[5].u.operand;
+
+ emitPutJITStubArg(regT1, regT0, 0);
+ emitPutJITStubArgConstant(registerOffset, 1);
+ emitPutJITStubArgConstant(argCount, 2);
+ emitPutJITStubArgFromVirtualRegister(proto, 3, regT2, regT3);
+ emitPutJITStubArgConstant(thisRegister, 4);
+}
+
+void JIT::compileOpCallVarargsSetupArgs(Instruction*)
+{
+ emitPutJITStubArg(regT1, regT0, 0);
+ emitPutJITStubArg(regT3, 1); // registerOffset
+ emitPutJITStubArg(regT2, 2); // argCount
+}
+
+void JIT::emit_op_call_put_result(Instruction* instruction)
+{
+ int dst = instruction[1].u.operand;
+ emitStore(dst, regT1, regT0);
+}
+
+void JIT::compileOpCallVarargs(Instruction* instruction)
+{
+ int callee = instruction[1].u.operand;
+ int argCountRegister = instruction[2].u.operand;
+ int registerOffset = instruction[3].u.operand;
+
+ emitLoad(callee, regT1, regT0);
+ emitLoadPayload(argCountRegister, regT2); // argCount
+ addPtr(Imm32(registerOffset), regT2, regT3); // registerOffset
+
+ compileOpCallVarargsSetupArgs(instruction);
+
+ emitJumpSlowCaseIfNotJSCell(callee, regT1);
+ addSlowCase(branchPtr(NotEqual, Address(regT0), ImmPtr(m_globalData->jsFunctionVPtr)));
+
+ // Speculatively roll the callframe, assuming argCount will match the arity.
+ mul32(Imm32(sizeof(Register)), regT3, regT3);
+ addPtr(callFrameRegister, regT3);
+ storePtr(callFrameRegister, Address(regT3, RegisterFile::CallerFrame * static_cast<int>(sizeof(Register))));
+ move(regT3, callFrameRegister);
+
+ move(regT2, regT1); // argCount
+
+ emitNakedCall(m_globalData->jitStubs.ctiVirtualCall());
+
+ sampleCodeBlock(m_codeBlock);
+}
+
+void JIT::compileOpCallVarargsSlowCase(Instruction* instruction, Vector<SlowCaseEntry>::iterator& iter)
+{
+ int callee = instruction[1].u.operand;
+
+ linkSlowCaseIfNotJSCell(iter, callee);
+ linkSlowCase(iter);
+
+ JITStubCall stubCall(this, cti_op_call_NotJSFunction);
+ stubCall.call();
+
+ sampleCodeBlock(m_codeBlock);
+}
+
+void JIT::emit_op_ret(Instruction* currentInstruction)
+{
+ unsigned dst = currentInstruction[1].u.operand;
+
+ // We could JIT generate the deref, only calling out to C when the refcount hits zero.
+ if (m_codeBlock->needsFullScopeChain())
+ JITStubCall(this, cti_op_ret_scopeChain).call();
+
+ emitLoad(dst, regT1, regT0);
+ emitGetFromCallFrameHeaderPtr(RegisterFile::ReturnPC, regT2);
+ emitGetFromCallFrameHeaderPtr(RegisterFile::CallerFrame, callFrameRegister);
+
+ restoreReturnAddressBeforeReturn(regT2);
+ ret();
+}
+
+void JIT::emit_op_ret_object_or_this(Instruction* currentInstruction)
+{
+ unsigned result = currentInstruction[1].u.operand;
+ unsigned thisReg = currentInstruction[2].u.operand;
+
+ // We could JIT generate the deref, only calling out to C when the refcount hits zero.
+ if (m_codeBlock->needsFullScopeChain())
+ JITStubCall(this, cti_op_ret_scopeChain).call();
+
+ emitLoad(result, regT1, regT0);
+ Jump notJSCell = branch32(NotEqual, regT1, Imm32(JSValue::CellTag));
+ loadPtr(Address(regT0, OBJECT_OFFSETOF(JSCell, m_structure)), regT2);
+ Jump notObject = branch8(NotEqual, Address(regT2, OBJECT_OFFSETOF(Structure, m_typeInfo) + OBJECT_OFFSETOF(TypeInfo, m_type)), Imm32(ObjectType));
+
+ emitGetFromCallFrameHeaderPtr(RegisterFile::ReturnPC, regT2);
+ emitGetFromCallFrameHeaderPtr(RegisterFile::CallerFrame, callFrameRegister);
+
+ restoreReturnAddressBeforeReturn(regT2);
+ ret();
+
+ notJSCell.link(this);
+ notObject.link(this);
+ emitLoad(thisReg, regT1, regT0);
+
+ emitGetFromCallFrameHeaderPtr(RegisterFile::ReturnPC, regT2);
+ emitGetFromCallFrameHeaderPtr(RegisterFile::CallerFrame, callFrameRegister);
+
+ restoreReturnAddressBeforeReturn(regT2);
+ ret();
+}
+
+void JIT::emitSlow_op_call(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
+{
+ compileOpCallSlowCase(currentInstruction, iter, m_callLinkInfoIndex++, op_call);
+}
+
+void JIT::emitSlow_op_call_eval(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
+{
+ compileOpCallSlowCase(currentInstruction, iter, m_callLinkInfoIndex++, op_call_eval);
+}
+
+void JIT::emitSlow_op_call_varargs(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
+{
+ compileOpCallVarargsSlowCase(currentInstruction, iter);
+}
+
+void JIT::emitSlow_op_construct(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
+{
+ compileOpCallSlowCase(currentInstruction, iter, m_callLinkInfoIndex++, op_construct);
+}
+
+void JIT::emit_op_call(Instruction* currentInstruction)
+{
+ compileOpCall(op_call, currentInstruction, m_callLinkInfoIndex++);
+}
+
+void JIT::emit_op_call_eval(Instruction* currentInstruction)
+{
+ compileOpCall(op_call_eval, currentInstruction, m_callLinkInfoIndex++);
+}
+
+void JIT::emit_op_load_varargs(Instruction* currentInstruction)
+{
+ int argCountDst = currentInstruction[1].u.operand;
+ int argsOffset = currentInstruction[2].u.operand;
+
+ JITStubCall stubCall(this, cti_op_load_varargs);
+ stubCall.addArgument(Imm32(argsOffset));
+ stubCall.call();
+ // Stores a naked int32 in the register file.
+ store32(returnValueRegister, Address(callFrameRegister, argCountDst * sizeof(Register)));
+}
+
+void JIT::emit_op_call_varargs(Instruction* currentInstruction)
+{
+ compileOpCallVarargs(currentInstruction);
+}
+
+void JIT::emit_op_construct(Instruction* currentInstruction)
+{
+ compileOpCall(op_construct, currentInstruction, m_callLinkInfoIndex++);
+}
+
+#if !ENABLE(JIT_OPTIMIZE_CALL)
+
+/* ------------------------------ BEGIN: !ENABLE(JIT_OPTIMIZE_CALL) ------------------------------ */
+
+void JIT::compileOpCall(OpcodeID opcodeID, Instruction* instruction, unsigned)
+{
+ int callee = instruction[1].u.operand;
+ int argCount = instruction[2].u.operand;
+ int registerOffset = instruction[3].u.operand;
+
+ Jump wasEval;
+ if (opcodeID == op_call_eval) {
+ JITStubCall stubCall(this, cti_op_call_eval);
+ stubCall.addArgument(callee);
+ stubCall.addArgument(JIT::Imm32(registerOffset));
+ stubCall.addArgument(JIT::Imm32(argCount));
+ stubCall.call();
+ wasEval = branch32(NotEqual, regT1, Imm32(JSValue::EmptyValueTag));
+ }
+
+ emitLoad(callee, regT1, regT0);
+
+ if (opcodeID == op_call)
+ compileOpCallSetupArgs(instruction);
+ else if (opcodeID == op_construct)
+ compileOpConstructSetupArgs(instruction);
+
+ emitJumpSlowCaseIfNotJSCell(callee, regT1);
+ addSlowCase(branchPtr(NotEqual, Address(regT0), ImmPtr(m_globalData->jsFunctionVPtr)));
+
+ // First, in the case of a construct, allocate the new object.
+ if (opcodeID == op_construct) {
+ JITStubCall(this, cti_op_construct_JSConstruct).call(registerOffset - RegisterFile::CallFrameHeaderSize - argCount);
+ emitLoad(callee, regT1, regT0);
+ }
+
+ // Speculatively roll the callframe, assuming argCount will match the arity.
+ storePtr(callFrameRegister, Address(callFrameRegister, (RegisterFile::CallerFrame + registerOffset) * static_cast<int>(sizeof(Register))));
+ addPtr(Imm32(registerOffset * static_cast<int>(sizeof(Register))), callFrameRegister);
+ move(Imm32(argCount), regT1);
+
+ emitNakedCall(opcodeID == op_construct ? m_globalData->jitStubs.ctiVirtualConstruct() : m_globalData->jitStubs.ctiVirtualCall());
+
+ if (opcodeID == op_call_eval)
+ wasEval.link(this);
+
+ sampleCodeBlock(m_codeBlock);
+}
+
+void JIT::compileOpCallSlowCase(Instruction* instruction, Vector<SlowCaseEntry>::iterator& iter, unsigned, OpcodeID opcodeID)
+{
+ int callee = instruction[1].u.operand;
+
+ linkSlowCaseIfNotJSCell(iter, callee);
+ linkSlowCase(iter);
+
+ JITStubCall stubCall(this, opcodeID == op_construct ? cti_op_construct_NotJSConstruct : cti_op_call_NotJSFunction);
+ stubCall.call();
+
+ sampleCodeBlock(m_codeBlock);
+}
+
+#else // !ENABLE(JIT_OPTIMIZE_CALL)
+
+/* ------------------------------ BEGIN: ENABLE(JIT_OPTIMIZE_CALL) ------------------------------ */
+
+void JIT::compileOpCall(OpcodeID opcodeID, Instruction* instruction, unsigned callLinkInfoIndex)
+{
+ int callee = instruction[1].u.operand;
+ int argCount = instruction[2].u.operand;
+ int registerOffset = instruction[3].u.operand;
+
+ Jump wasEval;
+ if (opcodeID == op_call_eval) {
+ JITStubCall stubCall(this, cti_op_call_eval);
+ stubCall.addArgument(callee);
+ stubCall.addArgument(JIT::Imm32(registerOffset));
+ stubCall.addArgument(JIT::Imm32(argCount));
+ stubCall.call();
+ wasEval = branch32(NotEqual, regT1, Imm32(JSValue::EmptyValueTag));
+ }
+
+ emitLoad(callee, regT1, regT0);
+
+ DataLabelPtr addressOfLinkedFunctionCheck;
+
+ BEGIN_UNINTERRUPTED_SEQUENCE(sequenceOpCall);
+
+ Jump jumpToSlow = branchPtrWithPatch(NotEqual, regT0, addressOfLinkedFunctionCheck, ImmPtr(0));
+
+ END_UNINTERRUPTED_SEQUENCE(sequenceOpCall);
+
+ addSlowCase(jumpToSlow);
+ ASSERT(differenceBetween(addressOfLinkedFunctionCheck, jumpToSlow) == patchOffsetOpCallCompareToJump);
+ m_callStructureStubCompilationInfo[callLinkInfoIndex].hotPathBegin = addressOfLinkedFunctionCheck;
+
+ addSlowCase(branch32(NotEqual, regT1, Imm32(JSValue::CellTag)));
+
+ // The following is the fast case, only used whan a callee can be linked.
+
+ // In the case of OpConstruct, call out to a cti_ function to create the new object.
+ if (opcodeID == op_construct) {
+ int proto = instruction[4].u.operand;
+ int thisRegister = instruction[5].u.operand;
+
+ JITStubCall stubCall(this, cti_op_construct_JSConstruct);
+ stubCall.addArgument(regT1, regT0);
+ stubCall.addArgument(Imm32(0)); // FIXME: Remove this unused JITStub argument.
+ stubCall.addArgument(Imm32(0)); // FIXME: Remove this unused JITStub argument.
+ stubCall.addArgument(proto);
+ stubCall.call(thisRegister);
+
+ emitLoad(callee, regT1, regT0);
+ }
+
+ // Fast version of stack frame initialization, directly relative to edi.
+ // Note that this omits to set up RegisterFile::CodeBlock, which is set in the callee
+ loadPtr(Address(regT0, OBJECT_OFFSETOF(JSFunction, m_scopeChain) + OBJECT_OFFSETOF(ScopeChain, m_node)), regT2);
+
+ store32(Imm32(argCount), Address(callFrameRegister, (registerOffset + RegisterFile::ArgumentCount) * static_cast<int>(sizeof(Register))));
+ storePtr(callFrameRegister, Address(callFrameRegister, (registerOffset + RegisterFile::CallerFrame) * static_cast<int>(sizeof(Register))));
+ emitStore(registerOffset + RegisterFile::Callee, regT1, regT0);
+ storePtr(regT2, Address(callFrameRegister, (registerOffset + RegisterFile::ScopeChain) * static_cast<int>(sizeof(Register))));
+ addPtr(Imm32(registerOffset * sizeof(Register)), callFrameRegister);
+
+ // Call to the callee
+ m_callStructureStubCompilationInfo[callLinkInfoIndex].hotPathOther = emitNakedCall();
+
+ if (opcodeID == op_call_eval)
+ wasEval.link(this);
+
+ sampleCodeBlock(m_codeBlock);
+}
+
+void JIT::compileOpCallSlowCase(Instruction* instruction, Vector<SlowCaseEntry>::iterator& iter, unsigned callLinkInfoIndex, OpcodeID opcodeID)
+{
+ int callee = instruction[1].u.operand;
+ int argCount = instruction[2].u.operand;
+ int registerOffset = instruction[3].u.operand;
+
+ linkSlowCase(iter);
+ linkSlowCase(iter);
+
+ // The arguments have been set up on the hot path for op_call_eval
+ if (opcodeID == op_call)
+ compileOpCallSetupArgs(instruction);
+ else if (opcodeID == op_construct)
+ compileOpConstructSetupArgs(instruction);
+
+ // Fast check for JS function.
+ Jump callLinkFailNotObject = branch32(NotEqual, regT1, Imm32(JSValue::CellTag));
+ Jump callLinkFailNotJSFunction = branchPtr(NotEqual, Address(regT0), ImmPtr(m_globalData->jsFunctionVPtr));
+
+ // First, in the case of a construct, allocate the new object.
+ if (opcodeID == op_construct) {
+ JITStubCall(this, cti_op_construct_JSConstruct).call(registerOffset - RegisterFile::CallFrameHeaderSize - argCount);
+ emitLoad(callee, regT1, regT0);
+ }
+
+ // Speculatively roll the callframe, assuming argCount will match the arity.
+ storePtr(callFrameRegister, Address(callFrameRegister, (RegisterFile::CallerFrame + registerOffset) * static_cast<int>(sizeof(Register))));
+ addPtr(Imm32(registerOffset * static_cast<int>(sizeof(Register))), callFrameRegister);
+ move(Imm32(argCount), regT1);
+
+ m_callStructureStubCompilationInfo[callLinkInfoIndex].callReturnLocation = emitNakedCall(opcodeID == op_construct ? m_globalData->jitStubs.ctiVirtualConstructLink() : m_globalData->jitStubs.ctiVirtualCallLink());
+
+ // If not, we need an extra case in the if below!
+ ASSERT(OPCODE_LENGTH(op_call) == OPCODE_LENGTH(op_call_eval));
+
+ // Done! - return back to the hot path.
+ if (opcodeID == op_construct)
+ emitJumpSlowToHot(jump(), OPCODE_LENGTH(op_construct));
+ else
+ emitJumpSlowToHot(jump(), OPCODE_LENGTH(op_call));
+
+ // This handles host functions
+ callLinkFailNotObject.link(this);
+ callLinkFailNotJSFunction.link(this);
+ JITStubCall(this, opcodeID == op_construct ? cti_op_construct_NotJSConstruct : cti_op_call_NotJSFunction).call();
+
+ sampleCodeBlock(m_codeBlock);
+}
+
+/* ------------------------------ END: !ENABLE / ENABLE(JIT_OPTIMIZE_CALL) ------------------------------ */
+
+#endif // !ENABLE(JIT_OPTIMIZE_CALL)
+
+} // namespace JSC
+
+#endif // USE(JSVALUE32_64)
+#endif // ENABLE(JIT)
diff --git a/JavaScriptCore/jit/JITInlineMethods.h b/JavaScriptCore/jit/JITInlineMethods.h
index 148f615..89faa00 100644
--- a/JavaScriptCore/jit/JITInlineMethods.h
+++ b/JavaScriptCore/jit/JITInlineMethods.h
@@ -113,10 +113,10 @@ ALWAYS_INLINE void JIT::emitGetFromCallFrameHeader32(RegisterFile::CallFrameHead
ALWAYS_INLINE JIT::Call JIT::emitNakedCall(CodePtr function)
{
- ASSERT(m_bytecodeIndex != (unsigned)-1); // This method should only be called during hot/cold path generation, so that m_bytecodeIndex is set.
+ ASSERT(m_bytecodeOffset != (unsigned)-1); // This method should only be called during hot/cold path generation, so that m_bytecodeOffset is set.
Call nakedCall = nearCall();
- m_calls.append(CallRecord(nakedCall, m_bytecodeIndex, function.executableAddress()));
+ m_calls.append(CallRecord(nakedCall, m_bytecodeOffset, function.executableAddress()));
return nakedCall;
}
@@ -243,33 +243,33 @@ ALWAYS_INLINE void JIT::linkSlowCaseIfNotJSCell(Vector<SlowCaseEntry>::iterator&
ALWAYS_INLINE void JIT::addSlowCase(Jump jump)
{
- ASSERT(m_bytecodeIndex != (unsigned)-1); // This method should only be called during hot/cold path generation, so that m_bytecodeIndex is set.
+ ASSERT(m_bytecodeOffset != (unsigned)-1); // This method should only be called during hot/cold path generation, so that m_bytecodeOffset is set.
- m_slowCases.append(SlowCaseEntry(jump, m_bytecodeIndex));
+ m_slowCases.append(SlowCaseEntry(jump, m_bytecodeOffset));
}
ALWAYS_INLINE void JIT::addSlowCase(JumpList jumpList)
{
- ASSERT(m_bytecodeIndex != (unsigned)-1); // This method should only be called during hot/cold path generation, so that m_bytecodeIndex is set.
+ ASSERT(m_bytecodeOffset != (unsigned)-1); // This method should only be called during hot/cold path generation, so that m_bytecodeOffset is set.
const JumpList::JumpVector& jumpVector = jumpList.jumps();
size_t size = jumpVector.size();
for (size_t i = 0; i < size; ++i)
- m_slowCases.append(SlowCaseEntry(jumpVector[i], m_bytecodeIndex));
+ m_slowCases.append(SlowCaseEntry(jumpVector[i], m_bytecodeOffset));
}
ALWAYS_INLINE void JIT::addJump(Jump jump, int relativeOffset)
{
- ASSERT(m_bytecodeIndex != (unsigned)-1); // This method should only be called during hot/cold path generation, so that m_bytecodeIndex is set.
+ ASSERT(m_bytecodeOffset != (unsigned)-1); // This method should only be called during hot/cold path generation, so that m_bytecodeOffset is set.
- m_jmpTable.append(JumpTable(jump, m_bytecodeIndex + relativeOffset));
+ m_jmpTable.append(JumpTable(jump, m_bytecodeOffset + relativeOffset));
}
ALWAYS_INLINE void JIT::emitJumpSlowToHot(Jump jump, int relativeOffset)
{
- ASSERT(m_bytecodeIndex != (unsigned)-1); // This method should only be called during hot/cold path generation, so that m_bytecodeIndex is set.
+ ASSERT(m_bytecodeOffset != (unsigned)-1); // This method should only be called during hot/cold path generation, so that m_bytecodeOffset is set.
- jump.linkTo(m_labels[m_bytecodeIndex + relativeOffset], this);
+ jump.linkTo(m_labels[m_bytecodeOffset + relativeOffset], this);
}
#if ENABLE(SAMPLING_FLAGS)
@@ -485,24 +485,24 @@ ALWAYS_INLINE void JIT::emitInitRegister(unsigned dst)
emitStore(dst, jsUndefined());
}
-inline bool JIT::isLabeled(unsigned bytecodeIndex)
+inline bool JIT::isLabeled(unsigned bytecodeOffset)
{
for (size_t numberOfJumpTargets = m_codeBlock->numberOfJumpTargets(); m_jumpTargetIndex != numberOfJumpTargets; ++m_jumpTargetIndex) {
unsigned jumpTarget = m_codeBlock->jumpTarget(m_jumpTargetIndex);
- if (jumpTarget == bytecodeIndex)
+ if (jumpTarget == bytecodeOffset)
return true;
- if (jumpTarget > bytecodeIndex)
+ if (jumpTarget > bytecodeOffset)
return false;
}
return false;
}
-inline void JIT::map(unsigned bytecodeIndex, unsigned virtualRegisterIndex, RegisterID tag, RegisterID payload)
+inline void JIT::map(unsigned bytecodeOffset, unsigned virtualRegisterIndex, RegisterID tag, RegisterID payload)
{
- if (isLabeled(bytecodeIndex))
+ if (isLabeled(bytecodeOffset))
return;
- m_mappedBytecodeIndex = bytecodeIndex;
+ m_mappedBytecodeOffset = bytecodeOffset;
m_mappedVirtualRegisterIndex = virtualRegisterIndex;
m_mappedTag = tag;
m_mappedPayload = payload;
@@ -518,7 +518,7 @@ inline void JIT::unmap(RegisterID registerID)
inline void JIT::unmap()
{
- m_mappedBytecodeIndex = (unsigned)-1;
+ m_mappedBytecodeOffset = (unsigned)-1;
m_mappedVirtualRegisterIndex = (unsigned)-1;
m_mappedTag = (RegisterID)-1;
m_mappedPayload = (RegisterID)-1;
@@ -526,7 +526,7 @@ inline void JIT::unmap()
inline bool JIT::isMapped(unsigned virtualRegisterIndex)
{
- if (m_mappedBytecodeIndex != m_bytecodeIndex)
+ if (m_mappedBytecodeOffset != m_bytecodeOffset)
return false;
if (m_mappedVirtualRegisterIndex != virtualRegisterIndex)
return false;
@@ -535,7 +535,7 @@ inline bool JIT::isMapped(unsigned virtualRegisterIndex)
inline bool JIT::getMappedPayload(unsigned virtualRegisterIndex, RegisterID& payload)
{
- if (m_mappedBytecodeIndex != m_bytecodeIndex)
+ if (m_mappedBytecodeOffset != m_bytecodeOffset)
return false;
if (m_mappedVirtualRegisterIndex != virtualRegisterIndex)
return false;
@@ -547,7 +547,7 @@ inline bool JIT::getMappedPayload(unsigned virtualRegisterIndex, RegisterID& pay
inline bool JIT::getMappedTag(unsigned virtualRegisterIndex, RegisterID& tag)
{
- if (m_mappedBytecodeIndex != m_bytecodeIndex)
+ if (m_mappedBytecodeOffset != m_bytecodeOffset)
return false;
if (m_mappedVirtualRegisterIndex != virtualRegisterIndex)
return false;
@@ -559,14 +559,22 @@ inline bool JIT::getMappedTag(unsigned virtualRegisterIndex, RegisterID& tag)
inline void JIT::emitJumpSlowCaseIfNotJSCell(unsigned virtualRegisterIndex)
{
- if (!m_codeBlock->isKnownNotImmediate(virtualRegisterIndex))
- addSlowCase(emitJumpIfNotJSCell(virtualRegisterIndex));
+ if (!m_codeBlock->isKnownNotImmediate(virtualRegisterIndex)) {
+ if (m_codeBlock->isConstantRegisterIndex(virtualRegisterIndex))
+ addSlowCase(jump());
+ else
+ addSlowCase(emitJumpIfNotJSCell(virtualRegisterIndex));
+ }
}
inline void JIT::emitJumpSlowCaseIfNotJSCell(unsigned virtualRegisterIndex, RegisterID tag)
{
- if (!m_codeBlock->isKnownNotImmediate(virtualRegisterIndex))
- addSlowCase(branch32(NotEqual, tag, Imm32(JSValue::CellTag)));
+ if (!m_codeBlock->isKnownNotImmediate(virtualRegisterIndex)) {
+ if (m_codeBlock->isConstantRegisterIndex(virtualRegisterIndex))
+ addSlowCase(jump());
+ else
+ addSlowCase(branch32(NotEqual, tag, Imm32(JSValue::CellTag)));
+ }
}
inline void JIT::linkSlowCaseIfNotJSCell(Vector<SlowCaseEntry>::iterator& iter, unsigned virtualRegisterIndex)
@@ -632,7 +640,7 @@ ALWAYS_INLINE void JIT::killLastResultRegister()
// get arg puts an arg from the SF register array into a h/w register
ALWAYS_INLINE void JIT::emitGetVirtualRegister(int src, RegisterID dst)
{
- ASSERT(m_bytecodeIndex != (unsigned)-1); // This method should only be called during hot/cold path generation, so that m_bytecodeIndex is set.
+ ASSERT(m_bytecodeOffset != (unsigned)-1); // This method should only be called during hot/cold path generation, so that m_bytecodeOffset is set.
// TODO: we want to reuse values that are already in registers if we can - add a register allocator!
if (m_codeBlock->isConstantRegisterIndex(src)) {
@@ -644,8 +652,8 @@ ALWAYS_INLINE void JIT::emitGetVirtualRegister(int src, RegisterID dst)
if (src == m_lastResultBytecodeRegister && m_codeBlock->isTemporaryRegisterIndex(src)) {
bool atJumpTarget = false;
- while (m_jumpTargetsPosition < m_codeBlock->numberOfJumpTargets() && m_codeBlock->jumpTarget(m_jumpTargetsPosition) <= m_bytecodeIndex) {
- if (m_codeBlock->jumpTarget(m_jumpTargetsPosition) == m_bytecodeIndex)
+ while (m_jumpTargetsPosition < m_codeBlock->numberOfJumpTargets() && m_codeBlock->jumpTarget(m_jumpTargetsPosition) <= m_bytecodeOffset) {
+ if (m_codeBlock->jumpTarget(m_jumpTargetsPosition) == m_bytecodeOffset)
atJumpTarget = true;
++m_jumpTargetsPosition;
}
diff --git a/JavaScriptCore/jit/JITOpcodes.cpp b/JavaScriptCore/jit/JITOpcodes.cpp
index 9b0f780..f8be135 100644
--- a/JavaScriptCore/jit/JITOpcodes.cpp
+++ b/JavaScriptCore/jit/JITOpcodes.cpp
@@ -25,9 +25,8 @@
*/
#include "config.h"
-#include "JIT.h"
-
#if ENABLE(JIT)
+#include "JIT.h"
#include "JITInlineMethods.h"
#include "JITStubCall.h"
@@ -42,7 +41,7 @@ namespace JSC {
#if !USE(JSVALUE32_64)
#define RECORD_JUMP_TARGET(targetOffset) \
- do { m_labels[m_bytecodeIndex + (targetOffset)].used(); } while (false)
+ do { m_labels[m_bytecodeOffset + (targetOffset)].used(); } while (false)
void JIT::privateCompileCTIMachineTrampolines(RefPtr<ExecutablePool>* executablePool, JSGlobalData* globalData, TrampolineStructure *trampolines)
{
@@ -259,7 +258,8 @@ void JIT::privateCompileCTIMachineTrampolines(RefPtr<ExecutablePool>* executable
move(callFrameRegister, X86Registers::edi);
- call(Address(X86Registers::esi, OBJECT_OFFSETOF(JSFunction, m_data)));
+ loadPtr(Address(X86Registers::esi, OBJECT_OFFSETOF(JSFunction, m_executable)), X86Registers::r9);
+ call(Address(X86Registers::r9, OBJECT_OFFSETOF(NativeExecutable, m_function)));
addPtr(Imm32(sizeof(ArgList)), stackPointerRegister);
#elif CPU(X86)
@@ -337,7 +337,8 @@ void JIT::privateCompileCTIMachineTrampolines(RefPtr<ExecutablePool>* executable
// Plant callframe
move(callFrameRegister, X86Registers::edx);
- call(Address(X86Registers::eax, OBJECT_OFFSETOF(JSFunction, m_data)));
+ loadPtr(Address(X86Registers::eax, OBJECT_OFFSETOF(JSFunction, m_executable)), X86Registers::ebx);
+ call(Address(X86Registers::ebx, OBJECT_OFFSETOF(NativeExecutable, m_function)));
// JSValue is a non-POD type
loadPtr(Address(X86Registers::eax), X86Registers::eax);
@@ -347,7 +348,8 @@ void JIT::privateCompileCTIMachineTrampolines(RefPtr<ExecutablePool>* executable
// Plant callframe
move(callFrameRegister, X86Registers::ecx);
- call(Address(X86Registers::edx, OBJECT_OFFSETOF(JSFunction, m_data)));
+ loadPtr(Address(X86Registers::edx, OBJECT_OFFSETOF(JSFunction, m_executable)), X86Registers::ebx);
+ call(Address(X86Registers::ebx, OBJECT_OFFSETOF(NativeExecutable, m_function)));
#endif
// We've put a few temporaries on the stack in addition to the actual arguments
@@ -395,7 +397,8 @@ void JIT::privateCompileCTIMachineTrampolines(RefPtr<ExecutablePool>* executable
subPtr(Imm32(sizeof(Register)), stackPointerRegister);
storePtr(regT0, Address(stackPointerRegister));
- call(Address(regT2, OBJECT_OFFSETOF(JSFunction, m_data)));
+ loadPtr(Address(regT2, OBJECT_OFFSETOF(JSFunction, m_executable)), regT3);
+ call(Address(regT3, OBJECT_OFFSETOF(NativeExecutable, m_function)));
loadPtr(Address(regT0), regT0);
@@ -413,7 +416,8 @@ void JIT::privateCompileCTIMachineTrampolines(RefPtr<ExecutablePool>* executable
// Setup arg4: This is a plain hack
move(stackPointerRegister, ARMRegisters::r3);
- call(Address(regT1, OBJECT_OFFSETOF(JSFunction, m_data)));
+ loadPtr(Address(regT1, OBJECT_OFFSETOF(JSFunction, m_executable)), regT3);
+ call(Address(regT3, OBJECT_OFFSETOF(NativeExecutable, m_function)));
addPtr(Imm32(sizeof(ArgList)), stackPointerRegister);
#endif // OS(WINCE)
@@ -460,7 +464,8 @@ void JIT::privateCompileCTIMachineTrampolines(RefPtr<ExecutablePool>* executable
addPtr(Imm32(20), stackPointerRegister, MIPSRegisters::a0);
// Call
- call(Address(MIPSRegisters::a2, OBJECT_OFFSETOF(JSFunction, m_data)));
+ loadPtr(Address(MIPSRegisters::a2, OBJECT_OFFSETOF(JSFunction, m_executable)), regT2);
+ call(Address(regT2, OBJECT_OFFSETOF(NativeExecutable, m_function)));
// Get returned value from 0($v0) which is the same as 20($sp)
loadPtr(Address(returnValueRegister, 0), returnValueRegister);
@@ -535,7 +540,7 @@ void JIT::privateCompileCTIMachineTrampolines(RefPtr<ExecutablePool>* executable
trampolines->ctiVirtualConstructLink = trampolineAt(finalCode, virtualConstructLinkBegin);
trampolines->ctiVirtualCall = trampolineAt(finalCode, virtualCallBegin);
trampolines->ctiVirtualConstruct = trampolineAt(finalCode, virtualConstructBegin);
- trampolines->ctiNativeCallThunk = adoptRef(new NativeExecutable(JITCode(JITCode::HostFunction(trampolineAt(finalCode, nativeCallThunk)))));
+ trampolines->ctiNativeCall = trampolineAt(finalCode, nativeCallThunk);
#if ENABLE(JIT_OPTIMIZE_MOD)
trampolines->ctiSoftModulo = trampolineAt(finalCode, softModBegin);
#endif
@@ -544,6 +549,11 @@ void JIT::privateCompileCTIMachineTrampolines(RefPtr<ExecutablePool>* executable
#endif
}
+JIT::CodePtr JIT::privateCompileCTINativeCall(PassRefPtr<ExecutablePool>, JSGlobalData* globalData, NativeFunction)
+{
+ return globalData->jitStubs.ctiNativeCall();
+}
+
void JIT::emit_op_mov(Instruction* currentInstruction)
{
int dst = currentInstruction[1].u.operand;
@@ -711,7 +721,7 @@ void JIT::emit_op_put_global_var(Instruction* currentInstruction)
void JIT::emit_op_get_scoped_var(Instruction* currentInstruction)
{
- int skip = currentInstruction[3].u.operand + m_codeBlock->needsFullScopeChain();
+ int skip = currentInstruction[3].u.operand;
emitGetFromCallFrameHeaderPtr(RegisterFile::ScopeChain, regT0);
while (skip--)
@@ -724,7 +734,7 @@ void JIT::emit_op_get_scoped_var(Instruction* currentInstruction)
void JIT::emit_op_put_scoped_var(Instruction* currentInstruction)
{
- int skip = currentInstruction[2].u.operand + m_codeBlock->needsFullScopeChain();
+ int skip = currentInstruction[2].u.operand;
emitGetFromCallFrameHeaderPtr(RegisterFile::ScopeChain, regT1);
emitGetVirtualRegister(currentInstruction[3].u.operand, regT0);
@@ -739,12 +749,19 @@ void JIT::emit_op_tear_off_activation(Instruction* currentInstruction)
{
JITStubCall stubCall(this, cti_op_tear_off_activation);
stubCall.addArgument(currentInstruction[1].u.operand, regT2);
+ stubCall.addArgument(unmodifiedArgumentsRegister(currentInstruction[2].u.operand), regT2);
stubCall.call();
}
-void JIT::emit_op_tear_off_arguments(Instruction*)
+void JIT::emit_op_tear_off_arguments(Instruction* currentInstruction)
{
- JITStubCall(this, cti_op_tear_off_arguments).call();
+ unsigned dst = currentInstruction[1].u.operand;
+
+ Jump argsNotCreated = branchTestPtr(Zero, Address(callFrameRegister, sizeof(Register) * (unmodifiedArgumentsRegister(dst))));
+ JITStubCall stubCall(this, cti_op_tear_off_arguments);
+ stubCall.addArgument(unmodifiedArgumentsRegister(dst), regT2);
+ stubCall.call();
+ argsNotCreated.link(this);
}
void JIT::emit_op_ret(Instruction* currentInstruction)
@@ -771,6 +788,48 @@ void JIT::emit_op_ret(Instruction* currentInstruction)
ret();
}
+void JIT::emit_op_ret_object_or_this(Instruction* currentInstruction)
+{
+ // We could JIT generate the deref, only calling out to C when the refcount hits zero.
+ if (m_codeBlock->needsFullScopeChain())
+ JITStubCall(this, cti_op_ret_scopeChain).call();
+
+ ASSERT(callFrameRegister != regT1);
+ ASSERT(regT1 != returnValueRegister);
+ ASSERT(returnValueRegister != callFrameRegister);
+
+ // Return the result in %eax.
+ emitGetVirtualRegister(currentInstruction[1].u.operand, returnValueRegister);
+ Jump notJSCell = emitJumpIfNotJSCell(returnValueRegister);
+ loadPtr(Address(returnValueRegister, OBJECT_OFFSETOF(JSCell, m_structure)), regT2);
+ Jump notObject = branch8(NotEqual, Address(regT2, OBJECT_OFFSETOF(Structure, m_typeInfo) + OBJECT_OFFSETOF(TypeInfo, m_type)), Imm32(ObjectType));
+
+ // Grab the return address.
+ emitGetFromCallFrameHeaderPtr(RegisterFile::ReturnPC, regT1);
+
+ // Restore our caller's "r".
+ emitGetFromCallFrameHeaderPtr(RegisterFile::CallerFrame, callFrameRegister);
+
+ // Return.
+ restoreReturnAddressBeforeReturn(regT1);
+ ret();
+
+ // Return 'this' in %eax.
+ notJSCell.link(this);
+ notObject.link(this);
+ emitGetVirtualRegister(currentInstruction[2].u.operand, returnValueRegister);
+
+ // Grab the return address.
+ emitGetFromCallFrameHeaderPtr(RegisterFile::ReturnPC, regT1);
+
+ // Restore our caller's "r".
+ emitGetFromCallFrameHeaderPtr(RegisterFile::CallerFrame, callFrameRegister);
+
+ // Return.
+ restoreReturnAddressBeforeReturn(regT1);
+ ret();
+}
+
void JIT::emit_op_new_array(Instruction* currentInstruction)
{
JITStubCall stubCall(this, cti_op_new_array);
@@ -786,16 +845,6 @@ void JIT::emit_op_resolve(Instruction* currentInstruction)
stubCall.call(currentInstruction[1].u.operand);
}
-void JIT::emit_op_construct_verify(Instruction* currentInstruction)
-{
- emitGetVirtualRegister(currentInstruction[1].u.operand, regT0);
-
- emitJumpSlowCaseIfNotJSCell(regT0);
- loadPtr(Address(regT0, OBJECT_OFFSETOF(JSCell, m_structure)), regT2);
- addSlowCase(branch8(NotEqual, Address(regT2, OBJECT_OFFSETOF(Structure, m_typeInfo.m_type)), Imm32(ObjectType)));
-
-}
-
void JIT::emit_op_to_primitive(Instruction* currentInstruction)
{
int dst = currentInstruction[1].u.operand;
@@ -831,7 +880,7 @@ void JIT::emit_op_resolve_skip(Instruction* currentInstruction)
{
JITStubCall stubCall(this, cti_op_resolve_skip);
stubCall.addArgument(ImmPtr(&m_codeBlock->identifier(currentInstruction[2].u.operand)));
- stubCall.addArgument(Imm32(currentInstruction[3].u.operand + m_codeBlock->needsFullScopeChain()));
+ stubCall.addArgument(Imm32(currentInstruction[3].u.operand));
stubCall.call(currentInstruction[1].u.operand);
}
@@ -1266,7 +1315,7 @@ void JIT::emit_op_switch_imm(Instruction* currentInstruction)
// create jump table for switch destinations, track this switch statement.
SimpleJumpTable* jumpTable = &m_codeBlock->immediateSwitchJumpTable(tableIndex);
- m_switches.append(SwitchRecord(jumpTable, m_bytecodeIndex, defaultOffset, SwitchRecord::Immediate));
+ m_switches.append(SwitchRecord(jumpTable, m_bytecodeOffset, defaultOffset, SwitchRecord::Immediate));
jumpTable->ctiOffsets.grow(jumpTable->branchOffsets.size());
JITStubCall stubCall(this, cti_op_switch_imm);
@@ -1284,7 +1333,7 @@ void JIT::emit_op_switch_char(Instruction* currentInstruction)
// create jump table for switch destinations, track this switch statement.
SimpleJumpTable* jumpTable = &m_codeBlock->characterSwitchJumpTable(tableIndex);
- m_switches.append(SwitchRecord(jumpTable, m_bytecodeIndex, defaultOffset, SwitchRecord::Character));
+ m_switches.append(SwitchRecord(jumpTable, m_bytecodeOffset, defaultOffset, SwitchRecord::Character));
jumpTable->ctiOffsets.grow(jumpTable->branchOffsets.size());
JITStubCall stubCall(this, cti_op_switch_char);
@@ -1302,7 +1351,7 @@ void JIT::emit_op_switch_string(Instruction* currentInstruction)
// create jump table for switch destinations, track this switch statement.
StringJumpTable* jumpTable = &m_codeBlock->stringSwitchJumpTable(tableIndex);
- m_switches.append(SwitchRecord(jumpTable, m_bytecodeIndex, defaultOffset));
+ m_switches.append(SwitchRecord(jumpTable, m_bytecodeOffset, defaultOffset));
JITStubCall stubCall(this, cti_op_switch_string);
stubCall.addArgument(scrutinee, regT2);
@@ -1316,7 +1365,7 @@ void JIT::emit_op_new_error(Instruction* currentInstruction)
JITStubCall stubCall(this, cti_op_new_error);
stubCall.addArgument(Imm32(currentInstruction[2].u.operand));
stubCall.addArgument(ImmPtr(JSValue::encode(m_codeBlock->getConstant(currentInstruction[3].u.operand))));
- stubCall.addArgument(Imm32(m_bytecodeIndex));
+ stubCall.addArgument(Imm32(m_bytecodeOffset));
stubCall.call(currentInstruction[1].u.operand);
}
@@ -1407,19 +1456,26 @@ void JIT::emit_op_enter_with_activation(Instruction* currentInstruction)
JITStubCall(this, cti_op_push_activation).call(currentInstruction[1].u.operand);
}
-void JIT::emit_op_create_arguments(Instruction*)
+void JIT::emit_op_create_arguments(Instruction* currentInstruction)
{
- Jump argsCreated = branchTestPtr(NonZero, Address(callFrameRegister, sizeof(Register) * RegisterFile::ArgumentsRegister));
+ unsigned dst = currentInstruction[1].u.operand;
+
+ Jump argsCreated = branchTestPtr(NonZero, Address(callFrameRegister, sizeof(Register) * dst));
if (m_codeBlock->m_numParameters == 1)
JITStubCall(this, cti_op_create_arguments_no_params).call();
else
JITStubCall(this, cti_op_create_arguments).call();
+ emitPutVirtualRegister(dst);
+ emitPutVirtualRegister(unmodifiedArgumentsRegister(dst));
argsCreated.link(this);
}
-
-void JIT::emit_op_init_arguments(Instruction*)
+
+void JIT::emit_op_init_arguments(Instruction* currentInstruction)
{
- storePtr(ImmPtr(0), Address(callFrameRegister, sizeof(Register) * RegisterFile::ArgumentsRegister));
+ unsigned dst = currentInstruction[1].u.operand;
+
+ storePtr(ImmPtr(0), Address(callFrameRegister, sizeof(Register) * dst));
+ storePtr(ImmPtr(0), Address(callFrameRegister, sizeof(Register) * (unmodifiedArgumentsRegister(dst))));
}
void JIT::emit_op_convert_this(Instruction* currentInstruction)
@@ -1467,14 +1523,6 @@ void JIT::emitSlow_op_convert_this(Instruction* currentInstruction, Vector<SlowC
stubCall.call(currentInstruction[1].u.operand);
}
-void JIT::emitSlow_op_construct_verify(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
-{
- linkSlowCase(iter);
- linkSlowCase(iter);
- emitGetVirtualRegister(currentInstruction[2].u.operand, regT0);
- emitPutVirtualRegister(currentInstruction[1].u.operand);
-}
-
void JIT::emitSlow_op_to_primitive(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
{
linkSlowCase(iter);
@@ -1672,7 +1720,7 @@ void JIT::emitSlow_op_to_jsnumber(Instruction* currentInstruction, Vector<SlowCa
void JIT::emit_op_resolve_global_dynamic(Instruction* currentInstruction)
{
- int skip = currentInstruction[6].u.operand + m_codeBlock->needsFullScopeChain();
+ int skip = currentInstruction[6].u.operand;
emitGetFromCallFrameHeaderPtr(RegisterFile::ScopeChain, regT0);
while (skip--) {
@@ -1688,7 +1736,7 @@ void JIT::emitSlow_op_resolve_global_dynamic(Instruction* currentInstruction, Ve
unsigned dst = currentInstruction[1].u.operand;
void* globalObject = currentInstruction[2].u.jsCell;
Identifier* ident = &m_codeBlock->identifier(currentInstruction[3].u.operand);
- int skip = currentInstruction[6].u.operand + m_codeBlock->needsFullScopeChain();
+ int skip = currentInstruction[6].u.operand;
while (skip--)
linkSlowCase(iter);
JITStubCall resolveStubCall(this, cti_op_resolve);
diff --git a/JavaScriptCore/jit/JITOpcodes32_64.cpp b/JavaScriptCore/jit/JITOpcodes32_64.cpp
index d4edb92..b814801 100644
--- a/JavaScriptCore/jit/JITOpcodes32_64.cpp
+++ b/JavaScriptCore/jit/JITOpcodes32_64.cpp
@@ -25,9 +25,10 @@
*/
#include "config.h"
-#include "JIT.h"
-#if ENABLE(JIT) && USE(JSVALUE32_64)
+#if ENABLE(JIT)
+#if USE(JSVALUE32_64)
+#include "JIT.h"
#include "JITInlineMethods.h"
#include "JITStubCall.h"
@@ -309,14 +310,16 @@ void JIT::privateCompileCTIMachineTrampolines(RefPtr<ExecutablePool>* executable
// Plant callframe
move(callFrameRegister, X86Registers::edx);
- call(Address(X86Registers::eax, OBJECT_OFFSETOF(JSFunction, m_data)));
+ loadPtr(Address(X86Registers::eax, OBJECT_OFFSETOF(JSFunction, m_executable)), X86Registers::ebx);
+ call(Address(X86Registers::ebx, OBJECT_OFFSETOF(NativeExecutable, m_function)));
// JSValue is a non-POD type, so eax points to it
emitLoad(0, regT1, regT0, X86Registers::eax);
#else
emitGetFromCallFrameHeaderPtr(RegisterFile::Callee, X86Registers::edx); // callee
move(callFrameRegister, X86Registers::ecx); // callFrame
- call(Address(X86Registers::edx, OBJECT_OFFSETOF(JSFunction, m_data)));
+ loadPtr(Address(X86Registers::edx, OBJECT_OFFSETOF(JSFunction, m_executable)), X86Registers::ebx);
+ call(Address(X86Registers::ebx, OBJECT_OFFSETOF(NativeExecutable, m_function)));
#endif
// We've put a few temporaries on the stack in addition to the actual arguments
@@ -373,7 +376,8 @@ void JIT::privateCompileCTIMachineTrampolines(RefPtr<ExecutablePool>* executable
// Setup arg0:
move(stackPointerRegister, regT0);
- call(Address(regT2, OBJECT_OFFSETOF(JSFunction, m_data)));
+ loadPtr(Address(regT2, OBJECT_OFFSETOF(JSFunction, m_executable)), regT3);
+ call(Address(regT3, OBJECT_OFFSETOF(NativeExecutable, m_function)));
load32(Address(stackPointerRegister, 0), regT0);
load32(Address(stackPointerRegister, 4), regT1);
@@ -401,7 +405,8 @@ void JIT::privateCompileCTIMachineTrampolines(RefPtr<ExecutablePool>* executable
// Setup arg1:
move(callFrameRegister, regT1);
- call(Address(regT2, OBJECT_OFFSETOF(JSFunction, m_data)));
+ loadPtr(Address(regT2, OBJECT_OFFSETOF(JSFunction, m_executable)), regT3);
+ call(Address(regT3, OBJECT_OFFSETOF(NativeExecutable, m_function)));
// Load return value
load32(Address(stackPointerRegister, 16), regT0);
@@ -476,7 +481,7 @@ void JIT::privateCompileCTIMachineTrampolines(RefPtr<ExecutablePool>* executable
trampolines->ctiVirtualCall = trampolineAt(finalCode, virtualCallBegin);
trampolines->ctiVirtualConstruct = trampolineAt(finalCode, virtualConstructBegin);
- trampolines->ctiNativeCallThunk = adoptRef(new NativeExecutable(JITCode(JITCode::HostFunction(trampolineAt(finalCode, nativeCallThunk)))));
+ trampolines->ctiNativeCall = trampolineAt(finalCode, nativeCallThunk);
#if ENABLE(JIT_OPTIMIZE_PROPERTY_ACCESS)
trampolines->ctiStringLengthTrampoline = trampolineAt(finalCode, stringLengthBegin);
#endif
@@ -489,6 +494,251 @@ void JIT::privateCompileCTIMachineTrampolines(RefPtr<ExecutablePool>* executable
#endif
}
+JIT::CodePtr JIT::privateCompileCTINativeCall(PassRefPtr<ExecutablePool> executablePool, JSGlobalData* globalData, NativeFunction func)
+{
+#if CPU(X86) || CPU(ARM_TRADITIONAL)
+ Label nativeCallThunk = align();
+ preserveReturnAddressAfterCall(regT0);
+ emitPutToCallFrameHeader(regT0, RegisterFile::ReturnPC); // Push return address
+
+ // Load caller frame's scope chain into this callframe so that whatever we call can
+ // get to its global data.
+ emitGetFromCallFrameHeaderPtr(RegisterFile::CallerFrame, regT1);
+ emitGetFromCallFrameHeaderPtr(RegisterFile::ScopeChain, regT1, regT1);
+ emitPutToCallFrameHeader(regT1, RegisterFile::ScopeChain);
+
+#if CPU(X86)
+ emitGetFromCallFrameHeader32(RegisterFile::ArgumentCount, regT0);
+
+ /* We have two structs that we use to describe the stackframe we set up for our
+ * call to native code. NativeCallFrameStructure describes the how we set up the stack
+ * in advance of the call. NativeFunctionCalleeSignature describes the callframe
+ * as the native code expects it. We do this as we are using the fastcall calling
+ * convention which results in the callee popping its arguments off the stack, but
+ * not the rest of the callframe so we need a nice way to ensure we increment the
+ * stack pointer by the right amount after the call.
+ */
+
+#if COMPILER(MSVC) || OS(LINUX)
+#if COMPILER(MSVC)
+#pragma pack(push)
+#pragma pack(4)
+#endif // COMPILER(MSVC)
+ struct NativeCallFrameStructure {
+ // CallFrame* callFrame; // passed in EDX
+ JSObject* callee;
+ JSValue thisValue;
+ ArgList* argPointer;
+ ArgList args;
+ JSValue result;
+ };
+ struct NativeFunctionCalleeSignature {
+ JSObject* callee;
+ JSValue thisValue;
+ ArgList* argPointer;
+ };
+#if COMPILER(MSVC)
+#pragma pack(pop)
+#endif // COMPILER(MSVC)
+#else
+ struct NativeCallFrameStructure {
+ // CallFrame* callFrame; // passed in ECX
+ // JSObject* callee; // passed in EDX
+ JSValue thisValue;
+ ArgList* argPointer;
+ ArgList args;
+ };
+ struct NativeFunctionCalleeSignature {
+ JSValue thisValue;
+ ArgList* argPointer;
+ };
+#endif
+
+ const int NativeCallFrameSize = (sizeof(NativeCallFrameStructure) + 15) & ~15;
+ // Allocate system stack frame
+ subPtr(Imm32(NativeCallFrameSize), stackPointerRegister);
+
+ // Set up arguments
+ subPtr(Imm32(1), regT0); // Don't include 'this' in argcount
+
+ // push argcount
+ storePtr(regT0, Address(stackPointerRegister, OBJECT_OFFSETOF(NativeCallFrameStructure, args) + OBJECT_OFFSETOF(ArgList, m_argCount)));
+
+ // Calculate the start of the callframe header, and store in regT1
+ addPtr(Imm32(-RegisterFile::CallFrameHeaderSize * (int)sizeof(Register)), callFrameRegister, regT1);
+
+ // Calculate start of arguments as callframe header - sizeof(Register) * argcount (regT0)
+ mul32(Imm32(sizeof(Register)), regT0, regT0);
+ subPtr(regT0, regT1);
+ storePtr(regT1, Address(stackPointerRegister, OBJECT_OFFSETOF(NativeCallFrameStructure, args) + OBJECT_OFFSETOF(ArgList, m_args)));
+
+ // ArgList is passed by reference so is stackPointerRegister + 4 * sizeof(Register)
+ addPtr(Imm32(OBJECT_OFFSETOF(NativeCallFrameStructure, args)), stackPointerRegister, regT0);
+ storePtr(regT0, Address(stackPointerRegister, OBJECT_OFFSETOF(NativeCallFrameStructure, argPointer)));
+
+ // regT1 currently points to the first argument, regT1 - sizeof(Register) points to 'this'
+ loadPtr(Address(regT1, -(int)sizeof(Register) + OBJECT_OFFSETOF(JSValue, u.asBits.payload)), regT2);
+ loadPtr(Address(regT1, -(int)sizeof(Register) + OBJECT_OFFSETOF(JSValue, u.asBits.tag)), regT3);
+ storePtr(regT2, Address(stackPointerRegister, OBJECT_OFFSETOF(NativeCallFrameStructure, thisValue) + OBJECT_OFFSETOF(JSValue, u.asBits.payload)));
+ storePtr(regT3, Address(stackPointerRegister, OBJECT_OFFSETOF(NativeCallFrameStructure, thisValue) + OBJECT_OFFSETOF(JSValue, u.asBits.tag)));
+
+#if COMPILER(MSVC) || OS(LINUX)
+ // ArgList is passed by reference so is stackPointerRegister + 4 * sizeof(Register)
+ addPtr(Imm32(OBJECT_OFFSETOF(NativeCallFrameStructure, result)), stackPointerRegister, X86Registers::ecx);
+
+ // Plant callee
+ emitGetFromCallFrameHeaderPtr(RegisterFile::Callee, X86Registers::eax);
+ storePtr(X86Registers::eax, Address(stackPointerRegister, OBJECT_OFFSETOF(NativeCallFrameStructure, callee)));
+
+ // Plant callframe
+ move(callFrameRegister, X86Registers::edx);
+
+ Call nativeCall = call();
+
+ // JSValue is a non-POD type, so eax points to it
+ emitLoad(0, regT1, regT0, X86Registers::eax);
+#else
+ emitGetFromCallFrameHeaderPtr(RegisterFile::Callee, X86Registers::edx); // callee
+ move(callFrameRegister, X86Registers::ecx); // callFrame
+ Call nativeCall = call();
+#endif
+
+ // We've put a few temporaries on the stack in addition to the actual arguments
+ // so pull them off now
+ addPtr(Imm32(NativeCallFrameSize - sizeof(NativeFunctionCalleeSignature)), stackPointerRegister);
+
+#elif CPU(ARM_TRADITIONAL)
+ emitGetFromCallFrameHeader32(RegisterFile::ArgumentCount, regT0);
+
+ // Allocate stack space for our arglist
+ COMPILE_ASSERT((sizeof(ArgList) & 0x7) == 0 && sizeof(JSValue) == 8 && sizeof(Register) == 8, ArgList_should_by_8byte_aligned);
+ subPtr(Imm32(sizeof(ArgList)), stackPointerRegister);
+
+ // Set up arguments
+ subPtr(Imm32(1), regT0); // Don't include 'this' in argcount
+
+ // Push argcount
+ storePtr(regT0, Address(stackPointerRegister, OBJECT_OFFSETOF(ArgList, m_argCount)));
+
+ // Calculate the start of the callframe header, and store in regT1
+ move(callFrameRegister, regT1);
+ sub32(Imm32(RegisterFile::CallFrameHeaderSize * (int32_t)sizeof(Register)), regT1);
+
+ // Calculate start of arguments as callframe header - sizeof(Register) * argcount (regT1)
+ mul32(Imm32(sizeof(Register)), regT0, regT0);
+ subPtr(regT0, regT1);
+
+ // push pointer to arguments
+ storePtr(regT1, Address(stackPointerRegister, OBJECT_OFFSETOF(ArgList, m_args)));
+
+ // Argument passing method:
+ // r0 - points to return value
+ // r1 - callFrame
+ // r2 - callee
+ // stack: this(JSValue) and a pointer to ArgList
+
+#if OS(WINCE)
+ // Setup arg4:
+ push(stackPointerRegister);
+
+ // Setup arg3:
+ // regT1 currently points to the first argument, regT1-sizeof(Register) points to 'this'
+ load32(Address(regT1, -(int32_t)sizeof(void*) * 2), ARMRegisters::r3);
+ push(ARMRegisters::r3);
+ load32(Address(regT1, -(int32_t)sizeof(void*)), regT3);
+ storePtr(regT3, Address(stackPointerRegister));
+
+ // Setup arg2:
+ emitGetFromCallFrameHeaderPtr(RegisterFile::Callee, regT2);
+
+ // Setup arg1:
+ move(callFrameRegister, regT1);
+
+ // Setup arg0:
+ move(stackPointerRegister, regT0);
+
+ Call nativeCall = call();
+
+ load32(Address(stackPointerRegister, 0), regT0);
+ load32(Address(stackPointerRegister, 4), regT1);
+
+ addPtr(Imm32(sizeof(ArgList) + 8), stackPointerRegister);
+#else // OS(WINCE)
+ move(stackPointerRegister, regT3);
+ subPtr(Imm32(8), stackPointerRegister);
+ move(stackPointerRegister, regT0);
+ subPtr(Imm32(8 + 4 + 4 /* padding */), stackPointerRegister);
+
+ // Setup arg4:
+ storePtr(regT3, Address(stackPointerRegister, 8));
+
+ // Setup arg3:
+ // regT1 currently points to the first argument, regT1-sizeof(Register) points to 'this'
+ load32(Address(regT1, -(int32_t)sizeof(void*) * 2), regT3);
+ storePtr(regT3, Address(stackPointerRegister, 0));
+ load32(Address(regT1, -(int32_t)sizeof(void*)), regT3);
+ storePtr(regT3, Address(stackPointerRegister, 4));
+
+ // Setup arg2:
+ emitGetFromCallFrameHeaderPtr(RegisterFile::Callee, regT2);
+
+ // Setup arg1:
+ move(callFrameRegister, regT1);
+
+ Call nativeCall = call();
+
+ // Load return value
+ load32(Address(stackPointerRegister, 16), regT0);
+ load32(Address(stackPointerRegister, 20), regT1);
+
+ addPtr(Imm32(sizeof(ArgList) + 16 + 8), stackPointerRegister);
+#endif // OS(WINCE)
+
+#endif
+
+ // Check for an exception
+ move(ImmPtr(&globalData->exception), regT2);
+ Jump sawException = branch32(NotEqual, tagFor(0, regT2), Imm32(JSValue::EmptyValueTag));
+
+ // Grab the return address.
+ emitGetFromCallFrameHeaderPtr(RegisterFile::ReturnPC, regT3);
+
+ // Restore our caller's "r".
+ emitGetFromCallFrameHeaderPtr(RegisterFile::CallerFrame, callFrameRegister);
+
+ // Return.
+ restoreReturnAddressBeforeReturn(regT3);
+ ret();
+
+ // Handle an exception
+ sawException.link(this);
+ // Grab the return address.
+ emitGetFromCallFrameHeaderPtr(RegisterFile::ReturnPC, regT1);
+ move(ImmPtr(&globalData->exceptionLocation), regT2);
+ storePtr(regT1, regT2);
+ move(ImmPtr(FunctionPtr(ctiVMThrowTrampoline).value()), regT2);
+ emitGetFromCallFrameHeaderPtr(RegisterFile::CallerFrame, callFrameRegister);
+ poke(callFrameRegister, OBJECT_OFFSETOF(struct JITStackFrame, callFrame) / sizeof(void*));
+ restoreReturnAddressBeforeReturn(regT2);
+ ret();
+
+#elif ENABLE(JIT_OPTIMIZE_NATIVE_CALL)
+#error "JIT_OPTIMIZE_NATIVE_CALL not yet supported on this platform."
+#else
+ breakpoint();
+#endif
+
+ // All trampolines constructed! copy the code, link up calls, and set the pointers on the Machine object.
+ LinkBuffer patchBuffer(this, executablePool);
+
+#if ENABLE(JIT_OPTIMIZE_NATIVE_CALL)
+ patchBuffer.link(nativeCall, FunctionPtr(func));
+#endif
+
+ CodeRef finalCode = patchBuffer.finalizeCode();
+ return trampolineAt(finalCode, nativeCallThunk);
+}
+
void JIT::emit_op_mov(Instruction* currentInstruction)
{
unsigned dst = currentInstruction[1].u.operand;
@@ -499,7 +749,7 @@ void JIT::emit_op_mov(Instruction* currentInstruction)
else {
emitLoad(src, regT1, regT0);
emitStore(dst, regT1, regT0);
- map(m_bytecodeIndex + OPCODE_LENGTH(op_mov), dst, regT1, regT0);
+ map(m_bytecodeOffset + OPCODE_LENGTH(op_mov), dst, regT1, regT0);
}
}
@@ -649,7 +899,7 @@ void JIT::emit_op_get_global_var(Instruction* currentInstruction)
emitLoad(index, regT1, regT0, regT2);
emitStore(dst, regT1, regT0);
- map(m_bytecodeIndex + OPCODE_LENGTH(op_get_global_var), dst, regT1, regT0);
+ map(m_bytecodeOffset + OPCODE_LENGTH(op_get_global_var), dst, regT1, regT0);
}
void JIT::emit_op_put_global_var(Instruction* currentInstruction)
@@ -663,14 +913,14 @@ void JIT::emit_op_put_global_var(Instruction* currentInstruction)
loadPtr(&globalObject->d()->registers, regT2);
emitStore(index, regT1, regT0, regT2);
- map(m_bytecodeIndex + OPCODE_LENGTH(op_put_global_var), value, regT1, regT0);
+ map(m_bytecodeOffset + OPCODE_LENGTH(op_put_global_var), value, regT1, regT0);
}
void JIT::emit_op_get_scoped_var(Instruction* currentInstruction)
{
int dst = currentInstruction[1].u.operand;
int index = currentInstruction[2].u.operand;
- int skip = currentInstruction[3].u.operand + m_codeBlock->needsFullScopeChain();
+ int skip = currentInstruction[3].u.operand;
emitGetFromCallFrameHeaderPtr(RegisterFile::ScopeChain, regT2);
while (skip--)
@@ -682,13 +932,13 @@ void JIT::emit_op_get_scoped_var(Instruction* currentInstruction)
emitLoad(index, regT1, regT0, regT2);
emitStore(dst, regT1, regT0);
- map(m_bytecodeIndex + OPCODE_LENGTH(op_get_scoped_var), dst, regT1, regT0);
+ map(m_bytecodeOffset + OPCODE_LENGTH(op_get_scoped_var), dst, regT1, regT0);
}
void JIT::emit_op_put_scoped_var(Instruction* currentInstruction)
{
int index = currentInstruction[1].u.operand;
- int skip = currentInstruction[2].u.operand + m_codeBlock->needsFullScopeChain();
+ int skip = currentInstruction[2].u.operand;
int value = currentInstruction[3].u.operand;
emitLoad(value, regT1, regT0);
@@ -702,19 +952,26 @@ void JIT::emit_op_put_scoped_var(Instruction* currentInstruction)
loadPtr(Address(regT2, OBJECT_OFFSETOF(JSVariableObject::JSVariableObjectData, registers)), regT2);
emitStore(index, regT1, regT0, regT2);
- map(m_bytecodeIndex + OPCODE_LENGTH(op_put_scoped_var), value, regT1, regT0);
+ map(m_bytecodeOffset + OPCODE_LENGTH(op_put_scoped_var), value, regT1, regT0);
}
void JIT::emit_op_tear_off_activation(Instruction* currentInstruction)
{
JITStubCall stubCall(this, cti_op_tear_off_activation);
stubCall.addArgument(currentInstruction[1].u.operand);
+ stubCall.addArgument(unmodifiedArgumentsRegister(currentInstruction[2].u.operand));
stubCall.call();
}
-void JIT::emit_op_tear_off_arguments(Instruction*)
+void JIT::emit_op_tear_off_arguments(Instruction* currentInstruction)
{
- JITStubCall(this, cti_op_tear_off_arguments).call();
+ int dst = currentInstruction[1].u.operand;
+
+ Jump argsNotCreated = branch32(Equal, tagFor(unmodifiedArgumentsRegister(dst)), Imm32(JSValue::EmptyValueTag));
+ JITStubCall stubCall(this, cti_op_tear_off_arguments);
+ stubCall.addArgument(unmodifiedArgumentsRegister(dst));
+ stubCall.call();
+ argsNotCreated.link(this);
}
void JIT::emit_op_new_array(Instruction* currentInstruction)
@@ -745,7 +1002,7 @@ void JIT::emit_op_to_primitive(Instruction* currentInstruction)
if (dst != src)
emitStore(dst, regT1, regT0);
- map(m_bytecodeIndex + OPCODE_LENGTH(op_to_primitive), dst, regT1, regT0);
+ map(m_bytecodeOffset + OPCODE_LENGTH(op_to_primitive), dst, regT1, regT0);
}
void JIT::emitSlow_op_to_primitive(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
@@ -778,7 +1035,7 @@ void JIT::emit_op_resolve_skip(Instruction* currentInstruction)
{
JITStubCall stubCall(this, cti_op_resolve_skip);
stubCall.addArgument(ImmPtr(&m_codeBlock->identifier(currentInstruction[2].u.operand)));
- stubCall.addArgument(Imm32(currentInstruction[3].u.operand + m_codeBlock->needsFullScopeChain()));
+ stubCall.addArgument(Imm32(currentInstruction[3].u.operand));
stubCall.call(currentInstruction[1].u.operand);
}
@@ -804,7 +1061,7 @@ void JIT::emit_op_resolve_global(Instruction* currentInstruction, bool dynamic)
load32(BaseIndex(regT2, regT3, TimesEight), regT0); // payload
load32(BaseIndex(regT2, regT3, TimesEight, 4), regT1); // tag
emitStore(dst, regT1, regT0);
- map(m_bytecodeIndex + dynamic ? OPCODE_LENGTH(op_resolve_global_dynamic) : OPCODE_LENGTH(op_resolve_global), dst, regT1, regT0);
+ map(m_bytecodeOffset + dynamic ? OPCODE_LENGTH(op_resolve_global_dynamic) : OPCODE_LENGTH(op_resolve_global), dst, regT1, regT0);
}
void JIT::emitSlow_op_resolve_global(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
@@ -1390,7 +1647,7 @@ void JIT::emit_op_to_jsnumber(Instruction* currentInstruction)
if (src != dst)
emitStore(dst, regT1, regT0);
- map(m_bytecodeIndex + OPCODE_LENGTH(op_to_jsnumber), dst, regT1, regT0);
+ map(m_bytecodeOffset + OPCODE_LENGTH(op_to_jsnumber), dst, regT1, regT0);
}
void JIT::emitSlow_op_to_jsnumber(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
@@ -1424,7 +1681,7 @@ void JIT::emit_op_catch(Instruction* currentInstruction)
// Now store the exception returned by cti_op_throw.
emitStore(exception, regT1, regT0);
- map(m_bytecodeIndex + OPCODE_LENGTH(op_catch), exception, regT1, regT0);
+ map(m_bytecodeOffset + OPCODE_LENGTH(op_catch), exception, regT1, regT0);
}
void JIT::emit_op_jmp_scopes(Instruction* currentInstruction)
@@ -1443,7 +1700,7 @@ void JIT::emit_op_switch_imm(Instruction* currentInstruction)
// create jump table for switch destinations, track this switch statement.
SimpleJumpTable* jumpTable = &m_codeBlock->immediateSwitchJumpTable(tableIndex);
- m_switches.append(SwitchRecord(jumpTable, m_bytecodeIndex, defaultOffset, SwitchRecord::Immediate));
+ m_switches.append(SwitchRecord(jumpTable, m_bytecodeOffset, defaultOffset, SwitchRecord::Immediate));
jumpTable->ctiOffsets.grow(jumpTable->branchOffsets.size());
JITStubCall stubCall(this, cti_op_switch_imm);
@@ -1461,7 +1718,7 @@ void JIT::emit_op_switch_char(Instruction* currentInstruction)
// create jump table for switch destinations, track this switch statement.
SimpleJumpTable* jumpTable = &m_codeBlock->characterSwitchJumpTable(tableIndex);
- m_switches.append(SwitchRecord(jumpTable, m_bytecodeIndex, defaultOffset, SwitchRecord::Character));
+ m_switches.append(SwitchRecord(jumpTable, m_bytecodeOffset, defaultOffset, SwitchRecord::Character));
jumpTable->ctiOffsets.grow(jumpTable->branchOffsets.size());
JITStubCall stubCall(this, cti_op_switch_char);
@@ -1479,7 +1736,7 @@ void JIT::emit_op_switch_string(Instruction* currentInstruction)
// create jump table for switch destinations, track this switch statement.
StringJumpTable* jumpTable = &m_codeBlock->stringSwitchJumpTable(tableIndex);
- m_switches.append(SwitchRecord(jumpTable, m_bytecodeIndex, defaultOffset));
+ m_switches.append(SwitchRecord(jumpTable, m_bytecodeOffset, defaultOffset));
JITStubCall stubCall(this, cti_op_switch_string);
stubCall.addArgument(scrutinee);
@@ -1497,7 +1754,7 @@ void JIT::emit_op_new_error(Instruction* currentInstruction)
JITStubCall stubCall(this, cti_op_new_error);
stubCall.addArgument(Imm32(type));
stubCall.addArgument(m_codeBlock->getConstant(message));
- stubCall.addArgument(Imm32(m_bytecodeIndex));
+ stubCall.addArgument(Imm32(m_bytecodeOffset));
stubCall.call(dst);
}
@@ -1532,22 +1789,29 @@ void JIT::emit_op_enter_with_activation(Instruction* currentInstruction)
JITStubCall(this, cti_op_push_activation).call(currentInstruction[1].u.operand);
}
-void JIT::emit_op_create_arguments(Instruction*)
+void JIT::emit_op_create_arguments(Instruction* currentInstruction)
{
- Jump argsCreated = branch32(NotEqual, tagFor(RegisterFile::ArgumentsRegister, callFrameRegister), Imm32(JSValue::EmptyValueTag));
+ unsigned dst = currentInstruction[1].u.operand;
+
+ Jump argsCreated = branch32(NotEqual, tagFor(dst), Imm32(JSValue::EmptyValueTag));
- // If we get here the arguments pointer is a null cell - i.e. arguments need lazy creation.
if (m_codeBlock->m_numParameters == 1)
JITStubCall(this, cti_op_create_arguments_no_params).call();
else
JITStubCall(this, cti_op_create_arguments).call();
+ emitStore(dst, regT1, regT0);
+ emitStore(unmodifiedArgumentsRegister(dst), regT1, regT0);
+
argsCreated.link(this);
}
-void JIT::emit_op_init_arguments(Instruction*)
+void JIT::emit_op_init_arguments(Instruction* currentInstruction)
{
- emitStore(RegisterFile::ArgumentsRegister, JSValue(), callFrameRegister);
+ unsigned dst = currentInstruction[1].u.operand;
+
+ emitStore(dst, JSValue());
+ emitStore(unmodifiedArgumentsRegister(dst), JSValue());
}
void JIT::emit_op_convert_this(Instruction* currentInstruction)
@@ -1561,7 +1825,7 @@ void JIT::emit_op_convert_this(Instruction* currentInstruction)
loadPtr(Address(regT0, OBJECT_OFFSETOF(JSCell, m_structure)), regT2);
addSlowCase(branchTest8(NonZero, Address(regT2, OBJECT_OFFSETOF(Structure, m_typeInfo.m_flags)), Imm32(NeedsThisConversion)));
- map(m_bytecodeIndex + OPCODE_LENGTH(op_convert_this), thisRegister, regT1, regT0);
+ map(m_bytecodeOffset + OPCODE_LENGTH(op_convert_this), thisRegister, regT1, regT0);
}
void JIT::emitSlow_op_convert_this(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
@@ -1598,6 +1862,7 @@ void JIT::emit_op_profile_did_call(Instruction* currentInstruction)
noProfiler.link(this);
}
-}
+} // namespace JSC
-#endif // ENABLE(JIT) && USE(JSVALUE32_64)
+#endif // USE(JSVALUE32_64)
+#endif // ENABLE(JIT)
diff --git a/JavaScriptCore/jit/JITPropertyAccess.cpp b/JavaScriptCore/jit/JITPropertyAccess.cpp
index 399afdd..4d36cfa 100644
--- a/JavaScriptCore/jit/JITPropertyAccess.cpp
+++ b/JavaScriptCore/jit/JITPropertyAccess.cpp
@@ -25,12 +25,10 @@
#include "config.h"
+#if ENABLE(JIT)
#if !USE(JSVALUE32_64)
-
#include "JIT.h"
-#if ENABLE(JIT)
-
#include "CodeBlock.h"
#include "GetterSetter.h"
#include "JITInlineMethods.h"
@@ -52,7 +50,7 @@ using namespace std;
namespace JSC {
-PassRefPtr<NativeExecutable> JIT::stringGetByValStubGenerator(JSGlobalData* globalData, ExecutablePool* pool)
+JIT::CodePtr JIT::stringGetByValStubGenerator(JSGlobalData* globalData, ExecutablePool* pool)
{
JSInterfaceJIT jit;
JumpList failures;
@@ -80,7 +78,7 @@ PassRefPtr<NativeExecutable> JIT::stringGetByValStubGenerator(JSGlobalData* glob
jit.ret();
LinkBuffer patchBuffer(&jit, pool);
- return adoptRef(new NativeExecutable(patchBuffer.finalizeCode()));
+ return patchBuffer.finalizeCode().m_code;
}
void JIT::emit_op_get_by_val(Instruction* currentInstruction)
@@ -125,7 +123,7 @@ void JIT::emitSlow_op_get_by_val(Instruction* currentInstruction, Vector<SlowCas
Jump nonCell = jump();
linkSlowCase(iter); // base array check
Jump notString = branchPtr(NotEqual, Address(regT0), ImmPtr(m_globalData->jsStringVPtr));
- emitNakedCall(m_globalData->getThunk(stringGetByValStubGenerator)->generatedJITCodeForCall().addressForCall());
+ emitNakedCall(m_globalData->getCTIStub(stringGetByValStubGenerator));
Jump failed = branchTestPtr(Zero, regT0);
emitPutVirtualRegister(dst, regT0);
emitJumpSlowToHot(jump(), OPCODE_LENGTH(op_get_by_val));
@@ -380,7 +378,7 @@ void JIT::emit_op_method_check(Instruction* currentInstruction)
emitPutVirtualRegister(resultVReg);
// We've already generated the following get_by_id, so make sure it's skipped over.
- m_bytecodeIndex += OPCODE_LENGTH(op_get_by_id);
+ m_bytecodeOffset += OPCODE_LENGTH(op_get_by_id);
}
void JIT::emitSlow_op_method_check(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
@@ -393,7 +391,7 @@ void JIT::emitSlow_op_method_check(Instruction* currentInstruction, Vector<SlowC
compileGetByIdSlowCase(resultVReg, baseVReg, ident, iter, true);
// We've already generated the following get_by_id, so make sure it's skipped over.
- m_bytecodeIndex += OPCODE_LENGTH(op_get_by_id);
+ m_bytecodeOffset += OPCODE_LENGTH(op_get_by_id);
}
#else //!ENABLE(JIT_OPTIMIZE_METHOD_CALLS)
@@ -1112,6 +1110,5 @@ void JIT::privateCompileGetByIdChain(StructureStubInfo* stubInfo, Structure* str
} // namespace JSC
-#endif // ENABLE(JIT)
-
#endif // !USE(JSVALUE32_64)
+#endif // ENABLE(JIT)
diff --git a/JavaScriptCore/jit/JITPropertyAccess32_64.cpp b/JavaScriptCore/jit/JITPropertyAccess32_64.cpp
index 792583b..6b8af7c 100644
--- a/JavaScriptCore/jit/JITPropertyAccess32_64.cpp
+++ b/JavaScriptCore/jit/JITPropertyAccess32_64.cpp
@@ -25,12 +25,10 @@
#include "config.h"
+#if ENABLE(JIT)
#if USE(JSVALUE32_64)
-
#include "JIT.h"
-#if ENABLE(JIT)
-
#include "CodeBlock.h"
#include "JITInlineMethods.h"
#include "JITStubCall.h"
@@ -241,10 +239,10 @@ void JIT::emit_op_method_check(Instruction* currentInstruction)
match.link(this);
emitStore(dst, regT1, regT0);
- map(m_bytecodeIndex + OPCODE_LENGTH(op_method_check), dst, regT1, regT0);
+ map(m_bytecodeOffset + OPCODE_LENGTH(op_method_check), dst, regT1, regT0);
// We've already generated the following get_by_id, so make sure it's skipped over.
- m_bytecodeIndex += OPCODE_LENGTH(op_get_by_id);
+ m_bytecodeOffset += OPCODE_LENGTH(op_get_by_id);
}
void JIT::emitSlow_op_method_check(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
@@ -258,7 +256,7 @@ void JIT::emitSlow_op_method_check(Instruction* currentInstruction, Vector<SlowC
compileGetByIdSlowCase(dst, base, &(m_codeBlock->identifier(ident)), iter, true);
// We've already generated the following get_by_id, so make sure it's skipped over.
- m_bytecodeIndex += OPCODE_LENGTH(op_get_by_id);
+ m_bytecodeOffset += OPCODE_LENGTH(op_get_by_id);
}
#else //!ENABLE(JIT_OPTIMIZE_METHOD_CALLS)
@@ -269,7 +267,7 @@ void JIT::emitSlow_op_method_check(Instruction*, Vector<SlowCaseEntry>::iterator
#endif
-PassRefPtr<NativeExecutable> JIT::stringGetByValStubGenerator(JSGlobalData* globalData, ExecutablePool* pool)
+JIT::CodePtr JIT::stringGetByValStubGenerator(JSGlobalData* globalData, ExecutablePool* pool)
{
JSInterfaceJIT jit;
JumpList failures;
@@ -298,7 +296,7 @@ PassRefPtr<NativeExecutable> JIT::stringGetByValStubGenerator(JSGlobalData* glob
jit.ret();
LinkBuffer patchBuffer(&jit, pool);
- return adoptRef(new NativeExecutable(patchBuffer.finalizeCode()));
+ return patchBuffer.finalizeCode().m_code;
}
void JIT::emit_op_get_by_val(Instruction* currentInstruction)
@@ -321,7 +319,7 @@ void JIT::emit_op_get_by_val(Instruction* currentInstruction)
addSlowCase(branch32(Equal, regT1, Imm32(JSValue::EmptyValueTag)));
emitStore(dst, regT1, regT0);
- map(m_bytecodeIndex + OPCODE_LENGTH(op_get_by_val), dst, regT1, regT0);
+ map(m_bytecodeOffset + OPCODE_LENGTH(op_get_by_val), dst, regT1, regT0);
}
void JIT::emitSlow_op_get_by_val(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
@@ -336,7 +334,7 @@ void JIT::emitSlow_op_get_by_val(Instruction* currentInstruction, Vector<SlowCas
Jump nonCell = jump();
linkSlowCase(iter); // base array check
Jump notString = branchPtr(NotEqual, Address(regT0), ImmPtr(m_globalData->jsStringVPtr));
- emitNakedCall(m_globalData->getThunk(stringGetByValStubGenerator)->generatedJITCodeForCall().addressForCall());
+ emitNakedCall(m_globalData->getCTIStub(stringGetByValStubGenerator));
Jump failed = branchTestPtr(Zero, regT0);
emitStore(dst, regT1, regT0);
emitJumpSlowToHot(jump(), OPCODE_LENGTH(op_get_by_val));
@@ -414,7 +412,7 @@ void JIT::emit_op_get_by_id(Instruction* currentInstruction)
emitJumpSlowCaseIfNotJSCell(base, regT1);
compileGetByIdHotPath();
emitStore(dst, regT1, regT0);
- map(m_bytecodeIndex + OPCODE_LENGTH(op_get_by_id), dst, regT1, regT0);
+ map(m_bytecodeOffset + OPCODE_LENGTH(op_get_by_id), dst, regT1, regT0);
}
void JIT::compileGetByIdHotPath()
@@ -1159,7 +1157,7 @@ void JIT::emit_op_get_by_pname(Instruction* currentInstruction)
compileGetDirectOffset(regT2, regT1, regT0, regT0, regT3);
emitStore(dst, regT1, regT0);
- map(m_bytecodeIndex + OPCODE_LENGTH(op_get_by_pname), dst, regT1, regT0);
+ map(m_bytecodeOffset + OPCODE_LENGTH(op_get_by_pname), dst, regT1, regT0);
}
void JIT::emitSlow_op_get_by_pname(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
@@ -1182,7 +1180,5 @@ void JIT::emitSlow_op_get_by_pname(Instruction* currentInstruction, Vector<SlowC
} // namespace JSC
+#endif // USE(JSVALUE32_64)
#endif // ENABLE(JIT)
-
-#endif // ENABLE(JSVALUE32_64)
-
diff --git a/JavaScriptCore/jit/JITStubCall.h b/JavaScriptCore/jit/JITStubCall.h
index 70d2893..4478d06 100644
--- a/JavaScriptCore/jit/JITStubCall.h
+++ b/JavaScriptCore/jit/JITStubCall.h
@@ -167,17 +167,17 @@ namespace JSC {
JIT::Call call()
{
#if ENABLE(OPCODE_SAMPLING)
- if (m_jit->m_bytecodeIndex != (unsigned)-1)
- m_jit->sampleInstruction(m_jit->m_codeBlock->instructions().begin() + m_jit->m_bytecodeIndex, true);
+ if (m_jit->m_bytecodeOffset != (unsigned)-1)
+ m_jit->sampleInstruction(m_jit->m_codeBlock->instructions().begin() + m_jit->m_bytecodeOffset, true);
#endif
m_jit->restoreArgumentReference();
JIT::Call call = m_jit->call();
- m_jit->m_calls.append(CallRecord(call, m_jit->m_bytecodeIndex, m_stub.value()));
+ m_jit->m_calls.append(CallRecord(call, m_jit->m_bytecodeOffset, m_stub.value()));
#if ENABLE(OPCODE_SAMPLING)
- if (m_jit->m_bytecodeIndex != (unsigned)-1)
- m_jit->sampleInstruction(m_jit->m_codeBlock->instructions().begin() + m_jit->m_bytecodeIndex, false);
+ if (m_jit->m_bytecodeOffset != (unsigned)-1)
+ m_jit->sampleInstruction(m_jit->m_codeBlock->instructions().begin() + m_jit->m_bytecodeOffset, false);
#endif
#if USE(JSVALUE32_64)
diff --git a/JavaScriptCore/jit/JITStubs.cpp b/JavaScriptCore/jit/JITStubs.cpp
index 3d1c272..aea80a7 100644
--- a/JavaScriptCore/jit/JITStubs.cpp
+++ b/JavaScriptCore/jit/JITStubs.cpp
@@ -28,9 +28,9 @@
*/
#include "config.h"
-#include "JITStubs.h"
#if ENABLE(JIT)
+#include "JITStubs.h"
#include "Arguments.h"
#include "CallFrame.h"
@@ -113,7 +113,7 @@ COMPILE_ASSERT(offsetof(struct JITStackFrame, savedEBX) == 0x3c, JITStackFrame_s
COMPILE_ASSERT(offsetof(struct JITStackFrame, callFrame) == 0x58, JITStackFrame_callFrame_offset_matches_ctiTrampoline);
COMPILE_ASSERT(offsetof(struct JITStackFrame, code) == 0x50, JITStackFrame_code_offset_matches_ctiTrampoline);
-asm volatile (
+asm (
".text\n"
".globl " SYMBOL_STRING(ctiTrampoline) "\n"
HIDE_SYMBOL(ctiTrampoline) "\n"
@@ -135,7 +135,7 @@ SYMBOL_STRING(ctiTrampoline) ":" "\n"
"ret" "\n"
);
-asm volatile (
+asm (
".globl " SYMBOL_STRING(ctiVMThrowTrampoline) "\n"
HIDE_SYMBOL(ctiVMThrowTrampoline) "\n"
SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n"
@@ -151,7 +151,7 @@ SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n"
"ret" "\n"
);
-asm volatile (
+asm (
".globl " SYMBOL_STRING(ctiOpThrowNotCaught) "\n"
HIDE_SYMBOL(ctiOpThrowNotCaught) "\n"
SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n"
@@ -176,7 +176,7 @@ COMPILE_ASSERT(offsetof(struct JITStackFrame, savedRBX) == 0x48, JITStackFrame_s
COMPILE_ASSERT(offsetof(struct JITStackFrame, callFrame) == 0x90, JITStackFrame_callFrame_offset_matches_ctiTrampoline);
COMPILE_ASSERT(offsetof(struct JITStackFrame, code) == 0x80, JITStackFrame_code_offset_matches_ctiTrampoline);
-asm volatile (
+asm (
".globl " SYMBOL_STRING(ctiTrampoline) "\n"
HIDE_SYMBOL(ctiTrampoline) "\n"
SYMBOL_STRING(ctiTrampoline) ":" "\n"
@@ -203,7 +203,7 @@ SYMBOL_STRING(ctiTrampoline) ":" "\n"
"ret" "\n"
);
-asm volatile (
+asm (
".globl " SYMBOL_STRING(ctiVMThrowTrampoline) "\n"
HIDE_SYMBOL(ctiVMThrowTrampoline) "\n"
SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n"
@@ -219,7 +219,7 @@ SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n"
"ret" "\n"
);
-asm volatile (
+asm (
".globl " SYMBOL_STRING(ctiOpThrowNotCaught) "\n"
HIDE_SYMBOL(ctiOpThrowNotCaught) "\n"
SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n"
@@ -332,7 +332,7 @@ COMPILE_ASSERT(offsetof(struct JITStackFrame, callFrame) == 0x38, JITStackFrame_
COMPILE_ASSERT(offsetof(struct JITStackFrame, code) == 0x30, JITStackFrame_code_offset_matches_ctiTrampoline);
COMPILE_ASSERT(offsetof(struct JITStackFrame, savedEBX) == 0x1c, JITStackFrame_stub_argument_space_matches_ctiTrampoline);
-asm volatile (
+asm (
".text\n"
".globl " SYMBOL_STRING(ctiTrampoline) "\n"
HIDE_SYMBOL(ctiTrampoline) "\n"
@@ -354,7 +354,7 @@ SYMBOL_STRING(ctiTrampoline) ":" "\n"
"ret" "\n"
);
-asm volatile (
+asm (
".globl " SYMBOL_STRING(ctiVMThrowTrampoline) "\n"
HIDE_SYMBOL(ctiVMThrowTrampoline) "\n"
SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n"
@@ -370,7 +370,7 @@ SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n"
"ret" "\n"
);
-asm volatile (
+asm (
".globl " SYMBOL_STRING(ctiOpThrowNotCaught) "\n"
HIDE_SYMBOL(ctiOpThrowNotCaught) "\n"
SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n"
@@ -394,7 +394,7 @@ COMPILE_ASSERT(offsetof(struct JITStackFrame, callFrame) == 0x58, JITStackFrame_
COMPILE_ASSERT(offsetof(struct JITStackFrame, code) == 0x48, JITStackFrame_code_offset_matches_ctiTrampoline);
COMPILE_ASSERT(offsetof(struct JITStackFrame, savedRBX) == 0x78, JITStackFrame_stub_argument_space_matches_ctiTrampoline);
-asm volatile (
+asm (
".text\n"
".globl " SYMBOL_STRING(ctiTrampoline) "\n"
HIDE_SYMBOL(ctiTrampoline) "\n"
@@ -429,7 +429,7 @@ SYMBOL_STRING(ctiTrampoline) ":" "\n"
"ret" "\n"
);
-asm volatile (
+asm (
".globl " SYMBOL_STRING(ctiVMThrowTrampoline) "\n"
HIDE_SYMBOL(ctiVMThrowTrampoline) "\n"
SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n"
@@ -445,7 +445,7 @@ SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n"
"ret" "\n"
);
-asm volatile (
+asm (
".globl " SYMBOL_STRING(ctiOpThrowNotCaught) "\n"
HIDE_SYMBOL(ctiOpThrowNotCaught) "\n"
SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n"
@@ -1082,7 +1082,7 @@ static NEVER_INLINE void throwStackOverflowError(CallFrame* callFrame, JSGlobalD
extern "C" { \
rtype JITStubThunked_##op(STUB_ARGS_DECLARATION); \
}; \
- asm volatile ( \
+ asm ( \
".text" "\n" \
".align 2" "\n" \
".globl " SYMBOL_STRING(cti_##op) "\n" \
@@ -1162,7 +1162,7 @@ static NEVER_INLINE void throwStackOverflowError(CallFrame* callFrame, JSGlobalD
extern "C" { \
rtype JITStubThunked_##op(STUB_ARGS_DECLARATION); \
}; \
- asm volatile ( \
+ asm ( \
".globl " SYMBOL_STRING(cti_##op) "\n" \
SYMBOL_STRING(cti_##op) ":" "\n" \
"str lr, [sp, #" STRINGIZE_VALUE_OF(THUNK_RETURN_ADDRESS_OFFSET) "]" "\n" \
@@ -1717,7 +1717,7 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, op_instanceof)
if (!baseVal.isObject() || !(typeInfo = asObject(baseVal)->structure()->typeInfo()).implementsHasInstance()) {
CallFrame* callFrame = stackFrame.callFrame;
CodeBlock* codeBlock = callFrame->codeBlock();
- unsigned vPCIndex = codeBlock->getBytecodeIndex(callFrame, STUB_RETURN_ADDRESS);
+ unsigned vPCIndex = codeBlock->bytecodeOffset(callFrame, STUB_RETURN_ADDRESS);
stackFrame.globalData->exception = createInvalidParamError(callFrame, "instanceof", baseVal, vPCIndex, codeBlock);
VM_THROW_EXCEPTION();
}
@@ -2002,27 +2002,25 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, op_call_NotJSFunction)
CallFrame* callFrame = stackFrame.callFrame;
CodeBlock* codeBlock = callFrame->codeBlock();
- unsigned vPCIndex = codeBlock->getBytecodeIndex(callFrame, STUB_RETURN_ADDRESS);
+ unsigned vPCIndex = codeBlock->bytecodeOffset(callFrame, STUB_RETURN_ADDRESS);
stackFrame.globalData->exception = createNotAFunctionError(stackFrame.callFrame, funcVal, vPCIndex, codeBlock);
VM_THROW_EXCEPTION();
}
-DEFINE_STUB_FUNCTION(void, op_create_arguments)
+DEFINE_STUB_FUNCTION(EncodedJSValue, op_create_arguments)
{
STUB_INIT_STACK_FRAME(stackFrame);
Arguments* arguments = new (stackFrame.globalData) Arguments(stackFrame.callFrame);
- stackFrame.callFrame->setCalleeArguments(arguments);
- stackFrame.callFrame[RegisterFile::ArgumentsRegister] = JSValue(arguments);
+ return JSValue::encode(JSValue(arguments));
}
-DEFINE_STUB_FUNCTION(void, op_create_arguments_no_params)
+DEFINE_STUB_FUNCTION(EncodedJSValue, op_create_arguments_no_params)
{
STUB_INIT_STACK_FRAME(stackFrame);
Arguments* arguments = new (stackFrame.globalData) Arguments(stackFrame.callFrame, Arguments::NoParameters);
- stackFrame.callFrame->setCalleeArguments(arguments);
- stackFrame.callFrame[RegisterFile::ArgumentsRegister] = JSValue(arguments);
+ return JSValue::encode(JSValue(arguments));
}
DEFINE_STUB_FUNCTION(void, op_tear_off_activation)
@@ -2030,7 +2028,10 @@ DEFINE_STUB_FUNCTION(void, op_tear_off_activation)
STUB_INIT_STACK_FRAME(stackFrame);
ASSERT(stackFrame.callFrame->codeBlock()->needsFullScopeChain());
- asActivation(stackFrame.args[0].jsValue())->copyRegisters(stackFrame.callFrame->optionalCalleeArguments());
+ JSActivation* activation = asActivation(stackFrame.args[0].jsValue());
+ activation->copyRegisters();
+ if (JSValue v = stackFrame.args[1].jsValue())
+ asArguments(v)->setActivation(activation);
}
DEFINE_STUB_FUNCTION(void, op_tear_off_arguments)
@@ -2038,8 +2039,7 @@ DEFINE_STUB_FUNCTION(void, op_tear_off_arguments)
STUB_INIT_STACK_FRAME(stackFrame);
ASSERT(stackFrame.callFrame->codeBlock()->usesArguments() && !stackFrame.callFrame->codeBlock()->needsFullScopeChain());
- if (stackFrame.callFrame->optionalCalleeArguments())
- stackFrame.callFrame->optionalCalleeArguments()->copyRegisters();
+ asArguments(stackFrame.args[0].jsValue())->copyRegisters();
}
DEFINE_STUB_FUNCTION(void, op_profile_will_call)
@@ -2097,7 +2097,7 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, op_resolve)
} while (++iter != end);
CodeBlock* codeBlock = callFrame->codeBlock();
- unsigned vPCIndex = codeBlock->getBytecodeIndex(callFrame, STUB_RETURN_ADDRESS);
+ unsigned vPCIndex = codeBlock->bytecodeOffset(callFrame, STUB_RETURN_ADDRESS);
stackFrame.globalData->exception = createUndefinedVariableError(callFrame, ident, vPCIndex, codeBlock);
VM_THROW_EXCEPTION();
}
@@ -2110,7 +2110,7 @@ DEFINE_STUB_FUNCTION(JSObject*, op_construct_JSConstruct)
if (constructor->isHostFunction()) {
CallFrame* callFrame = stackFrame.callFrame;
CodeBlock* codeBlock = callFrame->codeBlock();
- unsigned vPCIndex = codeBlock->getBytecodeIndex(callFrame, STUB_RETURN_ADDRESS);
+ unsigned vPCIndex = codeBlock->bytecodeOffset(callFrame, STUB_RETURN_ADDRESS);
stackFrame.globalData->exception = createNotAConstructorError(callFrame, constructor, vPCIndex, codeBlock);
VM_THROW_EXCEPTION();
}
@@ -2157,7 +2157,7 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, op_construct_NotJSConstruct)
ASSERT(constructType == ConstructTypeNone);
CodeBlock* codeBlock = callFrame->codeBlock();
- unsigned vPCIndex = codeBlock->getBytecodeIndex(callFrame, STUB_RETURN_ADDRESS);
+ unsigned vPCIndex = codeBlock->bytecodeOffset(callFrame, STUB_RETURN_ADDRESS);
stackFrame.globalData->exception = createNotAConstructorError(callFrame, constrVal, vPCIndex, codeBlock);
VM_THROW_EXCEPTION();
}
@@ -2175,6 +2175,8 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, op_get_by_val)
if (LIKELY(baseValue.isCell() && subscript.isString())) {
Identifier propertyName(callFrame, asString(subscript)->value(callFrame));
PropertySlot slot(asCell(baseValue));
+ // JSString::value may have thrown, but we shouldn't find a property with a null identifier,
+ // so we should miss this case and wind up in the CHECK_FOR_EXCEPTION_AT_END, below.
if (asCell(baseValue)->fastGetOwnPropertySlot(callFrame, propertyName, slot)) {
JSValue result = slot.getValue(callFrame, propertyName);
CHECK_FOR_EXCEPTION();
@@ -2426,7 +2428,7 @@ DEFINE_STUB_FUNCTION(int, op_load_varargs)
} else if (!arguments.isUndefinedOrNull()) {
if (!arguments.isObject()) {
CodeBlock* codeBlock = callFrame->codeBlock();
- unsigned vPCIndex = codeBlock->getBytecodeIndex(callFrame, STUB_RETURN_ADDRESS);
+ unsigned vPCIndex = codeBlock->bytecodeOffset(callFrame, STUB_RETURN_ADDRESS);
stackFrame.globalData->exception = createInvalidParamError(callFrame, "Function.prototype.apply", arguments, vPCIndex, codeBlock);
VM_THROW_EXCEPTION();
}
@@ -2466,7 +2468,7 @@ DEFINE_STUB_FUNCTION(int, op_load_varargs)
}
} else {
CodeBlock* codeBlock = callFrame->codeBlock();
- unsigned vPCIndex = codeBlock->getBytecodeIndex(callFrame, STUB_RETURN_ADDRESS);
+ unsigned vPCIndex = codeBlock->bytecodeOffset(callFrame, STUB_RETURN_ADDRESS);
stackFrame.globalData->exception = createInvalidParamError(callFrame, "Function.prototype.apply", arguments, vPCIndex, codeBlock);
VM_THROW_EXCEPTION();
}
@@ -2526,7 +2528,7 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, op_resolve_skip)
} while (++iter != end);
CodeBlock* codeBlock = callFrame->codeBlock();
- unsigned vPCIndex = codeBlock->getBytecodeIndex(callFrame, STUB_RETURN_ADDRESS);
+ unsigned vPCIndex = codeBlock->bytecodeOffset(callFrame, STUB_RETURN_ADDRESS);
stackFrame.globalData->exception = createUndefinedVariableError(callFrame, ident, vPCIndex, codeBlock);
VM_THROW_EXCEPTION();
}
@@ -2558,7 +2560,7 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, op_resolve_global)
return JSValue::encode(result);
}
- unsigned vPCIndex = callFrame->codeBlock()->getBytecodeIndex(callFrame, STUB_RETURN_ADDRESS);
+ unsigned vPCIndex = callFrame->codeBlock()->bytecodeOffset(callFrame, STUB_RETURN_ADDRESS);
stackFrame.globalData->exception = createUndefinedVariableError(callFrame, ident, vPCIndex, callFrame->codeBlock());
VM_THROW_EXCEPTION();
}
@@ -2860,7 +2862,7 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, op_resolve_with_base)
} while (iter != end);
CodeBlock* codeBlock = callFrame->codeBlock();
- unsigned vPCIndex = codeBlock->getBytecodeIndex(callFrame, STUB_RETURN_ADDRESS);
+ unsigned vPCIndex = codeBlock->bytecodeOffset(callFrame, STUB_RETURN_ADDRESS);
stackFrame.globalData->exception = createUndefinedVariableError(callFrame, ident, vPCIndex, codeBlock);
VM_THROW_EXCEPTION_AT_END();
return JSValue::encode(JSValue());
@@ -2959,7 +2961,7 @@ DEFINE_STUB_FUNCTION(JSObject*, op_new_regexp)
{
STUB_INIT_STACK_FRAME(stackFrame);
- return new (stackFrame.globalData) RegExpObject(stackFrame.callFrame->lexicalGlobalObject()->regExpStructure(), stackFrame.args[0].regExp());
+ return new (stackFrame.globalData) RegExpObject(stackFrame.callFrame->lexicalGlobalObject(), stackFrame.callFrame->lexicalGlobalObject()->regExpStructure(), stackFrame.args[0].regExp());
}
DEFINE_STUB_FUNCTION(EncodedJSValue, op_bitor)
@@ -3014,7 +3016,7 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, op_throw)
CallFrame* callFrame = stackFrame.callFrame;
CodeBlock* codeBlock = callFrame->codeBlock();
- unsigned vPCIndex = codeBlock->getBytecodeIndex(callFrame, STUB_RETURN_ADDRESS);
+ unsigned vPCIndex = codeBlock->bytecodeOffset(callFrame, STUB_RETURN_ADDRESS);
JSValue exceptionValue = stackFrame.args[0].jsValue();
ASSERT(exceptionValue);
@@ -3053,7 +3055,9 @@ DEFINE_STUB_FUNCTION(int, has_property)
JSObject* base = stackFrame.args[0].jsObject();
JSString* property = stackFrame.args[1].jsString();
- return base->hasProperty(stackFrame.callFrame, Identifier(stackFrame.callFrame, property->value(stackFrame.callFrame)));
+ int result = base->hasProperty(stackFrame.callFrame, Identifier(stackFrame.callFrame, property->value(stackFrame.callFrame)));
+ CHECK_FOR_EXCEPTION_AT_END();
+ return result;
}
DEFINE_STUB_FUNCTION(JSObject*, op_push_scope)
@@ -3130,7 +3134,9 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, op_stricteq)
JSValue src1 = stackFrame.args[0].jsValue();
JSValue src2 = stackFrame.args[1].jsValue();
- return JSValue::encode(jsBoolean(JSValue::strictEqual(stackFrame.callFrame, src1, src2)));
+ bool result = JSValue::strictEqual(stackFrame.callFrame, src1, src2);
+ CHECK_FOR_EXCEPTION_AT_END();
+ return JSValue::encode(jsBoolean(result));
}
DEFINE_STUB_FUNCTION(EncodedJSValue, op_to_primitive)
@@ -3156,7 +3162,9 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, op_nstricteq)
JSValue src1 = stackFrame.args[0].jsValue();
JSValue src2 = stackFrame.args[1].jsValue();
- return JSValue::encode(jsBoolean(!JSValue::strictEqual(stackFrame.callFrame, src1, src2)));
+ bool result = !JSValue::strictEqual(stackFrame.callFrame, src1, src2);
+ CHECK_FOR_EXCEPTION_AT_END();
+ return JSValue::encode(jsBoolean(result));
}
DEFINE_STUB_FUNCTION(EncodedJSValue, op_to_jsnumber)
@@ -3181,7 +3189,7 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, op_in)
if (!baseVal.isObject()) {
CallFrame* callFrame = stackFrame.callFrame;
CodeBlock* codeBlock = callFrame->codeBlock();
- unsigned vPCIndex = codeBlock->getBytecodeIndex(callFrame, STUB_RETURN_ADDRESS);
+ unsigned vPCIndex = codeBlock->bytecodeOffset(callFrame, STUB_RETURN_ADDRESS);
stackFrame.globalData->exception = createInvalidParamError(callFrame, "in", baseVal, vPCIndex, codeBlock);
VM_THROW_EXCEPTION();
}
@@ -3270,6 +3278,7 @@ DEFINE_STUB_FUNCTION(void*, op_switch_char)
result = codeBlock->characterSwitchJumpTable(tableIndex).ctiForValue(value->characters()[0]).executableAddress();
}
+ CHECK_FOR_EXCEPTION_AT_END();
return result;
}
@@ -3289,6 +3298,7 @@ DEFINE_STUB_FUNCTION(void*, op_switch_string)
result = codeBlock->stringSwitchJumpTable(tableIndex).ctiForValue(value).executableAddress();
}
+ CHECK_FOR_EXCEPTION_AT_END();
return result;
}
@@ -3376,7 +3386,7 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, vm_throw)
CodeBlock* codeBlock = callFrame->codeBlock();
JSGlobalData* globalData = stackFrame.globalData;
- unsigned vPCIndex = codeBlock->getBytecodeIndex(callFrame, globalData->exceptionLocation);
+ unsigned vPCIndex = codeBlock->bytecodeOffset(callFrame, globalData->exceptionLocation);
JSValue exceptionValue = globalData->exception;
ASSERT(exceptionValue);
@@ -3404,13 +3414,28 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, to_object)
return JSValue::encode(stackFrame.args[0].jsValue().toObject(callFrame));
}
-NativeExecutable* JITThunks::specializedThunk(JSGlobalData* globalData, ThunkGenerator generator)
+MacroAssemblerCodePtr JITThunks::ctiStub(JSGlobalData* globalData, ThunkGenerator generator)
+{
+ std::pair<CTIStubMap::iterator, bool> entry = m_ctiStubMap.add(generator, MacroAssemblerCodePtr());
+ if (entry.second)
+ entry.first->second = generator(globalData, m_executablePool.get());
+ return entry.first->second;
+}
+
+PassRefPtr<NativeExecutable> JITThunks::hostFunctionStub(JSGlobalData* globalData, NativeFunction function)
+{
+ std::pair<HostFunctionStubMap::iterator, bool> entry = m_hostFunctionStubMap.add(function, 0);
+ if (entry.second)
+ entry.first->second = NativeExecutable::create(JIT::compileCTINativeCall(globalData, m_executablePool, function), function);
+ return entry.first->second;
+}
+
+PassRefPtr<NativeExecutable> JITThunks::hostFunctionStub(JSGlobalData* globalData, NativeFunction function, ThunkGenerator generator)
{
- std::pair<ThunkMap::iterator, bool> entry = m_thunkMap.add(generator, 0);
- if (!entry.second)
- return entry.first->second.get();
- entry.first->second = generator(globalData, m_executablePool.get());
- return entry.first->second.get();
+ std::pair<HostFunctionStubMap::iterator, bool> entry = m_hostFunctionStubMap.add(function, 0);
+ if (entry.second)
+ entry.first->second = NativeExecutable::create(generator(globalData, m_executablePool.get()), function);
+ return entry.first->second;
}
} // namespace JSC
diff --git a/JavaScriptCore/jit/JITStubs.h b/JavaScriptCore/jit/JITStubs.h
index 841950f..e5d1419 100644
--- a/JavaScriptCore/jit/JITStubs.h
+++ b/JavaScriptCore/jit/JITStubs.h
@@ -81,7 +81,7 @@ namespace JSC {
MacroAssemblerCodePtr ctiVirtualConstructLink;
MacroAssemblerCodePtr ctiVirtualCall;
MacroAssemblerCodePtr ctiVirtualConstruct;
- RefPtr<NativeExecutable> ctiNativeCallThunk;
+ MacroAssemblerCodePtr ctiNativeCall;
MacroAssemblerCodePtr ctiSoftModulo;
};
@@ -279,13 +279,18 @@ namespace JSC {
MacroAssemblerCodePtr ctiVirtualConstructLink() { return m_trampolineStructure.ctiVirtualConstructLink; }
MacroAssemblerCodePtr ctiVirtualCall() { return m_trampolineStructure.ctiVirtualCall; }
MacroAssemblerCodePtr ctiVirtualConstruct() { return m_trampolineStructure.ctiVirtualConstruct; }
- NativeExecutable* ctiNativeCallThunk() { return m_trampolineStructure.ctiNativeCallThunk.get(); }
+ MacroAssemblerCodePtr ctiNativeCall() { return m_trampolineStructure.ctiNativeCall; }
MacroAssemblerCodePtr ctiSoftModulo() { return m_trampolineStructure.ctiSoftModulo; }
- NativeExecutable* specializedThunk(JSGlobalData* globalData, ThunkGenerator generator);
+ MacroAssemblerCodePtr ctiStub(JSGlobalData* globalData, ThunkGenerator generator);
+
+ PassRefPtr<NativeExecutable> hostFunctionStub(JSGlobalData* globalData, NativeFunction func);
+ PassRefPtr<NativeExecutable> hostFunctionStub(JSGlobalData* globalData, NativeFunction func, ThunkGenerator generator);
private:
- typedef HashMap<ThunkGenerator, RefPtr<NativeExecutable> > ThunkMap;
- ThunkMap m_thunkMap;
+ typedef HashMap<ThunkGenerator, MacroAssemblerCodePtr> CTIStubMap;
+ CTIStubMap m_ctiStubMap;
+ typedef HashMap<NativeFunction, RefPtr<NativeExecutable> > HostFunctionStubMap;
+ HostFunctionStubMap m_hostFunctionStubMap;
RefPtr<ExecutablePool> m_executablePool;
TrampolineStructure m_trampolineStructure;
@@ -301,15 +306,17 @@ extern "C" {
EncodedJSValue JIT_STUB cti_op_call_eval(STUB_ARGS_DECLARATION);
EncodedJSValue JIT_STUB cti_op_construct_NotJSConstruct(STUB_ARGS_DECLARATION);
EncodedJSValue JIT_STUB cti_op_convert_this(STUB_ARGS_DECLARATION);
+ EncodedJSValue JIT_STUB cti_op_create_arguments(STUB_ARGS_DECLARATION);
+ EncodedJSValue JIT_STUB cti_op_create_arguments_no_params(STUB_ARGS_DECLARATION);
EncodedJSValue JIT_STUB cti_op_del_by_id(STUB_ARGS_DECLARATION);
EncodedJSValue JIT_STUB cti_op_del_by_val(STUB_ARGS_DECLARATION);
EncodedJSValue JIT_STUB cti_op_div(STUB_ARGS_DECLARATION);
EncodedJSValue JIT_STUB cti_op_get_by_id(STUB_ARGS_DECLARATION);
EncodedJSValue JIT_STUB cti_op_get_by_id_array_fail(STUB_ARGS_DECLARATION);
+ EncodedJSValue JIT_STUB cti_op_get_by_id_custom_stub(STUB_ARGS_DECLARATION);
EncodedJSValue JIT_STUB cti_op_get_by_id_generic(STUB_ARGS_DECLARATION);
- EncodedJSValue JIT_STUB cti_op_get_by_id_method_check(STUB_ARGS_DECLARATION);
EncodedJSValue JIT_STUB cti_op_get_by_id_getter_stub(STUB_ARGS_DECLARATION);
- EncodedJSValue JIT_STUB cti_op_get_by_id_custom_stub(STUB_ARGS_DECLARATION);
+ EncodedJSValue JIT_STUB cti_op_get_by_id_method_check(STUB_ARGS_DECLARATION);
EncodedJSValue JIT_STUB cti_op_get_by_id_proto_fail(STUB_ARGS_DECLARATION);
EncodedJSValue JIT_STUB cti_op_get_by_id_proto_list(STUB_ARGS_DECLARATION);
EncodedJSValue JIT_STUB cti_op_get_by_id_proto_list_full(STUB_ARGS_DECLARATION);
@@ -353,8 +360,8 @@ extern "C" {
EncodedJSValue JIT_STUB cti_op_to_primitive(STUB_ARGS_DECLARATION);
EncodedJSValue JIT_STUB cti_op_typeof(STUB_ARGS_DECLARATION);
EncodedJSValue JIT_STUB cti_op_urshift(STUB_ARGS_DECLARATION);
- EncodedJSValue JIT_STUB cti_vm_throw(STUB_ARGS_DECLARATION);
EncodedJSValue JIT_STUB cti_to_object(STUB_ARGS_DECLARATION);
+ EncodedJSValue JIT_STUB cti_vm_throw(STUB_ARGS_DECLARATION);
JSObject* JIT_STUB cti_op_construct_JSConstruct(STUB_ARGS_DECLARATION);
JSObject* JIT_STUB cti_op_new_array(STUB_ARGS_DECLARATION);
JSObject* JIT_STUB cti_op_new_error(STUB_ARGS_DECLARATION);
@@ -378,8 +385,6 @@ extern "C" {
int JIT_STUB cti_op_loop_if_lesseq(STUB_ARGS_DECLARATION);
int JIT_STUB cti_timeout_check(STUB_ARGS_DECLARATION);
int JIT_STUB cti_has_property(STUB_ARGS_DECLARATION);
- void JIT_STUB cti_op_create_arguments(STUB_ARGS_DECLARATION);
- void JIT_STUB cti_op_create_arguments_no_params(STUB_ARGS_DECLARATION);
void JIT_STUB cti_op_debug(STUB_ARGS_DECLARATION);
void JIT_STUB cti_op_end(STUB_ARGS_DECLARATION);
void JIT_STUB cti_op_jmp_scopes(STUB_ARGS_DECLARATION);
diff --git a/JavaScriptCore/jit/JSInterfaceJIT.h b/JavaScriptCore/jit/JSInterfaceJIT.h
index 12a6cfa..c85b94d 100644
--- a/JavaScriptCore/jit/JSInterfaceJIT.h
+++ b/JavaScriptCore/jit/JSInterfaceJIT.h
@@ -191,27 +191,32 @@ namespace JSC {
inline JSInterfaceJIT::Jump JSInterfaceJIT::emitJumpIfNotJSCell(unsigned virtualRegisterIndex)
{
+ ASSERT(static_cast<int>(virtualRegisterIndex) < FirstConstantRegisterIndex);
return branch32(NotEqual, tagFor(virtualRegisterIndex), Imm32(JSValue::CellTag));
}
inline JSInterfaceJIT::Jump JSInterfaceJIT::emitLoadInt32(unsigned virtualRegisterIndex, RegisterID dst)
{
+ ASSERT(static_cast<int>(virtualRegisterIndex) < FirstConstantRegisterIndex);
loadPtr(payloadFor(virtualRegisterIndex), dst);
return branch32(NotEqual, tagFor(virtualRegisterIndex), Imm32(JSValue::Int32Tag));
}
- inline JSInterfaceJIT::Address JSInterfaceJIT::tagFor(unsigned index, RegisterID base)
+ inline JSInterfaceJIT::Address JSInterfaceJIT::tagFor(unsigned virtualRegisterIndex, RegisterID base)
{
- return Address(base, (index * sizeof(Register)) + OBJECT_OFFSETOF(JSValue, u.asBits.tag));
+ ASSERT(static_cast<int>(virtualRegisterIndex) < FirstConstantRegisterIndex);
+ return Address(base, (virtualRegisterIndex * sizeof(Register)) + OBJECT_OFFSETOF(JSValue, u.asBits.tag));
}
- inline JSInterfaceJIT::Address JSInterfaceJIT::payloadFor(unsigned index, RegisterID base)
+ inline JSInterfaceJIT::Address JSInterfaceJIT::payloadFor(unsigned virtualRegisterIndex, RegisterID base)
{
- return Address(base, (index * sizeof(Register)) + OBJECT_OFFSETOF(JSValue, u.asBits.payload));
+ ASSERT(static_cast<int>(virtualRegisterIndex) < FirstConstantRegisterIndex);
+ return Address(base, (virtualRegisterIndex * sizeof(Register)) + OBJECT_OFFSETOF(JSValue, u.asBits.payload));
}
inline JSInterfaceJIT::Jump JSInterfaceJIT::emitLoadDouble(unsigned virtualRegisterIndex, FPRegisterID dst, RegisterID scratch)
{
+ ASSERT(static_cast<int>(virtualRegisterIndex) < FirstConstantRegisterIndex);
loadPtr(tagFor(virtualRegisterIndex), scratch);
Jump isDouble = branch32(Below, scratch, Imm32(JSValue::LowestTag));
Jump notInt = branch32(NotEqual, scratch, Imm32(JSValue::Int32Tag));
@@ -297,15 +302,17 @@ namespace JSC {
#endif
#if !USE(JSVALUE32_64)
- inline JSInterfaceJIT::Address JSInterfaceJIT::payloadFor(unsigned index, RegisterID base)
+ inline JSInterfaceJIT::Address JSInterfaceJIT::payloadFor(unsigned virtualRegisterIndex, RegisterID base)
{
- return addressFor(index, base);
+ ASSERT(static_cast<int>(virtualRegisterIndex) < FirstConstantRegisterIndex);
+ return addressFor(virtualRegisterIndex, base);
}
#endif
- inline JSInterfaceJIT::Address JSInterfaceJIT::addressFor(unsigned index, RegisterID base)
+ inline JSInterfaceJIT::Address JSInterfaceJIT::addressFor(unsigned virtualRegisterIndex, RegisterID base)
{
- return Address(base, (index * sizeof(Register)));
+ ASSERT(static_cast<int>(virtualRegisterIndex) < FirstConstantRegisterIndex);
+ return Address(base, (virtualRegisterIndex * sizeof(Register)));
}
}
diff --git a/JavaScriptCore/jit/SpecializedThunkJIT.h b/JavaScriptCore/jit/SpecializedThunkJIT.h
index 69925a9..00f7aef 100644
--- a/JavaScriptCore/jit/SpecializedThunkJIT.h
+++ b/JavaScriptCore/jit/SpecializedThunkJIT.h
@@ -127,11 +127,11 @@ namespace JSC {
ret();
}
- PassRefPtr<NativeExecutable> finalize()
+ MacroAssemblerCodePtr finalize(MacroAssemblerCodePtr fallback)
{
LinkBuffer patchBuffer(this, m_pool.get());
- patchBuffer.link(m_failures, CodeLocationLabel(m_globalData->jitStubs.ctiNativeCallThunk()->generatedJITCodeForCall().addressForCall()));
- return adoptRef(new NativeExecutable(patchBuffer.finalizeCode()));
+ patchBuffer.link(m_failures, CodeLocationLabel(fallback));
+ return patchBuffer.finalizeCode().m_code;
}
private:
diff --git a/JavaScriptCore/jit/ThunkGenerators.cpp b/JavaScriptCore/jit/ThunkGenerators.cpp
index c625c3d..271c7c1 100644
--- a/JavaScriptCore/jit/ThunkGenerators.cpp
+++ b/JavaScriptCore/jit/ThunkGenerators.cpp
@@ -25,8 +25,9 @@
#include "config.h"
#include "ThunkGenerators.h"
-#include <wtf/text/StringImpl.h>
+#include "CodeBlock.h"
+#include <wtf/text/StringImpl.h>
#include "SpecializedThunkJIT.h"
#if ENABLE(JIT)
@@ -62,59 +63,59 @@ static void charToString(SpecializedThunkJIT& jit, JSGlobalData* globalData, Mac
jit.appendFailure(jit.branchTestPtr(MacroAssembler::Zero, dst));
}
-PassRefPtr<NativeExecutable> charCodeAtThunkGenerator(JSGlobalData* globalData, ExecutablePool* pool)
+MacroAssemblerCodePtr charCodeAtThunkGenerator(JSGlobalData* globalData, ExecutablePool* pool)
{
SpecializedThunkJIT jit(1, globalData, pool);
stringCharLoad(jit);
jit.returnInt32(SpecializedThunkJIT::regT0);
- return jit.finalize();
+ return jit.finalize(globalData->jitStubs.ctiNativeCall());
}
-PassRefPtr<NativeExecutable> charAtThunkGenerator(JSGlobalData* globalData, ExecutablePool* pool)
+MacroAssemblerCodePtr charAtThunkGenerator(JSGlobalData* globalData, ExecutablePool* pool)
{
SpecializedThunkJIT jit(1, globalData, pool);
stringCharLoad(jit);
charToString(jit, globalData, SpecializedThunkJIT::regT0, SpecializedThunkJIT::regT0, SpecializedThunkJIT::regT1);
jit.returnJSCell(SpecializedThunkJIT::regT0);
- return jit.finalize();
+ return jit.finalize(globalData->jitStubs.ctiNativeCall());
}
-PassRefPtr<NativeExecutable> fromCharCodeThunkGenerator(JSGlobalData* globalData, ExecutablePool* pool)
+MacroAssemblerCodePtr fromCharCodeThunkGenerator(JSGlobalData* globalData, ExecutablePool* pool)
{
SpecializedThunkJIT jit(1, globalData, pool);
// load char code
jit.loadInt32Argument(0, SpecializedThunkJIT::regT0);
charToString(jit, globalData, SpecializedThunkJIT::regT0, SpecializedThunkJIT::regT0, SpecializedThunkJIT::regT1);
jit.returnJSCell(SpecializedThunkJIT::regT0);
- return jit.finalize();
+ return jit.finalize(globalData->jitStubs.ctiNativeCall());
}
-PassRefPtr<NativeExecutable> sqrtThunkGenerator(JSGlobalData* globalData, ExecutablePool* pool)
+MacroAssemblerCodePtr sqrtThunkGenerator(JSGlobalData* globalData, ExecutablePool* pool)
{
#if USE(JSVALUE64) || USE(JSVALUE32_64)
SpecializedThunkJIT jit(1, globalData, pool);
if (!jit.supportsFloatingPointSqrt())
- return globalData->jitStubs.ctiNativeCallThunk();
+ return globalData->jitStubs.ctiNativeCall();
jit.loadDoubleArgument(0, SpecializedThunkJIT::fpRegT0, SpecializedThunkJIT::regT0);
jit.sqrtDouble(SpecializedThunkJIT::fpRegT0, SpecializedThunkJIT::fpRegT0);
jit.returnDouble(SpecializedThunkJIT::fpRegT0);
- return jit.finalize();
+ return jit.finalize(globalData->jitStubs.ctiNativeCall());
#else
UNUSED_PARAM(pool);
- return globalData->jitStubs.ctiNativeCallThunk();
+ return globalData->jitStubs.ctiNativeCall();
#endif
}
static const double oneConstant = 1.0;
static const double negativeHalfConstant = -0.5;
-PassRefPtr<NativeExecutable> powThunkGenerator(JSGlobalData* globalData, ExecutablePool* pool)
+MacroAssemblerCodePtr powThunkGenerator(JSGlobalData* globalData, ExecutablePool* pool)
{
#if USE(JSVALUE64) || USE(JSVALUE32_64)
SpecializedThunkJIT jit(2, globalData, pool);
if (!jit.supportsFloatingPoint())
- return globalData->jitStubs.ctiNativeCallThunk();
+ return globalData->jitStubs.ctiNativeCall();
jit.loadDouble(&oneConstant, SpecializedThunkJIT::fpRegT1);
jit.loadDoubleArgument(0, SpecializedThunkJIT::fpRegT0, SpecializedThunkJIT::regT0);
@@ -147,10 +148,10 @@ PassRefPtr<NativeExecutable> powThunkGenerator(JSGlobalData* globalData, Executa
} else
jit.appendFailure(nonIntExponent);
- return jit.finalize();
+ return jit.finalize(globalData->jitStubs.ctiNativeCall());
#else
UNUSED_PARAM(pool);
- return globalData->jitStubs.ctiNativeCallThunk();
+ return globalData->jitStubs.ctiNativeCall();
#endif
}
diff --git a/JavaScriptCore/jit/ThunkGenerators.h b/JavaScriptCore/jit/ThunkGenerators.h
index c3374f2..15261f7 100644
--- a/JavaScriptCore/jit/ThunkGenerators.h
+++ b/JavaScriptCore/jit/ThunkGenerators.h
@@ -27,19 +27,18 @@
#define ThunkGenerators_h
#if ENABLE(JIT)
-#include <wtf/PassRefPtr.h>
-
namespace JSC {
class ExecutablePool;
class JSGlobalData;
class NativeExecutable;
+ class MacroAssemblerCodePtr;
- typedef PassRefPtr<NativeExecutable> (*ThunkGenerator)(JSGlobalData*, ExecutablePool*);
- PassRefPtr<NativeExecutable> charCodeAtThunkGenerator(JSGlobalData*, ExecutablePool*);
- PassRefPtr<NativeExecutable> charAtThunkGenerator(JSGlobalData*, ExecutablePool*);
- PassRefPtr<NativeExecutable> fromCharCodeThunkGenerator(JSGlobalData*, ExecutablePool*);
- PassRefPtr<NativeExecutable> sqrtThunkGenerator(JSGlobalData*, ExecutablePool*);
- PassRefPtr<NativeExecutable> powThunkGenerator(JSGlobalData*, ExecutablePool*);
+ typedef MacroAssemblerCodePtr (*ThunkGenerator)(JSGlobalData*, ExecutablePool*);
+ MacroAssemblerCodePtr charCodeAtThunkGenerator(JSGlobalData*, ExecutablePool*);
+ MacroAssemblerCodePtr charAtThunkGenerator(JSGlobalData*, ExecutablePool*);
+ MacroAssemblerCodePtr fromCharCodeThunkGenerator(JSGlobalData*, ExecutablePool*);
+ MacroAssemblerCodePtr sqrtThunkGenerator(JSGlobalData*, ExecutablePool*);
+ MacroAssemblerCodePtr powThunkGenerator(JSGlobalData*, ExecutablePool*);
}
#endif
diff --git a/JavaScriptCore/jsc.cpp b/JavaScriptCore/jsc.cpp
index ae47d55..46eaccc 100644
--- a/JavaScriptCore/jsc.cpp
+++ b/JavaScriptCore/jsc.cpp
@@ -150,19 +150,19 @@ ASSERT_CLASS_FITS_IN_CELL(GlobalObject);
GlobalObject::GlobalObject(const Vector<UString>& arguments)
: JSGlobalObject()
{
- putDirectFunction(globalExec(), new (globalExec()) NativeFunctionWrapper(globalExec(), prototypeFunctionStructure(), 1, Identifier(globalExec(), "debug"), functionDebug));
- putDirectFunction(globalExec(), new (globalExec()) NativeFunctionWrapper(globalExec(), prototypeFunctionStructure(), 1, Identifier(globalExec(), "print"), functionPrint));
- putDirectFunction(globalExec(), new (globalExec()) NativeFunctionWrapper(globalExec(), prototypeFunctionStructure(), 0, Identifier(globalExec(), "quit"), functionQuit));
- putDirectFunction(globalExec(), new (globalExec()) NativeFunctionWrapper(globalExec(), prototypeFunctionStructure(), 0, Identifier(globalExec(), "gc"), functionGC));
- putDirectFunction(globalExec(), new (globalExec()) NativeFunctionWrapper(globalExec(), prototypeFunctionStructure(), 1, Identifier(globalExec(), "version"), functionVersion));
- putDirectFunction(globalExec(), new (globalExec()) NativeFunctionWrapper(globalExec(), prototypeFunctionStructure(), 1, Identifier(globalExec(), "run"), functionRun));
- putDirectFunction(globalExec(), new (globalExec()) NativeFunctionWrapper(globalExec(), prototypeFunctionStructure(), 1, Identifier(globalExec(), "load"), functionLoad));
- putDirectFunction(globalExec(), new (globalExec()) NativeFunctionWrapper(globalExec(), prototypeFunctionStructure(), 1, Identifier(globalExec(), "checkSyntax"), functionCheckSyntax));
- putDirectFunction(globalExec(), new (globalExec()) NativeFunctionWrapper(globalExec(), prototypeFunctionStructure(), 0, Identifier(globalExec(), "readline"), functionReadline));
+ putDirectFunction(globalExec(), new (globalExec()) NativeFunctionWrapper(globalExec(), this, prototypeFunctionStructure(), 1, Identifier(globalExec(), "debug"), functionDebug));
+ putDirectFunction(globalExec(), new (globalExec()) NativeFunctionWrapper(globalExec(), this, prototypeFunctionStructure(), 1, Identifier(globalExec(), "print"), functionPrint));
+ putDirectFunction(globalExec(), new (globalExec()) NativeFunctionWrapper(globalExec(), this, prototypeFunctionStructure(), 0, Identifier(globalExec(), "quit"), functionQuit));
+ putDirectFunction(globalExec(), new (globalExec()) NativeFunctionWrapper(globalExec(), this, prototypeFunctionStructure(), 0, Identifier(globalExec(), "gc"), functionGC));
+ putDirectFunction(globalExec(), new (globalExec()) NativeFunctionWrapper(globalExec(), this, prototypeFunctionStructure(), 1, Identifier(globalExec(), "version"), functionVersion));
+ putDirectFunction(globalExec(), new (globalExec()) NativeFunctionWrapper(globalExec(), this, prototypeFunctionStructure(), 1, Identifier(globalExec(), "run"), functionRun));
+ putDirectFunction(globalExec(), new (globalExec()) NativeFunctionWrapper(globalExec(), this, prototypeFunctionStructure(), 1, Identifier(globalExec(), "load"), functionLoad));
+ putDirectFunction(globalExec(), new (globalExec()) NativeFunctionWrapper(globalExec(), this, prototypeFunctionStructure(), 1, Identifier(globalExec(), "checkSyntax"), functionCheckSyntax));
+ putDirectFunction(globalExec(), new (globalExec()) NativeFunctionWrapper(globalExec(), this, prototypeFunctionStructure(), 0, Identifier(globalExec(), "readline"), functionReadline));
#if ENABLE(SAMPLING_FLAGS)
- putDirectFunction(globalExec(), new (globalExec()) NativeFunctionWrapper(globalExec(), prototypeFunctionStructure(), 1, Identifier(globalExec(), "setSamplingFlags"), functionSetSamplingFlags));
- putDirectFunction(globalExec(), new (globalExec()) NativeFunctionWrapper(globalExec(), prototypeFunctionStructure(), 1, Identifier(globalExec(), "clearSamplingFlags"), functionClearSamplingFlags));
+ putDirectFunction(globalExec(), new (globalExec()) NativeFunctionWrapper(globalExec(), this, prototypeFunctionStructure(), 1, Identifier(globalExec(), "setSamplingFlags"), functionSetSamplingFlags));
+ putDirectFunction(globalExec(), new (globalExec()) NativeFunctionWrapper(globalExec(), this, prototypeFunctionStructure(), 1, Identifier(globalExec(), "clearSamplingFlags"), functionClearSamplingFlags));
#endif
JSObject* array = constructEmptyArray(globalExec());
diff --git a/JavaScriptCore/profiler/ProfileNode.cpp b/JavaScriptCore/profiler/ProfileNode.cpp
index f60c72e..1391f99 100644
--- a/JavaScriptCore/profiler/ProfileNode.cpp
+++ b/JavaScriptCore/profiler/ProfileNode.cpp
@@ -45,7 +45,7 @@ namespace JSC {
static double getCount()
{
#if OS(WINDOWS)
- static LARGE_INTEGER frequency = {0};
+ static LARGE_INTEGER frequency;
if (!frequency.QuadPart)
QueryPerformanceFrequency(&frequency);
LARGE_INTEGER counter;
diff --git a/JavaScriptCore/profiler/Profiler.cpp b/JavaScriptCore/profiler/Profiler.cpp
index fe8727a..94e46a4 100644
--- a/JavaScriptCore/profiler/Profiler.cpp
+++ b/JavaScriptCore/profiler/Profiler.cpp
@@ -32,6 +32,7 @@
#include "CommonIdentifiers.h"
#include "CallFrame.h"
#include "CodeBlock.h"
+#include "InternalFunction.h"
#include "JSFunction.h"
#include "JSGlobalObject.h"
#include "Nodes.h"
@@ -146,6 +147,8 @@ CallIdentifier Profiler::createCallIdentifier(ExecState* exec, JSValue functionV
if (!function->executable()->isHostFunction())
return createCallIdentifierFromFunctionImp(exec, function);
}
+ if (asObject(functionValue)->inherits(&JSFunction::info))
+ return CallIdentifier(static_cast<JSFunction*>(asObject(functionValue))->name(exec), defaultSourceURL, defaultLineNumber);
if (asObject(functionValue)->inherits(&InternalFunction::info))
return CallIdentifier(static_cast<InternalFunction*>(asObject(functionValue))->name(exec), defaultSourceURL, defaultLineNumber);
return CallIdentifier(makeString("(", asObject(functionValue)->className(), " object)"), defaultSourceURL, defaultLineNumber);
diff --git a/JavaScriptCore/qt/tests/qscriptvalue/qscriptvalue.pro b/JavaScriptCore/qt/tests/qscriptvalue/qscriptvalue.pro
index 35cc17d..532d430 100644
--- a/JavaScriptCore/qt/tests/qscriptvalue/qscriptvalue.pro
+++ b/JavaScriptCore/qt/tests/qscriptvalue/qscriptvalue.pro
@@ -6,7 +6,9 @@ include(../tests.pri)
SOURCES += \
tst_qscriptvalue.cpp \
- tst_qscriptvalue_generated.cpp
+ tst_qscriptvalue_generated_init.cpp \
+ tst_qscriptvalue_generated_istype.cpp \
+ tst_qscriptvalue_generated_totype.cpp \
HEADERS += \
tst_qscriptvalue.h
diff --git a/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue.h b/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue.h
index 27d5f99..3d33f8e 100644
--- a/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue.h
+++ b/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue.h
@@ -25,6 +25,8 @@
#include <QtCore/qnumeric.h>
#include <QtTest/qtest.h>
+#define DEFINE_TEST_VALUE(expr) m_values.insert(QString::fromLatin1(#expr), expr)
+
Q_DECLARE_METATYPE(QScriptValue*);
Q_DECLARE_METATYPE(QScriptValue);
diff --git a/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue_generated.cpp b/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue_generated.cpp
deleted file mode 100644
index 970c960..0000000
--- a/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue_generated.cpp
+++ /dev/null
@@ -1,1922 +0,0 @@
-/*
- Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-#include "tst_qscriptvalue.h"
-
-#define DEFINE_TEST_VALUE(expr) m_values.insert(QString::fromLatin1(#expr), expr)
-
-void tst_QScriptValue::initScriptValues()
-{
- m_values.clear();
- if (engine)
- delete engine;
- engine = new QScriptEngine;
- DEFINE_TEST_VALUE(QScriptValue());
- DEFINE_TEST_VALUE(QScriptValue(QScriptValue::UndefinedValue));
- DEFINE_TEST_VALUE(QScriptValue(QScriptValue::NullValue));
- DEFINE_TEST_VALUE(QScriptValue(true));
- DEFINE_TEST_VALUE(QScriptValue(false));
- DEFINE_TEST_VALUE(QScriptValue(int(122)));
- DEFINE_TEST_VALUE(QScriptValue(uint(124)));
- DEFINE_TEST_VALUE(QScriptValue(0));
- DEFINE_TEST_VALUE(QScriptValue(0.0));
- DEFINE_TEST_VALUE(QScriptValue(123.0));
- DEFINE_TEST_VALUE(QScriptValue(6.37e-8));
- DEFINE_TEST_VALUE(QScriptValue(-6.37e-8));
- DEFINE_TEST_VALUE(QScriptValue(0x43211234));
- DEFINE_TEST_VALUE(QScriptValue(0x10000));
- DEFINE_TEST_VALUE(QScriptValue(0x10001));
- DEFINE_TEST_VALUE(QScriptValue(qSNaN()));
- DEFINE_TEST_VALUE(QScriptValue(qQNaN()));
- DEFINE_TEST_VALUE(QScriptValue(qInf()));
- DEFINE_TEST_VALUE(QScriptValue(-qInf()));
- DEFINE_TEST_VALUE(QScriptValue("NaN"));
- DEFINE_TEST_VALUE(QScriptValue("Infinity"));
- DEFINE_TEST_VALUE(QScriptValue("-Infinity"));
- DEFINE_TEST_VALUE(QScriptValue("ciao"));
- DEFINE_TEST_VALUE(QScriptValue(QString::fromLatin1("ciao")));
- DEFINE_TEST_VALUE(QScriptValue(QString("")));
- DEFINE_TEST_VALUE(QScriptValue(QString()));
- DEFINE_TEST_VALUE(QScriptValue(QString("0")));
- DEFINE_TEST_VALUE(QScriptValue(QString("123")));
- DEFINE_TEST_VALUE(QScriptValue(QString("12.4")));
- DEFINE_TEST_VALUE(QScriptValue(0, QScriptValue::UndefinedValue));
- DEFINE_TEST_VALUE(QScriptValue(0, QScriptValue::NullValue));
- DEFINE_TEST_VALUE(QScriptValue(0, true));
- DEFINE_TEST_VALUE(QScriptValue(0, false));
- DEFINE_TEST_VALUE(QScriptValue(0, int(122)));
- DEFINE_TEST_VALUE(QScriptValue(0, uint(124)));
- DEFINE_TEST_VALUE(QScriptValue(0, 0));
- DEFINE_TEST_VALUE(QScriptValue(0, 0.0));
- DEFINE_TEST_VALUE(QScriptValue(0, 123.0));
- DEFINE_TEST_VALUE(QScriptValue(0, 6.37e-8));
- DEFINE_TEST_VALUE(QScriptValue(0, -6.37e-8));
- DEFINE_TEST_VALUE(QScriptValue(0, 0x43211234));
- DEFINE_TEST_VALUE(QScriptValue(0, 0x10000));
- DEFINE_TEST_VALUE(QScriptValue(0, 0x10001));
- DEFINE_TEST_VALUE(QScriptValue(0, qSNaN()));
- DEFINE_TEST_VALUE(QScriptValue(0, qQNaN()));
- DEFINE_TEST_VALUE(QScriptValue(0, qInf()));
- DEFINE_TEST_VALUE(QScriptValue(0, -qInf()));
- DEFINE_TEST_VALUE(QScriptValue(0, "NaN"));
- DEFINE_TEST_VALUE(QScriptValue(0, "Infinity"));
- DEFINE_TEST_VALUE(QScriptValue(0, "-Infinity"));
- DEFINE_TEST_VALUE(QScriptValue(0, "ciao"));
- DEFINE_TEST_VALUE(QScriptValue(0, QString::fromLatin1("ciao")));
- DEFINE_TEST_VALUE(QScriptValue(0, QString("")));
- DEFINE_TEST_VALUE(QScriptValue(0, QString()));
- DEFINE_TEST_VALUE(QScriptValue(0, QString("0")));
- DEFINE_TEST_VALUE(QScriptValue(0, QString("123")));
- DEFINE_TEST_VALUE(QScriptValue(0, QString("12.3")));
- DEFINE_TEST_VALUE(QScriptValue(engine, QScriptValue::UndefinedValue));
- DEFINE_TEST_VALUE(QScriptValue(engine, QScriptValue::NullValue));
- DEFINE_TEST_VALUE(QScriptValue(engine, true));
- DEFINE_TEST_VALUE(QScriptValue(engine, false));
- DEFINE_TEST_VALUE(QScriptValue(engine, int(122)));
- DEFINE_TEST_VALUE(QScriptValue(engine, uint(124)));
- DEFINE_TEST_VALUE(QScriptValue(engine, 0));
- DEFINE_TEST_VALUE(QScriptValue(engine, 0.0));
- DEFINE_TEST_VALUE(QScriptValue(engine, 123.0));
- DEFINE_TEST_VALUE(QScriptValue(engine, 6.37e-8));
- DEFINE_TEST_VALUE(QScriptValue(engine, -6.37e-8));
- DEFINE_TEST_VALUE(QScriptValue(engine, 0x43211234));
- DEFINE_TEST_VALUE(QScriptValue(engine, 0x10000));
- DEFINE_TEST_VALUE(QScriptValue(engine, 0x10001));
- DEFINE_TEST_VALUE(QScriptValue(engine, qSNaN()));
- DEFINE_TEST_VALUE(QScriptValue(engine, qQNaN()));
- DEFINE_TEST_VALUE(QScriptValue(engine, qInf()));
- DEFINE_TEST_VALUE(QScriptValue(engine, -qInf()));
- DEFINE_TEST_VALUE(QScriptValue(engine, "NaN"));
- DEFINE_TEST_VALUE(QScriptValue(engine, "Infinity"));
- DEFINE_TEST_VALUE(QScriptValue(engine, "-Infinity"));
- DEFINE_TEST_VALUE(QScriptValue(engine, "ciao"));
- DEFINE_TEST_VALUE(QScriptValue(engine, QString::fromLatin1("ciao")));
- DEFINE_TEST_VALUE(QScriptValue(engine, QString("")));
- DEFINE_TEST_VALUE(QScriptValue(engine, QString()));
- DEFINE_TEST_VALUE(QScriptValue(engine, QString("0")));
- DEFINE_TEST_VALUE(QScriptValue(engine, QString("123")));
- DEFINE_TEST_VALUE(QScriptValue(engine, QString("1.23")));
- DEFINE_TEST_VALUE(engine->evaluate("[]"));
- DEFINE_TEST_VALUE(engine->evaluate("{}"));
- DEFINE_TEST_VALUE(engine->evaluate("Object.prototype"));
- DEFINE_TEST_VALUE(engine->evaluate("Date.prototype"));
- DEFINE_TEST_VALUE(engine->evaluate("Array.prototype"));
- DEFINE_TEST_VALUE(engine->evaluate("Function.prototype"));
- DEFINE_TEST_VALUE(engine->evaluate("Error.prototype"));
- DEFINE_TEST_VALUE(engine->evaluate("Object"));
- DEFINE_TEST_VALUE(engine->evaluate("Array"));
- DEFINE_TEST_VALUE(engine->evaluate("Number"));
- DEFINE_TEST_VALUE(engine->evaluate("Function"));
- DEFINE_TEST_VALUE(engine->evaluate("(function() { return 1; })"));
- DEFINE_TEST_VALUE(engine->evaluate("(function() { return 'ciao'; })"));
- DEFINE_TEST_VALUE(engine->evaluate("(function() { throw new Error('foo'); })"));
- DEFINE_TEST_VALUE(engine->evaluate("/foo/"));
- DEFINE_TEST_VALUE(engine->evaluate("new Object()"));
- DEFINE_TEST_VALUE(engine->evaluate("new Array()"));
- DEFINE_TEST_VALUE(engine->evaluate("new Error()"));
- DEFINE_TEST_VALUE(engine->evaluate("a = new Object(); a.foo = 22; a.foo"));
- DEFINE_TEST_VALUE(engine->evaluate("Undefined"));
- DEFINE_TEST_VALUE(engine->evaluate("Null"));
- DEFINE_TEST_VALUE(engine->evaluate("True"));
- DEFINE_TEST_VALUE(engine->evaluate("False"));
- DEFINE_TEST_VALUE(engine->evaluate("undefined"));
- DEFINE_TEST_VALUE(engine->evaluate("null"));
- DEFINE_TEST_VALUE(engine->evaluate("true"));
- DEFINE_TEST_VALUE(engine->evaluate("false"));
- DEFINE_TEST_VALUE(engine->evaluate("122"));
- DEFINE_TEST_VALUE(engine->evaluate("124"));
- DEFINE_TEST_VALUE(engine->evaluate("0"));
- DEFINE_TEST_VALUE(engine->evaluate("0.0"));
- DEFINE_TEST_VALUE(engine->evaluate("123.0"));
- DEFINE_TEST_VALUE(engine->evaluate("6.37e-8"));
- DEFINE_TEST_VALUE(engine->evaluate("-6.37e-8"));
- DEFINE_TEST_VALUE(engine->evaluate("0x43211234"));
- DEFINE_TEST_VALUE(engine->evaluate("0x10000"));
- DEFINE_TEST_VALUE(engine->evaluate("0x10001"));
- DEFINE_TEST_VALUE(engine->evaluate("NaN"));
- DEFINE_TEST_VALUE(engine->evaluate("Infinity"));
- DEFINE_TEST_VALUE(engine->evaluate("-Infinity"));
- DEFINE_TEST_VALUE(engine->evaluate("'ciao'"));
- DEFINE_TEST_VALUE(engine->evaluate("''"));
- DEFINE_TEST_VALUE(engine->evaluate("'0'"));
- DEFINE_TEST_VALUE(engine->evaluate("'123'"));
- DEFINE_TEST_VALUE(engine->evaluate("'12.4'"));
- DEFINE_TEST_VALUE(engine->nullValue());
- DEFINE_TEST_VALUE(engine->undefinedValue());
-}
-
-
-void tst_QScriptValue::isValid_initData()
-{
- QTest::addColumn<bool>("expected");
- initScriptValues();
-}
-
-void tst_QScriptValue::isValid_makeData(const char* expr)
-{
- static QSet<QString> isValid;
- if (isValid.isEmpty()) {
- isValid << "QScriptValue(QScriptValue::UndefinedValue)"
- << "QScriptValue(QScriptValue::NullValue)"
- << "QScriptValue(true)"
- << "QScriptValue(false)"
- << "QScriptValue(int(122))"
- << "QScriptValue(uint(124))"
- << "QScriptValue(0)"
- << "QScriptValue(0.0)"
- << "QScriptValue(123.0)"
- << "QScriptValue(6.37e-8)"
- << "QScriptValue(-6.37e-8)"
- << "QScriptValue(0x43211234)"
- << "QScriptValue(0x10000)"
- << "QScriptValue(0x10001)"
- << "QScriptValue(qSNaN())"
- << "QScriptValue(qQNaN())"
- << "QScriptValue(qInf())"
- << "QScriptValue(-qInf())"
- << "QScriptValue(\"NaN\")"
- << "QScriptValue(\"Infinity\")"
- << "QScriptValue(\"-Infinity\")"
- << "QScriptValue(\"ciao\")"
- << "QScriptValue(QString::fromLatin1(\"ciao\"))"
- << "QScriptValue(QString(\"\"))"
- << "QScriptValue(QString())"
- << "QScriptValue(QString(\"0\"))"
- << "QScriptValue(QString(\"123\"))"
- << "QScriptValue(QString(\"12.4\"))"
- << "QScriptValue(0, QScriptValue::UndefinedValue)"
- << "QScriptValue(0, QScriptValue::NullValue)"
- << "QScriptValue(0, true)"
- << "QScriptValue(0, false)"
- << "QScriptValue(0, int(122))"
- << "QScriptValue(0, uint(124))"
- << "QScriptValue(0, 0)"
- << "QScriptValue(0, 0.0)"
- << "QScriptValue(0, 123.0)"
- << "QScriptValue(0, 6.37e-8)"
- << "QScriptValue(0, -6.37e-8)"
- << "QScriptValue(0, 0x43211234)"
- << "QScriptValue(0, 0x10000)"
- << "QScriptValue(0, 0x10001)"
- << "QScriptValue(0, qSNaN())"
- << "QScriptValue(0, qQNaN())"
- << "QScriptValue(0, qInf())"
- << "QScriptValue(0, -qInf())"
- << "QScriptValue(0, \"NaN\")"
- << "QScriptValue(0, \"Infinity\")"
- << "QScriptValue(0, \"-Infinity\")"
- << "QScriptValue(0, \"ciao\")"
- << "QScriptValue(0, QString::fromLatin1(\"ciao\"))"
- << "QScriptValue(0, QString(\"\"))"
- << "QScriptValue(0, QString())"
- << "QScriptValue(0, QString(\"0\"))"
- << "QScriptValue(0, QString(\"123\"))"
- << "QScriptValue(0, QString(\"12.3\"))"
- << "QScriptValue(engine, QScriptValue::UndefinedValue)"
- << "QScriptValue(engine, QScriptValue::NullValue)"
- << "QScriptValue(engine, true)"
- << "QScriptValue(engine, false)"
- << "QScriptValue(engine, int(122))"
- << "QScriptValue(engine, uint(124))"
- << "QScriptValue(engine, 0)"
- << "QScriptValue(engine, 0.0)"
- << "QScriptValue(engine, 123.0)"
- << "QScriptValue(engine, 6.37e-8)"
- << "QScriptValue(engine, -6.37e-8)"
- << "QScriptValue(engine, 0x43211234)"
- << "QScriptValue(engine, 0x10000)"
- << "QScriptValue(engine, 0x10001)"
- << "QScriptValue(engine, qSNaN())"
- << "QScriptValue(engine, qQNaN())"
- << "QScriptValue(engine, qInf())"
- << "QScriptValue(engine, -qInf())"
- << "QScriptValue(engine, \"NaN\")"
- << "QScriptValue(engine, \"Infinity\")"
- << "QScriptValue(engine, \"-Infinity\")"
- << "QScriptValue(engine, \"ciao\")"
- << "QScriptValue(engine, QString::fromLatin1(\"ciao\"))"
- << "QScriptValue(engine, QString(\"\"))"
- << "QScriptValue(engine, QString())"
- << "QScriptValue(engine, QString(\"0\"))"
- << "QScriptValue(engine, QString(\"123\"))"
- << "QScriptValue(engine, QString(\"1.23\"))"
- << "engine->evaluate(\"[]\")"
- << "engine->evaluate(\"{}\")"
- << "engine->evaluate(\"Object.prototype\")"
- << "engine->evaluate(\"Date.prototype\")"
- << "engine->evaluate(\"Array.prototype\")"
- << "engine->evaluate(\"Function.prototype\")"
- << "engine->evaluate(\"Error.prototype\")"
- << "engine->evaluate(\"Object\")"
- << "engine->evaluate(\"Array\")"
- << "engine->evaluate(\"Number\")"
- << "engine->evaluate(\"Function\")"
- << "engine->evaluate(\"(function() { return 1; })\")"
- << "engine->evaluate(\"(function() { return 'ciao'; })\")"
- << "engine->evaluate(\"(function() { throw new Error('foo'); })\")"
- << "engine->evaluate(\"/foo/\")"
- << "engine->evaluate(\"new Object()\")"
- << "engine->evaluate(\"new Array()\")"
- << "engine->evaluate(\"new Error()\")"
- << "engine->evaluate(\"a = new Object(); a.foo = 22; a.foo\")"
- << "engine->evaluate(\"Undefined\")"
- << "engine->evaluate(\"Null\")"
- << "engine->evaluate(\"True\")"
- << "engine->evaluate(\"False\")"
- << "engine->evaluate(\"undefined\")"
- << "engine->evaluate(\"null\")"
- << "engine->evaluate(\"true\")"
- << "engine->evaluate(\"false\")"
- << "engine->evaluate(\"122\")"
- << "engine->evaluate(\"124\")"
- << "engine->evaluate(\"0\")"
- << "engine->evaluate(\"0.0\")"
- << "engine->evaluate(\"123.0\")"
- << "engine->evaluate(\"6.37e-8\")"
- << "engine->evaluate(\"-6.37e-8\")"
- << "engine->evaluate(\"0x43211234\")"
- << "engine->evaluate(\"0x10000\")"
- << "engine->evaluate(\"0x10001\")"
- << "engine->evaluate(\"NaN\")"
- << "engine->evaluate(\"Infinity\")"
- << "engine->evaluate(\"-Infinity\")"
- << "engine->evaluate(\"'ciao'\")"
- << "engine->evaluate(\"''\")"
- << "engine->evaluate(\"'0'\")"
- << "engine->evaluate(\"'123'\")"
- << "engine->evaluate(\"'12.4'\")"
- << "engine->nullValue()"
- << "engine->undefinedValue()";
- }
- newRow(expr) << isValid.contains(expr);
-}
-
-void tst_QScriptValue::isValid_test(const char*, const QScriptValue& value)
-{
- QFETCH(bool, expected);
- QCOMPARE(value.isValid(), expected);
- QCOMPARE(value.isValid(), expected);
-}
-
-DEFINE_TEST_FUNCTION(isValid)
-
-
-void tst_QScriptValue::isBool_initData()
-{
- QTest::addColumn<bool>("expected");
- initScriptValues();
-}
-
-void tst_QScriptValue::isBool_makeData(const char* expr)
-{
- static QSet<QString> isBool;
- if (isBool.isEmpty()) {
- isBool << "QScriptValue(true)"
- << "QScriptValue(false)"
- << "QScriptValue(0, true)"
- << "QScriptValue(0, false)"
- << "QScriptValue(engine, true)"
- << "QScriptValue(engine, false)"
- << "engine->evaluate(\"true\")"
- << "engine->evaluate(\"false\")";
- }
- newRow(expr) << isBool.contains(expr);
-}
-
-void tst_QScriptValue::isBool_test(const char*, const QScriptValue& value)
-{
- QFETCH(bool, expected);
- QCOMPARE(value.isBool(), expected);
- QCOMPARE(value.isBool(), expected);
-}
-
-DEFINE_TEST_FUNCTION(isBool)
-
-
-void tst_QScriptValue::isBoolean_initData()
-{
- QTest::addColumn<bool>("expected");
- initScriptValues();
-}
-
-void tst_QScriptValue::isBoolean_makeData(const char* expr)
-{
- static QSet<QString> isBoolean;
- if (isBoolean.isEmpty()) {
- isBoolean << "QScriptValue(true)"
- << "QScriptValue(false)"
- << "QScriptValue(0, true)"
- << "QScriptValue(0, false)"
- << "QScriptValue(engine, true)"
- << "QScriptValue(engine, false)"
- << "engine->evaluate(\"true\")"
- << "engine->evaluate(\"false\")";
- }
- newRow(expr) << isBoolean.contains(expr);
-}
-
-void tst_QScriptValue::isBoolean_test(const char*, const QScriptValue& value)
-{
- QFETCH(bool, expected);
- QCOMPARE(value.isBoolean(), expected);
- QCOMPARE(value.isBoolean(), expected);
-}
-
-DEFINE_TEST_FUNCTION(isBoolean)
-
-
-void tst_QScriptValue::isNumber_initData()
-{
- QTest::addColumn<bool>("expected");
- initScriptValues();
-}
-
-void tst_QScriptValue::isNumber_makeData(const char* expr)
-{
- static QSet<QString> isNumber;
- if (isNumber.isEmpty()) {
- isNumber << "QScriptValue(int(122))"
- << "QScriptValue(uint(124))"
- << "QScriptValue(0)"
- << "QScriptValue(0.0)"
- << "QScriptValue(123.0)"
- << "QScriptValue(6.37e-8)"
- << "QScriptValue(-6.37e-8)"
- << "QScriptValue(0x43211234)"
- << "QScriptValue(0x10000)"
- << "QScriptValue(0x10001)"
- << "QScriptValue(qSNaN())"
- << "QScriptValue(qQNaN())"
- << "QScriptValue(qInf())"
- << "QScriptValue(-qInf())"
- << "QScriptValue(0, int(122))"
- << "QScriptValue(0, uint(124))"
- << "QScriptValue(0, 0)"
- << "QScriptValue(0, 0.0)"
- << "QScriptValue(0, 123.0)"
- << "QScriptValue(0, 6.37e-8)"
- << "QScriptValue(0, -6.37e-8)"
- << "QScriptValue(0, 0x43211234)"
- << "QScriptValue(0, 0x10000)"
- << "QScriptValue(0, 0x10001)"
- << "QScriptValue(0, qSNaN())"
- << "QScriptValue(0, qQNaN())"
- << "QScriptValue(0, qInf())"
- << "QScriptValue(0, -qInf())"
- << "QScriptValue(engine, int(122))"
- << "QScriptValue(engine, uint(124))"
- << "QScriptValue(engine, 0)"
- << "QScriptValue(engine, 0.0)"
- << "QScriptValue(engine, 123.0)"
- << "QScriptValue(engine, 6.37e-8)"
- << "QScriptValue(engine, -6.37e-8)"
- << "QScriptValue(engine, 0x43211234)"
- << "QScriptValue(engine, 0x10000)"
- << "QScriptValue(engine, 0x10001)"
- << "QScriptValue(engine, qSNaN())"
- << "QScriptValue(engine, qQNaN())"
- << "QScriptValue(engine, qInf())"
- << "QScriptValue(engine, -qInf())"
- << "engine->evaluate(\"a = new Object(); a.foo = 22; a.foo\")"
- << "engine->evaluate(\"122\")"
- << "engine->evaluate(\"124\")"
- << "engine->evaluate(\"0\")"
- << "engine->evaluate(\"0.0\")"
- << "engine->evaluate(\"123.0\")"
- << "engine->evaluate(\"6.37e-8\")"
- << "engine->evaluate(\"-6.37e-8\")"
- << "engine->evaluate(\"0x43211234\")"
- << "engine->evaluate(\"0x10000\")"
- << "engine->evaluate(\"0x10001\")"
- << "engine->evaluate(\"NaN\")"
- << "engine->evaluate(\"Infinity\")"
- << "engine->evaluate(\"-Infinity\")";
- }
- newRow(expr) << isNumber.contains(expr);
-}
-
-void tst_QScriptValue::isNumber_test(const char*, const QScriptValue& value)
-{
- QFETCH(bool, expected);
- QCOMPARE(value.isNumber(), expected);
- QCOMPARE(value.isNumber(), expected);
-}
-
-DEFINE_TEST_FUNCTION(isNumber)
-
-
-void tst_QScriptValue::isFunction_initData()
-{
- QTest::addColumn<bool>("expected");
- initScriptValues();
-}
-
-void tst_QScriptValue::isFunction_makeData(const char* expr)
-{
- static QSet<QString> isFunction;
- if (isFunction.isEmpty()) {
- isFunction << "engine->evaluate(\"Function.prototype\")"
- << "engine->evaluate(\"Object\")"
- << "engine->evaluate(\"Array\")"
- << "engine->evaluate(\"Number\")"
- << "engine->evaluate(\"Function\")"
- << "engine->evaluate(\"(function() { return 1; })\")"
- << "engine->evaluate(\"(function() { return 'ciao'; })\")"
- << "engine->evaluate(\"(function() { throw new Error('foo'); })\")"
- << "engine->evaluate(\"/foo/\")";
- }
- newRow(expr) << isFunction.contains(expr);
-}
-
-void tst_QScriptValue::isFunction_test(const char*, const QScriptValue& value)
-{
- QFETCH(bool, expected);
- QCOMPARE(value.isFunction(), expected);
- QCOMPARE(value.isFunction(), expected);
-}
-
-DEFINE_TEST_FUNCTION(isFunction)
-
-
-void tst_QScriptValue::isNull_initData()
-{
- QTest::addColumn<bool>("expected");
- initScriptValues();
-}
-
-void tst_QScriptValue::isNull_makeData(const char* expr)
-{
- static QSet<QString> isNull;
- if (isNull.isEmpty()) {
- isNull << "QScriptValue(QScriptValue::NullValue)"
- << "QScriptValue(0, QScriptValue::NullValue)"
- << "QScriptValue(engine, QScriptValue::NullValue)"
- << "engine->evaluate(\"null\")"
- << "engine->nullValue()";
- }
- newRow(expr) << isNull.contains(expr);
-}
-
-void tst_QScriptValue::isNull_test(const char*, const QScriptValue& value)
-{
- QFETCH(bool, expected);
- QCOMPARE(value.isNull(), expected);
- QCOMPARE(value.isNull(), expected);
-}
-
-DEFINE_TEST_FUNCTION(isNull)
-
-
-void tst_QScriptValue::isString_initData()
-{
- QTest::addColumn<bool>("expected");
- initScriptValues();
-}
-
-void tst_QScriptValue::isString_makeData(const char* expr)
-{
- static QSet<QString> isString;
- if (isString.isEmpty()) {
- isString << "QScriptValue(\"NaN\")"
- << "QScriptValue(\"Infinity\")"
- << "QScriptValue(\"-Infinity\")"
- << "QScriptValue(\"ciao\")"
- << "QScriptValue(QString::fromLatin1(\"ciao\"))"
- << "QScriptValue(QString(\"\"))"
- << "QScriptValue(QString())"
- << "QScriptValue(QString(\"0\"))"
- << "QScriptValue(QString(\"123\"))"
- << "QScriptValue(QString(\"12.4\"))"
- << "QScriptValue(0, \"NaN\")"
- << "QScriptValue(0, \"Infinity\")"
- << "QScriptValue(0, \"-Infinity\")"
- << "QScriptValue(0, \"ciao\")"
- << "QScriptValue(0, QString::fromLatin1(\"ciao\"))"
- << "QScriptValue(0, QString(\"\"))"
- << "QScriptValue(0, QString())"
- << "QScriptValue(0, QString(\"0\"))"
- << "QScriptValue(0, QString(\"123\"))"
- << "QScriptValue(0, QString(\"12.3\"))"
- << "QScriptValue(engine, \"NaN\")"
- << "QScriptValue(engine, \"Infinity\")"
- << "QScriptValue(engine, \"-Infinity\")"
- << "QScriptValue(engine, \"ciao\")"
- << "QScriptValue(engine, QString::fromLatin1(\"ciao\"))"
- << "QScriptValue(engine, QString(\"\"))"
- << "QScriptValue(engine, QString())"
- << "QScriptValue(engine, QString(\"0\"))"
- << "QScriptValue(engine, QString(\"123\"))"
- << "QScriptValue(engine, QString(\"1.23\"))"
- << "engine->evaluate(\"'ciao'\")"
- << "engine->evaluate(\"''\")"
- << "engine->evaluate(\"'0'\")"
- << "engine->evaluate(\"'123'\")"
- << "engine->evaluate(\"'12.4'\")";
- }
- newRow(expr) << isString.contains(expr);
-}
-
-void tst_QScriptValue::isString_test(const char*, const QScriptValue& value)
-{
- QFETCH(bool, expected);
- QCOMPARE(value.isString(), expected);
- QCOMPARE(value.isString(), expected);
-}
-
-DEFINE_TEST_FUNCTION(isString)
-
-
-void tst_QScriptValue::isUndefined_initData()
-{
- QTest::addColumn<bool>("expected");
- initScriptValues();
-}
-
-void tst_QScriptValue::isUndefined_makeData(const char* expr)
-{
- static QSet<QString> isUndefined;
- if (isUndefined.isEmpty()) {
- isUndefined << "QScriptValue(QScriptValue::UndefinedValue)"
- << "QScriptValue(0, QScriptValue::UndefinedValue)"
- << "QScriptValue(engine, QScriptValue::UndefinedValue)"
- << "engine->evaluate(\"{}\")"
- << "engine->evaluate(\"undefined\")"
- << "engine->undefinedValue()";
- }
- newRow(expr) << isUndefined.contains(expr);
-}
-
-void tst_QScriptValue::isUndefined_test(const char*, const QScriptValue& value)
-{
- QFETCH(bool, expected);
- QCOMPARE(value.isUndefined(), expected);
- QCOMPARE(value.isUndefined(), expected);
-}
-
-DEFINE_TEST_FUNCTION(isUndefined)
-
-
-
-
-
-void tst_QScriptValue::isObject_initData()
-{
- QTest::addColumn<bool>("expected");
- initScriptValues();
-}
-
-void tst_QScriptValue::isObject_makeData(const char* expr)
-{
- static QSet<QString> isObject;
- if (isObject.isEmpty()) {
- isObject << "engine->evaluate(\"[]\")"
- << "engine->evaluate(\"Object.prototype\")"
- << "engine->evaluate(\"Date.prototype\")"
- << "engine->evaluate(\"Array.prototype\")"
- << "engine->evaluate(\"Function.prototype\")"
- << "engine->evaluate(\"Error.prototype\")"
- << "engine->evaluate(\"Object\")"
- << "engine->evaluate(\"Array\")"
- << "engine->evaluate(\"Number\")"
- << "engine->evaluate(\"Function\")"
- << "engine->evaluate(\"(function() { return 1; })\")"
- << "engine->evaluate(\"(function() { return 'ciao'; })\")"
- << "engine->evaluate(\"(function() { throw new Error('foo'); })\")"
- << "engine->evaluate(\"/foo/\")"
- << "engine->evaluate(\"new Object()\")"
- << "engine->evaluate(\"new Array()\")"
- << "engine->evaluate(\"new Error()\")"
- << "engine->evaluate(\"Undefined\")"
- << "engine->evaluate(\"Null\")"
- << "engine->evaluate(\"True\")"
- << "engine->evaluate(\"False\")";
- }
- newRow(expr) << isObject.contains(expr);
-}
-
-void tst_QScriptValue::isObject_test(const char*, const QScriptValue& value)
-{
- QFETCH(bool, expected);
- QCOMPARE(value.isObject(), expected);
- QCOMPARE(value.isObject(), expected);
-}
-
-DEFINE_TEST_FUNCTION(isObject)
-
-
-void tst_QScriptValue::toString_initData()
-{
- QTest::addColumn<QString>("expected");
- initScriptValues();
-}
-
-void tst_QScriptValue::toString_makeData(const char* expr)
-{
- static QHash<QString, QString> toString;
- if (toString.isEmpty()) {
- toString.insert("QScriptValue()", "");
- toString.insert("QScriptValue(QScriptValue::UndefinedValue)", "undefined");
- toString.insert("QScriptValue(QScriptValue::NullValue)", "null");
- toString.insert("QScriptValue(true)", "true");
- toString.insert("QScriptValue(false)", "false");
- toString.insert("QScriptValue(int(122))", "122");
- toString.insert("QScriptValue(uint(124))", "124");
- toString.insert("QScriptValue(0)", "0");
- toString.insert("QScriptValue(0.0)", "0");
- toString.insert("QScriptValue(123.0)", "123");
- toString.insert("QScriptValue(6.37e-8)", "6.37e-8");
- toString.insert("QScriptValue(-6.37e-8)", "-6.37e-8");
- toString.insert("QScriptValue(0x43211234)", "1126240820");
- toString.insert("QScriptValue(0x10000)", "65536");
- toString.insert("QScriptValue(0x10001)", "65537");
- toString.insert("QScriptValue(qSNaN())", "NaN");
- toString.insert("QScriptValue(qQNaN())", "NaN");
- toString.insert("QScriptValue(qInf())", "Infinity");
- toString.insert("QScriptValue(-qInf())", "-Infinity");
- toString.insert("QScriptValue(\"NaN\")", "NaN");
- toString.insert("QScriptValue(\"Infinity\")", "Infinity");
- toString.insert("QScriptValue(\"-Infinity\")", "-Infinity");
- toString.insert("QScriptValue(\"ciao\")", "ciao");
- toString.insert("QScriptValue(QString::fromLatin1(\"ciao\"))", "ciao");
- toString.insert("QScriptValue(QString(\"\"))", "");
- toString.insert("QScriptValue(QString())", "");
- toString.insert("QScriptValue(QString(\"0\"))", "0");
- toString.insert("QScriptValue(QString(\"123\"))", "123");
- toString.insert("QScriptValue(QString(\"12.4\"))", "12.4");
- toString.insert("QScriptValue(0, QScriptValue::UndefinedValue)", "undefined");
- toString.insert("QScriptValue(0, QScriptValue::NullValue)", "null");
- toString.insert("QScriptValue(0, true)", "true");
- toString.insert("QScriptValue(0, false)", "false");
- toString.insert("QScriptValue(0, int(122))", "122");
- toString.insert("QScriptValue(0, uint(124))", "124");
- toString.insert("QScriptValue(0, 0)", "0");
- toString.insert("QScriptValue(0, 0.0)", "0");
- toString.insert("QScriptValue(0, 123.0)", "123");
- toString.insert("QScriptValue(0, 6.37e-8)", "6.37e-8");
- toString.insert("QScriptValue(0, -6.37e-8)", "-6.37e-8");
- toString.insert("QScriptValue(0, 0x43211234)", "1126240820");
- toString.insert("QScriptValue(0, 0x10000)", "65536");
- toString.insert("QScriptValue(0, 0x10001)", "65537");
- toString.insert("QScriptValue(0, qSNaN())", "NaN");
- toString.insert("QScriptValue(0, qQNaN())", "NaN");
- toString.insert("QScriptValue(0, qInf())", "Infinity");
- toString.insert("QScriptValue(0, -qInf())", "-Infinity");
- toString.insert("QScriptValue(0, \"NaN\")", "NaN");
- toString.insert("QScriptValue(0, \"Infinity\")", "Infinity");
- toString.insert("QScriptValue(0, \"-Infinity\")", "-Infinity");
- toString.insert("QScriptValue(0, \"ciao\")", "ciao");
- toString.insert("QScriptValue(0, QString::fromLatin1(\"ciao\"))", "ciao");
- toString.insert("QScriptValue(0, QString(\"\"))", "");
- toString.insert("QScriptValue(0, QString())", "");
- toString.insert("QScriptValue(0, QString(\"0\"))", "0");
- toString.insert("QScriptValue(0, QString(\"123\"))", "123");
- toString.insert("QScriptValue(0, QString(\"12.3\"))", "12.3");
- toString.insert("QScriptValue(engine, QScriptValue::UndefinedValue)", "undefined");
- toString.insert("QScriptValue(engine, QScriptValue::NullValue)", "null");
- toString.insert("QScriptValue(engine, true)", "true");
- toString.insert("QScriptValue(engine, false)", "false");
- toString.insert("QScriptValue(engine, int(122))", "122");
- toString.insert("QScriptValue(engine, uint(124))", "124");
- toString.insert("QScriptValue(engine, 0)", "0");
- toString.insert("QScriptValue(engine, 0.0)", "0");
- toString.insert("QScriptValue(engine, 123.0)", "123");
- toString.insert("QScriptValue(engine, 6.37e-8)", "6.37e-8");
- toString.insert("QScriptValue(engine, -6.37e-8)", "-6.37e-8");
- toString.insert("QScriptValue(engine, 0x43211234)", "1126240820");
- toString.insert("QScriptValue(engine, 0x10000)", "65536");
- toString.insert("QScriptValue(engine, 0x10001)", "65537");
- toString.insert("QScriptValue(engine, qSNaN())", "NaN");
- toString.insert("QScriptValue(engine, qQNaN())", "NaN");
- toString.insert("QScriptValue(engine, qInf())", "Infinity");
- toString.insert("QScriptValue(engine, -qInf())", "-Infinity");
- toString.insert("QScriptValue(engine, \"NaN\")", "NaN");
- toString.insert("QScriptValue(engine, \"Infinity\")", "Infinity");
- toString.insert("QScriptValue(engine, \"-Infinity\")", "-Infinity");
- toString.insert("QScriptValue(engine, \"ciao\")", "ciao");
- toString.insert("QScriptValue(engine, QString::fromLatin1(\"ciao\"))", "ciao");
- toString.insert("QScriptValue(engine, QString(\"\"))", "");
- toString.insert("QScriptValue(engine, QString())", "");
- toString.insert("QScriptValue(engine, QString(\"0\"))", "0");
- toString.insert("QScriptValue(engine, QString(\"123\"))", "123");
- toString.insert("QScriptValue(engine, QString(\"1.23\"))", "1.23");
- toString.insert("engine->evaluate(\"[]\")", "");
- toString.insert("engine->evaluate(\"{}\")", "undefined");
- toString.insert("engine->evaluate(\"Object.prototype\")", "[object Object]");
- toString.insert("engine->evaluate(\"Date.prototype\")", "Invalid Date");
- toString.insert("engine->evaluate(\"Array.prototype\")", "");
- toString.insert("engine->evaluate(\"Function.prototype\")", "function () {\n [native code]\n}");
- toString.insert("engine->evaluate(\"Error.prototype\")", "Error: Unknown error");
- toString.insert("engine->evaluate(\"Object\")", "function Object() {\n [native code]\n}");
- toString.insert("engine->evaluate(\"Array\")", "function Array() {\n [native code]\n}");
- toString.insert("engine->evaluate(\"Number\")", "function Number() {\n [native code]\n}");
- toString.insert("engine->evaluate(\"Function\")", "function Function() {\n [native code]\n}");
- toString.insert("engine->evaluate(\"(function() { return 1; })\")", "function () { return 1; }");
- toString.insert("engine->evaluate(\"(function() { return 'ciao'; })\")", "function () { return 'ciao'; }");
- toString.insert("engine->evaluate(\"(function() { throw new Error('foo'); })\")", "function () { throw new Error('foo'); }");
- toString.insert("engine->evaluate(\"/foo/\")", "/foo/");
- toString.insert("engine->evaluate(\"new Object()\")", "[object Object]");
- toString.insert("engine->evaluate(\"new Array()\")", "");
- toString.insert("engine->evaluate(\"new Error()\")", "Error: Unknown error");
- toString.insert("engine->evaluate(\"a = new Object(); a.foo = 22; a.foo\")", "22");
- toString.insert("engine->evaluate(\"Undefined\")", "ReferenceError: Can't find variable: Undefined");
- toString.insert("engine->evaluate(\"Null\")", "ReferenceError: Can't find variable: Null");
- toString.insert("engine->evaluate(\"True\")", "ReferenceError: Can't find variable: True");
- toString.insert("engine->evaluate(\"False\")", "ReferenceError: Can't find variable: False");
- toString.insert("engine->evaluate(\"undefined\")", "undefined");
- toString.insert("engine->evaluate(\"null\")", "null");
- toString.insert("engine->evaluate(\"true\")", "true");
- toString.insert("engine->evaluate(\"false\")", "false");
- toString.insert("engine->evaluate(\"122\")", "122");
- toString.insert("engine->evaluate(\"124\")", "124");
- toString.insert("engine->evaluate(\"0\")", "0");
- toString.insert("engine->evaluate(\"0.0\")", "0");
- toString.insert("engine->evaluate(\"123.0\")", "123");
- toString.insert("engine->evaluate(\"6.37e-8\")", "6.37e-8");
- toString.insert("engine->evaluate(\"-6.37e-8\")", "-6.37e-8");
- toString.insert("engine->evaluate(\"0x43211234\")", "1126240820");
- toString.insert("engine->evaluate(\"0x10000\")", "65536");
- toString.insert("engine->evaluate(\"0x10001\")", "65537");
- toString.insert("engine->evaluate(\"NaN\")", "NaN");
- toString.insert("engine->evaluate(\"Infinity\")", "Infinity");
- toString.insert("engine->evaluate(\"-Infinity\")", "-Infinity");
- toString.insert("engine->evaluate(\"'ciao'\")", "ciao");
- toString.insert("engine->evaluate(\"''\")", "");
- toString.insert("engine->evaluate(\"'0'\")", "0");
- toString.insert("engine->evaluate(\"'123'\")", "123");
- toString.insert("engine->evaluate(\"'12.4'\")", "12.4");
- toString.insert("engine->nullValue()", "null");
- toString.insert("engine->undefinedValue()", "undefined");
- }
- newRow(expr) << toString.value(expr);
-}
-
-void tst_QScriptValue::toString_test(const char*, const QScriptValue& value)
-{
- QFETCH(QString, expected);
- QCOMPARE(value.toString(), expected);
- QCOMPARE(value.toString(), expected);
-}
-
-DEFINE_TEST_FUNCTION(toString)
-
-
-void tst_QScriptValue::toNumber_initData()
-{
- QTest::addColumn<qsreal>("expected");
- initScriptValues();
-}
-
-void tst_QScriptValue::toNumber_makeData(const char* expr)
-{
- static QHash<QString, qsreal> toNumber;
- if (toNumber.isEmpty()) {
- toNumber.insert("QScriptValue()", 0);
- toNumber.insert("QScriptValue(QScriptValue::UndefinedValue)", qQNaN());
- toNumber.insert("QScriptValue(QScriptValue::NullValue)", 0);
- toNumber.insert("QScriptValue(true)", 1);
- toNumber.insert("QScriptValue(false)", 0);
- toNumber.insert("QScriptValue(int(122))", 122);
- toNumber.insert("QScriptValue(uint(124))", 124);
- toNumber.insert("QScriptValue(0)", 0);
- toNumber.insert("QScriptValue(0.0)", 0);
- toNumber.insert("QScriptValue(123.0)", 123);
- toNumber.insert("QScriptValue(6.37e-8)", 6.369999999999999e-08);
- toNumber.insert("QScriptValue(-6.37e-8)", -6.369999999999999e-08);
- toNumber.insert("QScriptValue(0x43211234)", 1126240820);
- toNumber.insert("QScriptValue(0x10000)", 65536);
- toNumber.insert("QScriptValue(0x10001)", 65537);
- toNumber.insert("QScriptValue(qSNaN())", qQNaN());
- toNumber.insert("QScriptValue(qQNaN())", qQNaN());
- toNumber.insert("QScriptValue(qInf())", qInf());
- toNumber.insert("QScriptValue(-qInf())", qInf());
- toNumber.insert("QScriptValue(\"NaN\")", qQNaN());
- toNumber.insert("QScriptValue(\"Infinity\")", qInf());
- toNumber.insert("QScriptValue(\"-Infinity\")", qInf());
- toNumber.insert("QScriptValue(\"ciao\")", qQNaN());
- toNumber.insert("QScriptValue(QString::fromLatin1(\"ciao\"))", qQNaN());
- toNumber.insert("QScriptValue(QString(\"\"))", 0);
- toNumber.insert("QScriptValue(QString())", 0);
- toNumber.insert("QScriptValue(QString(\"0\"))", 0);
- toNumber.insert("QScriptValue(QString(\"123\"))", 123);
- toNumber.insert("QScriptValue(QString(\"12.4\"))", 12.4);
- toNumber.insert("QScriptValue(0, QScriptValue::UndefinedValue)", qQNaN());
- toNumber.insert("QScriptValue(0, QScriptValue::NullValue)", 0);
- toNumber.insert("QScriptValue(0, true)", 1);
- toNumber.insert("QScriptValue(0, false)", 0);
- toNumber.insert("QScriptValue(0, int(122))", 122);
- toNumber.insert("QScriptValue(0, uint(124))", 124);
- toNumber.insert("QScriptValue(0, 0)", 0);
- toNumber.insert("QScriptValue(0, 0.0)", 0);
- toNumber.insert("QScriptValue(0, 123.0)", 123);
- toNumber.insert("QScriptValue(0, 6.37e-8)", 6.369999999999999e-08);
- toNumber.insert("QScriptValue(0, -6.37e-8)", -6.369999999999999e-08);
- toNumber.insert("QScriptValue(0, 0x43211234)", 1126240820);
- toNumber.insert("QScriptValue(0, 0x10000)", 65536);
- toNumber.insert("QScriptValue(0, 0x10001)", 65537);
- toNumber.insert("QScriptValue(0, qSNaN())", qQNaN());
- toNumber.insert("QScriptValue(0, qQNaN())", qQNaN());
- toNumber.insert("QScriptValue(0, qInf())", qInf());
- toNumber.insert("QScriptValue(0, -qInf())", qInf());
- toNumber.insert("QScriptValue(0, \"NaN\")", qQNaN());
- toNumber.insert("QScriptValue(0, \"Infinity\")", qInf());
- toNumber.insert("QScriptValue(0, \"-Infinity\")", qInf());
- toNumber.insert("QScriptValue(0, \"ciao\")", qQNaN());
- toNumber.insert("QScriptValue(0, QString::fromLatin1(\"ciao\"))", qQNaN());
- toNumber.insert("QScriptValue(0, QString(\"\"))", 0);
- toNumber.insert("QScriptValue(0, QString())", 0);
- toNumber.insert("QScriptValue(0, QString(\"0\"))", 0);
- toNumber.insert("QScriptValue(0, QString(\"123\"))", 123);
- toNumber.insert("QScriptValue(0, QString(\"12.3\"))", 12.3);
- toNumber.insert("QScriptValue(engine, QScriptValue::UndefinedValue)", qQNaN());
- toNumber.insert("QScriptValue(engine, QScriptValue::NullValue)", 0);
- toNumber.insert("QScriptValue(engine, true)", 1);
- toNumber.insert("QScriptValue(engine, false)", 0);
- toNumber.insert("QScriptValue(engine, int(122))", 122);
- toNumber.insert("QScriptValue(engine, uint(124))", 124);
- toNumber.insert("QScriptValue(engine, 0)", 0);
- toNumber.insert("QScriptValue(engine, 0.0)", 0);
- toNumber.insert("QScriptValue(engine, 123.0)", 123);
- toNumber.insert("QScriptValue(engine, 6.37e-8)", 6.369999999999999e-08);
- toNumber.insert("QScriptValue(engine, -6.37e-8)", -6.369999999999999e-08);
- toNumber.insert("QScriptValue(engine, 0x43211234)", 1126240820);
- toNumber.insert("QScriptValue(engine, 0x10000)", 65536);
- toNumber.insert("QScriptValue(engine, 0x10001)", 65537);
- toNumber.insert("QScriptValue(engine, qSNaN())", qQNaN());
- toNumber.insert("QScriptValue(engine, qQNaN())", qQNaN());
- toNumber.insert("QScriptValue(engine, qInf())", qInf());
- toNumber.insert("QScriptValue(engine, -qInf())", qInf());
- toNumber.insert("QScriptValue(engine, \"NaN\")", qQNaN());
- toNumber.insert("QScriptValue(engine, \"Infinity\")", qInf());
- toNumber.insert("QScriptValue(engine, \"-Infinity\")", qInf());
- toNumber.insert("QScriptValue(engine, \"ciao\")", qQNaN());
- toNumber.insert("QScriptValue(engine, QString::fromLatin1(\"ciao\"))", qQNaN());
- toNumber.insert("QScriptValue(engine, QString(\"\"))", 0);
- toNumber.insert("QScriptValue(engine, QString())", 0);
- toNumber.insert("QScriptValue(engine, QString(\"0\"))", 0);
- toNumber.insert("QScriptValue(engine, QString(\"123\"))", 123);
- toNumber.insert("QScriptValue(engine, QString(\"1.23\"))", 1.23);
- toNumber.insert("engine->evaluate(\"[]\")", 0);
- toNumber.insert("engine->evaluate(\"{}\")", qQNaN());
- toNumber.insert("engine->evaluate(\"Object.prototype\")", qQNaN());
- toNumber.insert("engine->evaluate(\"Date.prototype\")", qQNaN());
- toNumber.insert("engine->evaluate(\"Array.prototype\")", 0);
- toNumber.insert("engine->evaluate(\"Function.prototype\")", qQNaN());
- toNumber.insert("engine->evaluate(\"Error.prototype\")", qQNaN());
- toNumber.insert("engine->evaluate(\"Object\")", qQNaN());
- toNumber.insert("engine->evaluate(\"Array\")", qQNaN());
- toNumber.insert("engine->evaluate(\"Number\")", qQNaN());
- toNumber.insert("engine->evaluate(\"Function\")", qQNaN());
- toNumber.insert("engine->evaluate(\"(function() { return 1; })\")", qQNaN());
- toNumber.insert("engine->evaluate(\"(function() { return 'ciao'; })\")", qQNaN());
- toNumber.insert("engine->evaluate(\"(function() { throw new Error('foo'); })\")", qQNaN());
- toNumber.insert("engine->evaluate(\"/foo/\")", qQNaN());
- toNumber.insert("engine->evaluate(\"new Object()\")", qQNaN());
- toNumber.insert("engine->evaluate(\"new Array()\")", 0);
- toNumber.insert("engine->evaluate(\"new Error()\")", qQNaN());
- toNumber.insert("engine->evaluate(\"a = new Object(); a.foo = 22; a.foo\")", 22);
- toNumber.insert("engine->evaluate(\"Undefined\")", qQNaN());
- toNumber.insert("engine->evaluate(\"Null\")", qQNaN());
- toNumber.insert("engine->evaluate(\"True\")", qQNaN());
- toNumber.insert("engine->evaluate(\"False\")", qQNaN());
- toNumber.insert("engine->evaluate(\"undefined\")", qQNaN());
- toNumber.insert("engine->evaluate(\"null\")", 0);
- toNumber.insert("engine->evaluate(\"true\")", 1);
- toNumber.insert("engine->evaluate(\"false\")", 0);
- toNumber.insert("engine->evaluate(\"122\")", 122);
- toNumber.insert("engine->evaluate(\"124\")", 124);
- toNumber.insert("engine->evaluate(\"0\")", 0);
- toNumber.insert("engine->evaluate(\"0.0\")", 0);
- toNumber.insert("engine->evaluate(\"123.0\")", 123);
- toNumber.insert("engine->evaluate(\"6.37e-8\")", 6.369999999999999e-08);
- toNumber.insert("engine->evaluate(\"-6.37e-8\")", -6.369999999999999e-08);
- toNumber.insert("engine->evaluate(\"0x43211234\")", 1126240820);
- toNumber.insert("engine->evaluate(\"0x10000\")", 65536);
- toNumber.insert("engine->evaluate(\"0x10001\")", 65537);
- toNumber.insert("engine->evaluate(\"NaN\")", qQNaN());
- toNumber.insert("engine->evaluate(\"Infinity\")", qInf());
- toNumber.insert("engine->evaluate(\"-Infinity\")", qInf());
- toNumber.insert("engine->evaluate(\"'ciao'\")", qQNaN());
- toNumber.insert("engine->evaluate(\"''\")", 0);
- toNumber.insert("engine->evaluate(\"'0'\")", 0);
- toNumber.insert("engine->evaluate(\"'123'\")", 123);
- toNumber.insert("engine->evaluate(\"'12.4'\")", 12.4);
- toNumber.insert("engine->nullValue()", 0);
- toNumber.insert("engine->undefinedValue()", qQNaN());
- }
- newRow(expr) << toNumber.value(expr);
-}
-
-void tst_QScriptValue::toNumber_test(const char*, const QScriptValue& value)
-{
- QFETCH(qsreal, expected);
- if (qIsNaN(expected)) {
- QVERIFY(qIsNaN(value.toNumber()));
- return;
- }
- if (qIsInf(expected)) {
- QVERIFY(qIsInf(value.toNumber()));
- QVERIFY(qIsInf(value.toNumber()));
- return;
- }
- QCOMPARE(value.toNumber(), expected);
- QCOMPARE(value.toNumber(), expected);
-}
-
-DEFINE_TEST_FUNCTION(toNumber)
-
-
-void tst_QScriptValue::toBool_initData()
-{
- QTest::addColumn<bool>("expected");
- initScriptValues();
-}
-
-void tst_QScriptValue::toBool_makeData(const char* expr)
-{
- static QHash<QString, bool> toBool;
- if (toBool.isEmpty()) {
- toBool.insert("QScriptValue()", false);
- toBool.insert("QScriptValue(QScriptValue::UndefinedValue)", false);
- toBool.insert("QScriptValue(QScriptValue::NullValue)", false);
- toBool.insert("QScriptValue(true)", true);
- toBool.insert("QScriptValue(false)", false);
- toBool.insert("QScriptValue(int(122))", true);
- toBool.insert("QScriptValue(uint(124))", true);
- toBool.insert("QScriptValue(0)", false);
- toBool.insert("QScriptValue(0.0)", false);
- toBool.insert("QScriptValue(123.0)", true);
- toBool.insert("QScriptValue(6.37e-8)", true);
- toBool.insert("QScriptValue(-6.37e-8)", true);
- toBool.insert("QScriptValue(0x43211234)", true);
- toBool.insert("QScriptValue(0x10000)", true);
- toBool.insert("QScriptValue(0x10001)", true);
- toBool.insert("QScriptValue(qSNaN())", false);
- toBool.insert("QScriptValue(qQNaN())", false);
- toBool.insert("QScriptValue(qInf())", true);
- toBool.insert("QScriptValue(-qInf())", true);
- toBool.insert("QScriptValue(\"NaN\")", true);
- toBool.insert("QScriptValue(\"Infinity\")", true);
- toBool.insert("QScriptValue(\"-Infinity\")", true);
- toBool.insert("QScriptValue(\"ciao\")", true);
- toBool.insert("QScriptValue(QString::fromLatin1(\"ciao\"))", true);
- toBool.insert("QScriptValue(QString(\"\"))", false);
- toBool.insert("QScriptValue(QString())", false);
- toBool.insert("QScriptValue(QString(\"0\"))", true);
- toBool.insert("QScriptValue(QString(\"123\"))", true);
- toBool.insert("QScriptValue(QString(\"12.4\"))", true);
- toBool.insert("QScriptValue(0, QScriptValue::UndefinedValue)", false);
- toBool.insert("QScriptValue(0, QScriptValue::NullValue)", false);
- toBool.insert("QScriptValue(0, true)", true);
- toBool.insert("QScriptValue(0, false)", false);
- toBool.insert("QScriptValue(0, int(122))", true);
- toBool.insert("QScriptValue(0, uint(124))", true);
- toBool.insert("QScriptValue(0, 0)", false);
- toBool.insert("QScriptValue(0, 0.0)", false);
- toBool.insert("QScriptValue(0, 123.0)", true);
- toBool.insert("QScriptValue(0, 6.37e-8)", true);
- toBool.insert("QScriptValue(0, -6.37e-8)", true);
- toBool.insert("QScriptValue(0, 0x43211234)", true);
- toBool.insert("QScriptValue(0, 0x10000)", true);
- toBool.insert("QScriptValue(0, 0x10001)", true);
- toBool.insert("QScriptValue(0, qSNaN())", false);
- toBool.insert("QScriptValue(0, qQNaN())", false);
- toBool.insert("QScriptValue(0, qInf())", true);
- toBool.insert("QScriptValue(0, -qInf())", true);
- toBool.insert("QScriptValue(0, \"NaN\")", true);
- toBool.insert("QScriptValue(0, \"Infinity\")", true);
- toBool.insert("QScriptValue(0, \"-Infinity\")", true);
- toBool.insert("QScriptValue(0, \"ciao\")", true);
- toBool.insert("QScriptValue(0, QString::fromLatin1(\"ciao\"))", true);
- toBool.insert("QScriptValue(0, QString(\"\"))", false);
- toBool.insert("QScriptValue(0, QString())", false);
- toBool.insert("QScriptValue(0, QString(\"0\"))", true);
- toBool.insert("QScriptValue(0, QString(\"123\"))", true);
- toBool.insert("QScriptValue(0, QString(\"12.3\"))", true);
- toBool.insert("QScriptValue(engine, QScriptValue::UndefinedValue)", false);
- toBool.insert("QScriptValue(engine, QScriptValue::NullValue)", false);
- toBool.insert("QScriptValue(engine, true)", true);
- toBool.insert("QScriptValue(engine, false)", false);
- toBool.insert("QScriptValue(engine, int(122))", true);
- toBool.insert("QScriptValue(engine, uint(124))", true);
- toBool.insert("QScriptValue(engine, 0)", false);
- toBool.insert("QScriptValue(engine, 0.0)", false);
- toBool.insert("QScriptValue(engine, 123.0)", true);
- toBool.insert("QScriptValue(engine, 6.37e-8)", true);
- toBool.insert("QScriptValue(engine, -6.37e-8)", true);
- toBool.insert("QScriptValue(engine, 0x43211234)", true);
- toBool.insert("QScriptValue(engine, 0x10000)", true);
- toBool.insert("QScriptValue(engine, 0x10001)", true);
- toBool.insert("QScriptValue(engine, qSNaN())", false);
- toBool.insert("QScriptValue(engine, qQNaN())", false);
- toBool.insert("QScriptValue(engine, qInf())", true);
- toBool.insert("QScriptValue(engine, -qInf())", true);
- toBool.insert("QScriptValue(engine, \"NaN\")", true);
- toBool.insert("QScriptValue(engine, \"Infinity\")", true);
- toBool.insert("QScriptValue(engine, \"-Infinity\")", true);
- toBool.insert("QScriptValue(engine, \"ciao\")", true);
- toBool.insert("QScriptValue(engine, QString::fromLatin1(\"ciao\"))", true);
- toBool.insert("QScriptValue(engine, QString(\"\"))", false);
- toBool.insert("QScriptValue(engine, QString())", false);
- toBool.insert("QScriptValue(engine, QString(\"0\"))", true);
- toBool.insert("QScriptValue(engine, QString(\"123\"))", true);
- toBool.insert("QScriptValue(engine, QString(\"1.23\"))", true);
- toBool.insert("engine->evaluate(\"[]\")", true);
- toBool.insert("engine->evaluate(\"{}\")", false);
- toBool.insert("engine->evaluate(\"Object.prototype\")", true);
- toBool.insert("engine->evaluate(\"Date.prototype\")", true);
- toBool.insert("engine->evaluate(\"Array.prototype\")", true);
- toBool.insert("engine->evaluate(\"Function.prototype\")", true);
- toBool.insert("engine->evaluate(\"Error.prototype\")", true);
- toBool.insert("engine->evaluate(\"Object\")", true);
- toBool.insert("engine->evaluate(\"Array\")", true);
- toBool.insert("engine->evaluate(\"Number\")", true);
- toBool.insert("engine->evaluate(\"Function\")", true);
- toBool.insert("engine->evaluate(\"(function() { return 1; })\")", true);
- toBool.insert("engine->evaluate(\"(function() { return 'ciao'; })\")", true);
- toBool.insert("engine->evaluate(\"(function() { throw new Error('foo'); })\")", true);
- toBool.insert("engine->evaluate(\"/foo/\")", true);
- toBool.insert("engine->evaluate(\"new Object()\")", true);
- toBool.insert("engine->evaluate(\"new Array()\")", true);
- toBool.insert("engine->evaluate(\"new Error()\")", true);
- toBool.insert("engine->evaluate(\"a = new Object(); a.foo = 22; a.foo\")", true);
- toBool.insert("engine->evaluate(\"Undefined\")", true);
- toBool.insert("engine->evaluate(\"Null\")", true);
- toBool.insert("engine->evaluate(\"True\")", true);
- toBool.insert("engine->evaluate(\"False\")", true);
- toBool.insert("engine->evaluate(\"undefined\")", false);
- toBool.insert("engine->evaluate(\"null\")", false);
- toBool.insert("engine->evaluate(\"true\")", true);
- toBool.insert("engine->evaluate(\"false\")", false);
- toBool.insert("engine->evaluate(\"122\")", true);
- toBool.insert("engine->evaluate(\"124\")", true);
- toBool.insert("engine->evaluate(\"0\")", false);
- toBool.insert("engine->evaluate(\"0.0\")", false);
- toBool.insert("engine->evaluate(\"123.0\")", true);
- toBool.insert("engine->evaluate(\"6.37e-8\")", true);
- toBool.insert("engine->evaluate(\"-6.37e-8\")", true);
- toBool.insert("engine->evaluate(\"0x43211234\")", true);
- toBool.insert("engine->evaluate(\"0x10000\")", true);
- toBool.insert("engine->evaluate(\"0x10001\")", true);
- toBool.insert("engine->evaluate(\"NaN\")", false);
- toBool.insert("engine->evaluate(\"Infinity\")", true);
- toBool.insert("engine->evaluate(\"-Infinity\")", true);
- toBool.insert("engine->evaluate(\"'ciao'\")", true);
- toBool.insert("engine->evaluate(\"''\")", false);
- toBool.insert("engine->evaluate(\"'0'\")", true);
- toBool.insert("engine->evaluate(\"'123'\")", true);
- toBool.insert("engine->evaluate(\"'12.4'\")", true);
- toBool.insert("engine->nullValue()", false);
- toBool.insert("engine->undefinedValue()", false);
- }
- newRow(expr) << toBool.value(expr);
-}
-
-void tst_QScriptValue::toBool_test(const char*, const QScriptValue& value)
-{
- QFETCH(bool, expected);
- QCOMPARE(value.toBool(), expected);
- QCOMPARE(value.toBool(), expected);
-}
-
-DEFINE_TEST_FUNCTION(toBool)
-
-
-void tst_QScriptValue::toBoolean_initData()
-{
- QTest::addColumn<bool>("expected");
- initScriptValues();
-}
-
-void tst_QScriptValue::toBoolean_makeData(const char* expr)
-{
- static QHash<QString, bool> toBoolean;
- if (toBoolean.isEmpty()) {
- toBoolean.insert("QScriptValue()", false);
- toBoolean.insert("QScriptValue(QScriptValue::UndefinedValue)", false);
- toBoolean.insert("QScriptValue(QScriptValue::NullValue)", false);
- toBoolean.insert("QScriptValue(true)", true);
- toBoolean.insert("QScriptValue(false)", false);
- toBoolean.insert("QScriptValue(int(122))", true);
- toBoolean.insert("QScriptValue(uint(124))", true);
- toBoolean.insert("QScriptValue(0)", false);
- toBoolean.insert("QScriptValue(0.0)", false);
- toBoolean.insert("QScriptValue(123.0)", true);
- toBoolean.insert("QScriptValue(6.37e-8)", true);
- toBoolean.insert("QScriptValue(-6.37e-8)", true);
- toBoolean.insert("QScriptValue(0x43211234)", true);
- toBoolean.insert("QScriptValue(0x10000)", true);
- toBoolean.insert("QScriptValue(0x10001)", true);
- toBoolean.insert("QScriptValue(qSNaN())", false);
- toBoolean.insert("QScriptValue(qQNaN())", false);
- toBoolean.insert("QScriptValue(qInf())", true);
- toBoolean.insert("QScriptValue(-qInf())", true);
- toBoolean.insert("QScriptValue(\"NaN\")", true);
- toBoolean.insert("QScriptValue(\"Infinity\")", true);
- toBoolean.insert("QScriptValue(\"-Infinity\")", true);
- toBoolean.insert("QScriptValue(\"ciao\")", true);
- toBoolean.insert("QScriptValue(QString::fromLatin1(\"ciao\"))", true);
- toBoolean.insert("QScriptValue(QString(\"\"))", false);
- toBoolean.insert("QScriptValue(QString())", false);
- toBoolean.insert("QScriptValue(QString(\"0\"))", true);
- toBoolean.insert("QScriptValue(QString(\"123\"))", true);
- toBoolean.insert("QScriptValue(QString(\"12.4\"))", true);
- toBoolean.insert("QScriptValue(0, QScriptValue::UndefinedValue)", false);
- toBoolean.insert("QScriptValue(0, QScriptValue::NullValue)", false);
- toBoolean.insert("QScriptValue(0, true)", true);
- toBoolean.insert("QScriptValue(0, false)", false);
- toBoolean.insert("QScriptValue(0, int(122))", true);
- toBoolean.insert("QScriptValue(0, uint(124))", true);
- toBoolean.insert("QScriptValue(0, 0)", false);
- toBoolean.insert("QScriptValue(0, 0.0)", false);
- toBoolean.insert("QScriptValue(0, 123.0)", true);
- toBoolean.insert("QScriptValue(0, 6.37e-8)", true);
- toBoolean.insert("QScriptValue(0, -6.37e-8)", true);
- toBoolean.insert("QScriptValue(0, 0x43211234)", true);
- toBoolean.insert("QScriptValue(0, 0x10000)", true);
- toBoolean.insert("QScriptValue(0, 0x10001)", true);
- toBoolean.insert("QScriptValue(0, qSNaN())", false);
- toBoolean.insert("QScriptValue(0, qQNaN())", false);
- toBoolean.insert("QScriptValue(0, qInf())", true);
- toBoolean.insert("QScriptValue(0, -qInf())", true);
- toBoolean.insert("QScriptValue(0, \"NaN\")", true);
- toBoolean.insert("QScriptValue(0, \"Infinity\")", true);
- toBoolean.insert("QScriptValue(0, \"-Infinity\")", true);
- toBoolean.insert("QScriptValue(0, \"ciao\")", true);
- toBoolean.insert("QScriptValue(0, QString::fromLatin1(\"ciao\"))", true);
- toBoolean.insert("QScriptValue(0, QString(\"\"))", false);
- toBoolean.insert("QScriptValue(0, QString())", false);
- toBoolean.insert("QScriptValue(0, QString(\"0\"))", true);
- toBoolean.insert("QScriptValue(0, QString(\"123\"))", true);
- toBoolean.insert("QScriptValue(0, QString(\"12.3\"))", true);
- toBoolean.insert("QScriptValue(engine, QScriptValue::UndefinedValue)", false);
- toBoolean.insert("QScriptValue(engine, QScriptValue::NullValue)", false);
- toBoolean.insert("QScriptValue(engine, true)", true);
- toBoolean.insert("QScriptValue(engine, false)", false);
- toBoolean.insert("QScriptValue(engine, int(122))", true);
- toBoolean.insert("QScriptValue(engine, uint(124))", true);
- toBoolean.insert("QScriptValue(engine, 0)", false);
- toBoolean.insert("QScriptValue(engine, 0.0)", false);
- toBoolean.insert("QScriptValue(engine, 123.0)", true);
- toBoolean.insert("QScriptValue(engine, 6.37e-8)", true);
- toBoolean.insert("QScriptValue(engine, -6.37e-8)", true);
- toBoolean.insert("QScriptValue(engine, 0x43211234)", true);
- toBoolean.insert("QScriptValue(engine, 0x10000)", true);
- toBoolean.insert("QScriptValue(engine, 0x10001)", true);
- toBoolean.insert("QScriptValue(engine, qSNaN())", false);
- toBoolean.insert("QScriptValue(engine, qQNaN())", false);
- toBoolean.insert("QScriptValue(engine, qInf())", true);
- toBoolean.insert("QScriptValue(engine, -qInf())", true);
- toBoolean.insert("QScriptValue(engine, \"NaN\")", true);
- toBoolean.insert("QScriptValue(engine, \"Infinity\")", true);
- toBoolean.insert("QScriptValue(engine, \"-Infinity\")", true);
- toBoolean.insert("QScriptValue(engine, \"ciao\")", true);
- toBoolean.insert("QScriptValue(engine, QString::fromLatin1(\"ciao\"))", true);
- toBoolean.insert("QScriptValue(engine, QString(\"\"))", false);
- toBoolean.insert("QScriptValue(engine, QString())", false);
- toBoolean.insert("QScriptValue(engine, QString(\"0\"))", true);
- toBoolean.insert("QScriptValue(engine, QString(\"123\"))", true);
- toBoolean.insert("QScriptValue(engine, QString(\"1.23\"))", true);
- toBoolean.insert("engine->evaluate(\"[]\")", true);
- toBoolean.insert("engine->evaluate(\"{}\")", false);
- toBoolean.insert("engine->evaluate(\"Object.prototype\")", true);
- toBoolean.insert("engine->evaluate(\"Date.prototype\")", true);
- toBoolean.insert("engine->evaluate(\"Array.prototype\")", true);
- toBoolean.insert("engine->evaluate(\"Function.prototype\")", true);
- toBoolean.insert("engine->evaluate(\"Error.prototype\")", true);
- toBoolean.insert("engine->evaluate(\"Object\")", true);
- toBoolean.insert("engine->evaluate(\"Array\")", true);
- toBoolean.insert("engine->evaluate(\"Number\")", true);
- toBoolean.insert("engine->evaluate(\"Function\")", true);
- toBoolean.insert("engine->evaluate(\"(function() { return 1; })\")", true);
- toBoolean.insert("engine->evaluate(\"(function() { return 'ciao'; })\")", true);
- toBoolean.insert("engine->evaluate(\"(function() { throw new Error('foo'); })\")", true);
- toBoolean.insert("engine->evaluate(\"/foo/\")", true);
- toBoolean.insert("engine->evaluate(\"new Object()\")", true);
- toBoolean.insert("engine->evaluate(\"new Array()\")", true);
- toBoolean.insert("engine->evaluate(\"new Error()\")", true);
- toBoolean.insert("engine->evaluate(\"a = new Object(); a.foo = 22; a.foo\")", true);
- toBoolean.insert("engine->evaluate(\"Undefined\")", true);
- toBoolean.insert("engine->evaluate(\"Null\")", true);
- toBoolean.insert("engine->evaluate(\"True\")", true);
- toBoolean.insert("engine->evaluate(\"False\")", true);
- toBoolean.insert("engine->evaluate(\"undefined\")", false);
- toBoolean.insert("engine->evaluate(\"null\")", false);
- toBoolean.insert("engine->evaluate(\"true\")", true);
- toBoolean.insert("engine->evaluate(\"false\")", false);
- toBoolean.insert("engine->evaluate(\"122\")", true);
- toBoolean.insert("engine->evaluate(\"124\")", true);
- toBoolean.insert("engine->evaluate(\"0\")", false);
- toBoolean.insert("engine->evaluate(\"0.0\")", false);
- toBoolean.insert("engine->evaluate(\"123.0\")", true);
- toBoolean.insert("engine->evaluate(\"6.37e-8\")", true);
- toBoolean.insert("engine->evaluate(\"-6.37e-8\")", true);
- toBoolean.insert("engine->evaluate(\"0x43211234\")", true);
- toBoolean.insert("engine->evaluate(\"0x10000\")", true);
- toBoolean.insert("engine->evaluate(\"0x10001\")", true);
- toBoolean.insert("engine->evaluate(\"NaN\")", false);
- toBoolean.insert("engine->evaluate(\"Infinity\")", true);
- toBoolean.insert("engine->evaluate(\"-Infinity\")", true);
- toBoolean.insert("engine->evaluate(\"'ciao'\")", true);
- toBoolean.insert("engine->evaluate(\"''\")", false);
- toBoolean.insert("engine->evaluate(\"'0'\")", true);
- toBoolean.insert("engine->evaluate(\"'123'\")", true);
- toBoolean.insert("engine->evaluate(\"'12.4'\")", true);
- toBoolean.insert("engine->nullValue()", false);
- toBoolean.insert("engine->undefinedValue()", false);
- }
- newRow(expr) << toBoolean.value(expr);
-}
-
-void tst_QScriptValue::toBoolean_test(const char*, const QScriptValue& value)
-{
- QFETCH(bool, expected);
- QCOMPARE(value.toBoolean(), expected);
- QCOMPARE(value.toBoolean(), expected);
-}
-
-DEFINE_TEST_FUNCTION(toBoolean)
-
-
-void tst_QScriptValue::toInteger_initData()
-{
- QTest::addColumn<qsreal>("expected");
- initScriptValues();
-}
-
-void tst_QScriptValue::toInteger_makeData(const char* expr)
-{
- static QHash<QString, qsreal> toInteger;
- if (toInteger.isEmpty()) {
- toInteger.insert("QScriptValue()", 0);
- toInteger.insert("QScriptValue(QScriptValue::UndefinedValue)", 0);
- toInteger.insert("QScriptValue(QScriptValue::NullValue)", 0);
- toInteger.insert("QScriptValue(true)", 1);
- toInteger.insert("QScriptValue(false)", 0);
- toInteger.insert("QScriptValue(int(122))", 122);
- toInteger.insert("QScriptValue(uint(124))", 124);
- toInteger.insert("QScriptValue(0)", 0);
- toInteger.insert("QScriptValue(0.0)", 0);
- toInteger.insert("QScriptValue(123.0)", 123);
- toInteger.insert("QScriptValue(6.37e-8)", 0);
- toInteger.insert("QScriptValue(-6.37e-8)", 0);
- toInteger.insert("QScriptValue(0x43211234)", 1126240820);
- toInteger.insert("QScriptValue(0x10000)", 65536);
- toInteger.insert("QScriptValue(0x10001)", 65537);
- toInteger.insert("QScriptValue(qSNaN())", 0);
- toInteger.insert("QScriptValue(qQNaN())", 0);
- toInteger.insert("QScriptValue(qInf())", qInf());
- toInteger.insert("QScriptValue(-qInf())", qInf());
- toInteger.insert("QScriptValue(\"NaN\")", 0);
- toInteger.insert("QScriptValue(\"Infinity\")", qInf());
- toInteger.insert("QScriptValue(\"-Infinity\")", qInf());
- toInteger.insert("QScriptValue(\"ciao\")", 0);
- toInteger.insert("QScriptValue(QString::fromLatin1(\"ciao\"))", 0);
- toInteger.insert("QScriptValue(QString(\"\"))", 0);
- toInteger.insert("QScriptValue(QString())", 0);
- toInteger.insert("QScriptValue(QString(\"0\"))", 0);
- toInteger.insert("QScriptValue(QString(\"123\"))", 123);
- toInteger.insert("QScriptValue(QString(\"12.4\"))", 12);
- toInteger.insert("QScriptValue(0, QScriptValue::UndefinedValue)", 0);
- toInteger.insert("QScriptValue(0, QScriptValue::NullValue)", 0);
- toInteger.insert("QScriptValue(0, true)", 1);
- toInteger.insert("QScriptValue(0, false)", 0);
- toInteger.insert("QScriptValue(0, int(122))", 122);
- toInteger.insert("QScriptValue(0, uint(124))", 124);
- toInteger.insert("QScriptValue(0, 0)", 0);
- toInteger.insert("QScriptValue(0, 0.0)", 0);
- toInteger.insert("QScriptValue(0, 123.0)", 123);
- toInteger.insert("QScriptValue(0, 6.37e-8)", 0);
- toInteger.insert("QScriptValue(0, -6.37e-8)", 0);
- toInteger.insert("QScriptValue(0, 0x43211234)", 1126240820);
- toInteger.insert("QScriptValue(0, 0x10000)", 65536);
- toInteger.insert("QScriptValue(0, 0x10001)", 65537);
- toInteger.insert("QScriptValue(0, qSNaN())", 0);
- toInteger.insert("QScriptValue(0, qQNaN())", 0);
- toInteger.insert("QScriptValue(0, qInf())", qInf());
- toInteger.insert("QScriptValue(0, -qInf())", qInf());
- toInteger.insert("QScriptValue(0, \"NaN\")", 0);
- toInteger.insert("QScriptValue(0, \"Infinity\")", qInf());
- toInteger.insert("QScriptValue(0, \"-Infinity\")", qInf());
- toInteger.insert("QScriptValue(0, \"ciao\")", 0);
- toInteger.insert("QScriptValue(0, QString::fromLatin1(\"ciao\"))", 0);
- toInteger.insert("QScriptValue(0, QString(\"\"))", 0);
- toInteger.insert("QScriptValue(0, QString())", 0);
- toInteger.insert("QScriptValue(0, QString(\"0\"))", 0);
- toInteger.insert("QScriptValue(0, QString(\"123\"))", 123);
- toInteger.insert("QScriptValue(0, QString(\"12.3\"))", 12);
- toInteger.insert("QScriptValue(engine, QScriptValue::UndefinedValue)", 0);
- toInteger.insert("QScriptValue(engine, QScriptValue::NullValue)", 0);
- toInteger.insert("QScriptValue(engine, true)", 1);
- toInteger.insert("QScriptValue(engine, false)", 0);
- toInteger.insert("QScriptValue(engine, int(122))", 122);
- toInteger.insert("QScriptValue(engine, uint(124))", 124);
- toInteger.insert("QScriptValue(engine, 0)", 0);
- toInteger.insert("QScriptValue(engine, 0.0)", 0);
- toInteger.insert("QScriptValue(engine, 123.0)", 123);
- toInteger.insert("QScriptValue(engine, 6.37e-8)", 0);
- toInteger.insert("QScriptValue(engine, -6.37e-8)", 0);
- toInteger.insert("QScriptValue(engine, 0x43211234)", 1126240820);
- toInteger.insert("QScriptValue(engine, 0x10000)", 65536);
- toInteger.insert("QScriptValue(engine, 0x10001)", 65537);
- toInteger.insert("QScriptValue(engine, qSNaN())", 0);
- toInteger.insert("QScriptValue(engine, qQNaN())", 0);
- toInteger.insert("QScriptValue(engine, qInf())", qInf());
- toInteger.insert("QScriptValue(engine, -qInf())", qInf());
- toInteger.insert("QScriptValue(engine, \"NaN\")", 0);
- toInteger.insert("QScriptValue(engine, \"Infinity\")", qInf());
- toInteger.insert("QScriptValue(engine, \"-Infinity\")", qInf());
- toInteger.insert("QScriptValue(engine, \"ciao\")", 0);
- toInteger.insert("QScriptValue(engine, QString::fromLatin1(\"ciao\"))", 0);
- toInteger.insert("QScriptValue(engine, QString(\"\"))", 0);
- toInteger.insert("QScriptValue(engine, QString())", 0);
- toInteger.insert("QScriptValue(engine, QString(\"0\"))", 0);
- toInteger.insert("QScriptValue(engine, QString(\"123\"))", 123);
- toInteger.insert("QScriptValue(engine, QString(\"1.23\"))", 1);
- toInteger.insert("engine->evaluate(\"[]\")", 0);
- toInteger.insert("engine->evaluate(\"{}\")", 0);
- toInteger.insert("engine->evaluate(\"Object.prototype\")", 0);
- toInteger.insert("engine->evaluate(\"Date.prototype\")", 0);
- toInteger.insert("engine->evaluate(\"Array.prototype\")", 0);
- toInteger.insert("engine->evaluate(\"Function.prototype\")", 0);
- toInteger.insert("engine->evaluate(\"Error.prototype\")", 0);
- toInteger.insert("engine->evaluate(\"Object\")", 0);
- toInteger.insert("engine->evaluate(\"Array\")", 0);
- toInteger.insert("engine->evaluate(\"Number\")", 0);
- toInteger.insert("engine->evaluate(\"Function\")", 0);
- toInteger.insert("engine->evaluate(\"(function() { return 1; })\")", 0);
- toInteger.insert("engine->evaluate(\"(function() { return 'ciao'; })\")", 0);
- toInteger.insert("engine->evaluate(\"(function() { throw new Error('foo'); })\")", 0);
- toInteger.insert("engine->evaluate(\"/foo/\")", 0);
- toInteger.insert("engine->evaluate(\"new Object()\")", 0);
- toInteger.insert("engine->evaluate(\"new Array()\")", 0);
- toInteger.insert("engine->evaluate(\"new Error()\")", 0);
- toInteger.insert("engine->evaluate(\"a = new Object(); a.foo = 22; a.foo\")", 22);
- toInteger.insert("engine->evaluate(\"Undefined\")", 0);
- toInteger.insert("engine->evaluate(\"Null\")", 0);
- toInteger.insert("engine->evaluate(\"True\")", 0);
- toInteger.insert("engine->evaluate(\"False\")", 0);
- toInteger.insert("engine->evaluate(\"undefined\")", 0);
- toInteger.insert("engine->evaluate(\"null\")", 0);
- toInteger.insert("engine->evaluate(\"true\")", 1);
- toInteger.insert("engine->evaluate(\"false\")", 0);
- toInteger.insert("engine->evaluate(\"122\")", 122);
- toInteger.insert("engine->evaluate(\"124\")", 124);
- toInteger.insert("engine->evaluate(\"0\")", 0);
- toInteger.insert("engine->evaluate(\"0.0\")", 0);
- toInteger.insert("engine->evaluate(\"123.0\")", 123);
- toInteger.insert("engine->evaluate(\"6.37e-8\")", 0);
- toInteger.insert("engine->evaluate(\"-6.37e-8\")", 0);
- toInteger.insert("engine->evaluate(\"0x43211234\")", 1126240820);
- toInteger.insert("engine->evaluate(\"0x10000\")", 65536);
- toInteger.insert("engine->evaluate(\"0x10001\")", 65537);
- toInteger.insert("engine->evaluate(\"NaN\")", 0);
- toInteger.insert("engine->evaluate(\"Infinity\")", qInf());
- toInteger.insert("engine->evaluate(\"-Infinity\")", qInf());
- toInteger.insert("engine->evaluate(\"'ciao'\")", 0);
- toInteger.insert("engine->evaluate(\"''\")", 0);
- toInteger.insert("engine->evaluate(\"'0'\")", 0);
- toInteger.insert("engine->evaluate(\"'123'\")", 123);
- toInteger.insert("engine->evaluate(\"'12.4'\")", 12);
- toInteger.insert("engine->nullValue()", 0);
- toInteger.insert("engine->undefinedValue()", 0);
- }
- newRow(expr) << toInteger.value(expr);
-}
-
-void tst_QScriptValue::toInteger_test(const char*, const QScriptValue& value)
-{
- QFETCH(qsreal, expected);
- if (qIsInf(expected)) {
- QVERIFY(qIsInf(value.toInteger()));
- QVERIFY(qIsInf(value.toInteger()));
- return;
- }
- QCOMPARE(value.toInteger(), expected);
- QCOMPARE(value.toInteger(), expected);
-}
-
-DEFINE_TEST_FUNCTION(toInteger)
-
-
-void tst_QScriptValue::toInt32_initData()
-{
- QTest::addColumn<qint32>("expected");
- initScriptValues();
-}
-
-void tst_QScriptValue::toInt32_makeData(const char* expr)
-{
- static QHash<QString, qint32> toInt32;
- if (toInt32.isEmpty()) {
- toInt32.insert("QScriptValue()", 0);
- toInt32.insert("QScriptValue(QScriptValue::UndefinedValue)", 0);
- toInt32.insert("QScriptValue(QScriptValue::NullValue)", 0);
- toInt32.insert("QScriptValue(true)", 1);
- toInt32.insert("QScriptValue(false)", 0);
- toInt32.insert("QScriptValue(int(122))", 122);
- toInt32.insert("QScriptValue(uint(124))", 124);
- toInt32.insert("QScriptValue(0)", 0);
- toInt32.insert("QScriptValue(0.0)", 0);
- toInt32.insert("QScriptValue(123.0)", 123);
- toInt32.insert("QScriptValue(6.37e-8)", 0);
- toInt32.insert("QScriptValue(-6.37e-8)", 0);
- toInt32.insert("QScriptValue(0x43211234)", 1126240820);
- toInt32.insert("QScriptValue(0x10000)", 65536);
- toInt32.insert("QScriptValue(0x10001)", 65537);
- toInt32.insert("QScriptValue(qSNaN())", 0);
- toInt32.insert("QScriptValue(qQNaN())", 0);
- toInt32.insert("QScriptValue(qInf())", 0);
- toInt32.insert("QScriptValue(-qInf())", 0);
- toInt32.insert("QScriptValue(\"NaN\")", 0);
- toInt32.insert("QScriptValue(\"Infinity\")", 0);
- toInt32.insert("QScriptValue(\"-Infinity\")", 0);
- toInt32.insert("QScriptValue(\"ciao\")", 0);
- toInt32.insert("QScriptValue(QString::fromLatin1(\"ciao\"))", 0);
- toInt32.insert("QScriptValue(QString(\"\"))", 0);
- toInt32.insert("QScriptValue(QString())", 0);
- toInt32.insert("QScriptValue(QString(\"0\"))", 0);
- toInt32.insert("QScriptValue(QString(\"123\"))", 123);
- toInt32.insert("QScriptValue(QString(\"12.4\"))", 12);
- toInt32.insert("QScriptValue(0, QScriptValue::UndefinedValue)", 0);
- toInt32.insert("QScriptValue(0, QScriptValue::NullValue)", 0);
- toInt32.insert("QScriptValue(0, true)", 1);
- toInt32.insert("QScriptValue(0, false)", 0);
- toInt32.insert("QScriptValue(0, int(122))", 122);
- toInt32.insert("QScriptValue(0, uint(124))", 124);
- toInt32.insert("QScriptValue(0, 0)", 0);
- toInt32.insert("QScriptValue(0, 0.0)", 0);
- toInt32.insert("QScriptValue(0, 123.0)", 123);
- toInt32.insert("QScriptValue(0, 6.37e-8)", 0);
- toInt32.insert("QScriptValue(0, -6.37e-8)", 0);
- toInt32.insert("QScriptValue(0, 0x43211234)", 1126240820);
- toInt32.insert("QScriptValue(0, 0x10000)", 65536);
- toInt32.insert("QScriptValue(0, 0x10001)", 65537);
- toInt32.insert("QScriptValue(0, qSNaN())", 0);
- toInt32.insert("QScriptValue(0, qQNaN())", 0);
- toInt32.insert("QScriptValue(0, qInf())", 0);
- toInt32.insert("QScriptValue(0, -qInf())", 0);
- toInt32.insert("QScriptValue(0, \"NaN\")", 0);
- toInt32.insert("QScriptValue(0, \"Infinity\")", 0);
- toInt32.insert("QScriptValue(0, \"-Infinity\")", 0);
- toInt32.insert("QScriptValue(0, \"ciao\")", 0);
- toInt32.insert("QScriptValue(0, QString::fromLatin1(\"ciao\"))", 0);
- toInt32.insert("QScriptValue(0, QString(\"\"))", 0);
- toInt32.insert("QScriptValue(0, QString())", 0);
- toInt32.insert("QScriptValue(0, QString(\"0\"))", 0);
- toInt32.insert("QScriptValue(0, QString(\"123\"))", 123);
- toInt32.insert("QScriptValue(0, QString(\"12.3\"))", 12);
- toInt32.insert("QScriptValue(engine, QScriptValue::UndefinedValue)", 0);
- toInt32.insert("QScriptValue(engine, QScriptValue::NullValue)", 0);
- toInt32.insert("QScriptValue(engine, true)", 1);
- toInt32.insert("QScriptValue(engine, false)", 0);
- toInt32.insert("QScriptValue(engine, int(122))", 122);
- toInt32.insert("QScriptValue(engine, uint(124))", 124);
- toInt32.insert("QScriptValue(engine, 0)", 0);
- toInt32.insert("QScriptValue(engine, 0.0)", 0);
- toInt32.insert("QScriptValue(engine, 123.0)", 123);
- toInt32.insert("QScriptValue(engine, 6.37e-8)", 0);
- toInt32.insert("QScriptValue(engine, -6.37e-8)", 0);
- toInt32.insert("QScriptValue(engine, 0x43211234)", 1126240820);
- toInt32.insert("QScriptValue(engine, 0x10000)", 65536);
- toInt32.insert("QScriptValue(engine, 0x10001)", 65537);
- toInt32.insert("QScriptValue(engine, qSNaN())", 0);
- toInt32.insert("QScriptValue(engine, qQNaN())", 0);
- toInt32.insert("QScriptValue(engine, qInf())", 0);
- toInt32.insert("QScriptValue(engine, -qInf())", 0);
- toInt32.insert("QScriptValue(engine, \"NaN\")", 0);
- toInt32.insert("QScriptValue(engine, \"Infinity\")", 0);
- toInt32.insert("QScriptValue(engine, \"-Infinity\")", 0);
- toInt32.insert("QScriptValue(engine, \"ciao\")", 0);
- toInt32.insert("QScriptValue(engine, QString::fromLatin1(\"ciao\"))", 0);
- toInt32.insert("QScriptValue(engine, QString(\"\"))", 0);
- toInt32.insert("QScriptValue(engine, QString())", 0);
- toInt32.insert("QScriptValue(engine, QString(\"0\"))", 0);
- toInt32.insert("QScriptValue(engine, QString(\"123\"))", 123);
- toInt32.insert("QScriptValue(engine, QString(\"1.23\"))", 1);
- toInt32.insert("engine->evaluate(\"[]\")", 0);
- toInt32.insert("engine->evaluate(\"{}\")", 0);
- toInt32.insert("engine->evaluate(\"Object.prototype\")", 0);
- toInt32.insert("engine->evaluate(\"Date.prototype\")", 0);
- toInt32.insert("engine->evaluate(\"Array.prototype\")", 0);
- toInt32.insert("engine->evaluate(\"Function.prototype\")", 0);
- toInt32.insert("engine->evaluate(\"Error.prototype\")", 0);
- toInt32.insert("engine->evaluate(\"Object\")", 0);
- toInt32.insert("engine->evaluate(\"Array\")", 0);
- toInt32.insert("engine->evaluate(\"Number\")", 0);
- toInt32.insert("engine->evaluate(\"Function\")", 0);
- toInt32.insert("engine->evaluate(\"(function() { return 1; })\")", 0);
- toInt32.insert("engine->evaluate(\"(function() { return 'ciao'; })\")", 0);
- toInt32.insert("engine->evaluate(\"(function() { throw new Error('foo'); })\")", 0);
- toInt32.insert("engine->evaluate(\"/foo/\")", 0);
- toInt32.insert("engine->evaluate(\"new Object()\")", 0);
- toInt32.insert("engine->evaluate(\"new Array()\")", 0);
- toInt32.insert("engine->evaluate(\"new Error()\")", 0);
- toInt32.insert("engine->evaluate(\"a = new Object(); a.foo = 22; a.foo\")", 22);
- toInt32.insert("engine->evaluate(\"Undefined\")", 0);
- toInt32.insert("engine->evaluate(\"Null\")", 0);
- toInt32.insert("engine->evaluate(\"True\")", 0);
- toInt32.insert("engine->evaluate(\"False\")", 0);
- toInt32.insert("engine->evaluate(\"undefined\")", 0);
- toInt32.insert("engine->evaluate(\"null\")", 0);
- toInt32.insert("engine->evaluate(\"true\")", 1);
- toInt32.insert("engine->evaluate(\"false\")", 0);
- toInt32.insert("engine->evaluate(\"122\")", 122);
- toInt32.insert("engine->evaluate(\"124\")", 124);
- toInt32.insert("engine->evaluate(\"0\")", 0);
- toInt32.insert("engine->evaluate(\"0.0\")", 0);
- toInt32.insert("engine->evaluate(\"123.0\")", 123);
- toInt32.insert("engine->evaluate(\"6.37e-8\")", 0);
- toInt32.insert("engine->evaluate(\"-6.37e-8\")", 0);
- toInt32.insert("engine->evaluate(\"0x43211234\")", 1126240820);
- toInt32.insert("engine->evaluate(\"0x10000\")", 65536);
- toInt32.insert("engine->evaluate(\"0x10001\")", 65537);
- toInt32.insert("engine->evaluate(\"NaN\")", 0);
- toInt32.insert("engine->evaluate(\"Infinity\")", 0);
- toInt32.insert("engine->evaluate(\"-Infinity\")", 0);
- toInt32.insert("engine->evaluate(\"'ciao'\")", 0);
- toInt32.insert("engine->evaluate(\"''\")", 0);
- toInt32.insert("engine->evaluate(\"'0'\")", 0);
- toInt32.insert("engine->evaluate(\"'123'\")", 123);
- toInt32.insert("engine->evaluate(\"'12.4'\")", 12);
- toInt32.insert("engine->nullValue()", 0);
- toInt32.insert("engine->undefinedValue()", 0);
- }
- newRow(expr) << toInt32.value(expr);
-}
-
-void tst_QScriptValue::toInt32_test(const char*, const QScriptValue& value)
-{
- QFETCH(qint32, expected);
- QCOMPARE(value.toInt32(), expected);
- QCOMPARE(value.toInt32(), expected);
-}
-
-DEFINE_TEST_FUNCTION(toInt32)
-
-
-void tst_QScriptValue::toUInt32_initData()
-{
- QTest::addColumn<quint32>("expected");
- initScriptValues();
-}
-
-void tst_QScriptValue::toUInt32_makeData(const char* expr)
-{
- static QHash<QString, quint32> toUInt32;
- if (toUInt32.isEmpty()) {
- toUInt32.insert("QScriptValue()", 0);
- toUInt32.insert("QScriptValue(QScriptValue::UndefinedValue)", 0);
- toUInt32.insert("QScriptValue(QScriptValue::NullValue)", 0);
- toUInt32.insert("QScriptValue(true)", 1);
- toUInt32.insert("QScriptValue(false)", 0);
- toUInt32.insert("QScriptValue(int(122))", 122);
- toUInt32.insert("QScriptValue(uint(124))", 124);
- toUInt32.insert("QScriptValue(0)", 0);
- toUInt32.insert("QScriptValue(0.0)", 0);
- toUInt32.insert("QScriptValue(123.0)", 123);
- toUInt32.insert("QScriptValue(6.37e-8)", 0);
- toUInt32.insert("QScriptValue(-6.37e-8)", 0);
- toUInt32.insert("QScriptValue(0x43211234)", 1126240820);
- toUInt32.insert("QScriptValue(0x10000)", 65536);
- toUInt32.insert("QScriptValue(0x10001)", 65537);
- toUInt32.insert("QScriptValue(qSNaN())", 0);
- toUInt32.insert("QScriptValue(qQNaN())", 0);
- toUInt32.insert("QScriptValue(qInf())", 0);
- toUInt32.insert("QScriptValue(-qInf())", 0);
- toUInt32.insert("QScriptValue(\"NaN\")", 0);
- toUInt32.insert("QScriptValue(\"Infinity\")", 0);
- toUInt32.insert("QScriptValue(\"-Infinity\")", 0);
- toUInt32.insert("QScriptValue(\"ciao\")", 0);
- toUInt32.insert("QScriptValue(QString::fromLatin1(\"ciao\"))", 0);
- toUInt32.insert("QScriptValue(QString(\"\"))", 0);
- toUInt32.insert("QScriptValue(QString())", 0);
- toUInt32.insert("QScriptValue(QString(\"0\"))", 0);
- toUInt32.insert("QScriptValue(QString(\"123\"))", 123);
- toUInt32.insert("QScriptValue(QString(\"12.4\"))", 12);
- toUInt32.insert("QScriptValue(0, QScriptValue::UndefinedValue)", 0);
- toUInt32.insert("QScriptValue(0, QScriptValue::NullValue)", 0);
- toUInt32.insert("QScriptValue(0, true)", 1);
- toUInt32.insert("QScriptValue(0, false)", 0);
- toUInt32.insert("QScriptValue(0, int(122))", 122);
- toUInt32.insert("QScriptValue(0, uint(124))", 124);
- toUInt32.insert("QScriptValue(0, 0)", 0);
- toUInt32.insert("QScriptValue(0, 0.0)", 0);
- toUInt32.insert("QScriptValue(0, 123.0)", 123);
- toUInt32.insert("QScriptValue(0, 6.37e-8)", 0);
- toUInt32.insert("QScriptValue(0, -6.37e-8)", 0);
- toUInt32.insert("QScriptValue(0, 0x43211234)", 1126240820);
- toUInt32.insert("QScriptValue(0, 0x10000)", 65536);
- toUInt32.insert("QScriptValue(0, 0x10001)", 65537);
- toUInt32.insert("QScriptValue(0, qSNaN())", 0);
- toUInt32.insert("QScriptValue(0, qQNaN())", 0);
- toUInt32.insert("QScriptValue(0, qInf())", 0);
- toUInt32.insert("QScriptValue(0, -qInf())", 0);
- toUInt32.insert("QScriptValue(0, \"NaN\")", 0);
- toUInt32.insert("QScriptValue(0, \"Infinity\")", 0);
- toUInt32.insert("QScriptValue(0, \"-Infinity\")", 0);
- toUInt32.insert("QScriptValue(0, \"ciao\")", 0);
- toUInt32.insert("QScriptValue(0, QString::fromLatin1(\"ciao\"))", 0);
- toUInt32.insert("QScriptValue(0, QString(\"\"))", 0);
- toUInt32.insert("QScriptValue(0, QString())", 0);
- toUInt32.insert("QScriptValue(0, QString(\"0\"))", 0);
- toUInt32.insert("QScriptValue(0, QString(\"123\"))", 123);
- toUInt32.insert("QScriptValue(0, QString(\"12.3\"))", 12);
- toUInt32.insert("QScriptValue(engine, QScriptValue::UndefinedValue)", 0);
- toUInt32.insert("QScriptValue(engine, QScriptValue::NullValue)", 0);
- toUInt32.insert("QScriptValue(engine, true)", 1);
- toUInt32.insert("QScriptValue(engine, false)", 0);
- toUInt32.insert("QScriptValue(engine, int(122))", 122);
- toUInt32.insert("QScriptValue(engine, uint(124))", 124);
- toUInt32.insert("QScriptValue(engine, 0)", 0);
- toUInt32.insert("QScriptValue(engine, 0.0)", 0);
- toUInt32.insert("QScriptValue(engine, 123.0)", 123);
- toUInt32.insert("QScriptValue(engine, 6.37e-8)", 0);
- toUInt32.insert("QScriptValue(engine, -6.37e-8)", 0);
- toUInt32.insert("QScriptValue(engine, 0x43211234)", 1126240820);
- toUInt32.insert("QScriptValue(engine, 0x10000)", 65536);
- toUInt32.insert("QScriptValue(engine, 0x10001)", 65537);
- toUInt32.insert("QScriptValue(engine, qSNaN())", 0);
- toUInt32.insert("QScriptValue(engine, qQNaN())", 0);
- toUInt32.insert("QScriptValue(engine, qInf())", 0);
- toUInt32.insert("QScriptValue(engine, -qInf())", 0);
- toUInt32.insert("QScriptValue(engine, \"NaN\")", 0);
- toUInt32.insert("QScriptValue(engine, \"Infinity\")", 0);
- toUInt32.insert("QScriptValue(engine, \"-Infinity\")", 0);
- toUInt32.insert("QScriptValue(engine, \"ciao\")", 0);
- toUInt32.insert("QScriptValue(engine, QString::fromLatin1(\"ciao\"))", 0);
- toUInt32.insert("QScriptValue(engine, QString(\"\"))", 0);
- toUInt32.insert("QScriptValue(engine, QString())", 0);
- toUInt32.insert("QScriptValue(engine, QString(\"0\"))", 0);
- toUInt32.insert("QScriptValue(engine, QString(\"123\"))", 123);
- toUInt32.insert("QScriptValue(engine, QString(\"1.23\"))", 1);
- toUInt32.insert("engine->evaluate(\"[]\")", 0);
- toUInt32.insert("engine->evaluate(\"{}\")", 0);
- toUInt32.insert("engine->evaluate(\"Object.prototype\")", 0);
- toUInt32.insert("engine->evaluate(\"Date.prototype\")", 0);
- toUInt32.insert("engine->evaluate(\"Array.prototype\")", 0);
- toUInt32.insert("engine->evaluate(\"Function.prototype\")", 0);
- toUInt32.insert("engine->evaluate(\"Error.prototype\")", 0);
- toUInt32.insert("engine->evaluate(\"Object\")", 0);
- toUInt32.insert("engine->evaluate(\"Array\")", 0);
- toUInt32.insert("engine->evaluate(\"Number\")", 0);
- toUInt32.insert("engine->evaluate(\"Function\")", 0);
- toUInt32.insert("engine->evaluate(\"(function() { return 1; })\")", 0);
- toUInt32.insert("engine->evaluate(\"(function() { return 'ciao'; })\")", 0);
- toUInt32.insert("engine->evaluate(\"(function() { throw new Error('foo'); })\")", 0);
- toUInt32.insert("engine->evaluate(\"/foo/\")", 0);
- toUInt32.insert("engine->evaluate(\"new Object()\")", 0);
- toUInt32.insert("engine->evaluate(\"new Array()\")", 0);
- toUInt32.insert("engine->evaluate(\"new Error()\")", 0);
- toUInt32.insert("engine->evaluate(\"a = new Object(); a.foo = 22; a.foo\")", 22);
- toUInt32.insert("engine->evaluate(\"Undefined\")", 0);
- toUInt32.insert("engine->evaluate(\"Null\")", 0);
- toUInt32.insert("engine->evaluate(\"True\")", 0);
- toUInt32.insert("engine->evaluate(\"False\")", 0);
- toUInt32.insert("engine->evaluate(\"undefined\")", 0);
- toUInt32.insert("engine->evaluate(\"null\")", 0);
- toUInt32.insert("engine->evaluate(\"true\")", 1);
- toUInt32.insert("engine->evaluate(\"false\")", 0);
- toUInt32.insert("engine->evaluate(\"122\")", 122);
- toUInt32.insert("engine->evaluate(\"124\")", 124);
- toUInt32.insert("engine->evaluate(\"0\")", 0);
- toUInt32.insert("engine->evaluate(\"0.0\")", 0);
- toUInt32.insert("engine->evaluate(\"123.0\")", 123);
- toUInt32.insert("engine->evaluate(\"6.37e-8\")", 0);
- toUInt32.insert("engine->evaluate(\"-6.37e-8\")", 0);
- toUInt32.insert("engine->evaluate(\"0x43211234\")", 1126240820);
- toUInt32.insert("engine->evaluate(\"0x10000\")", 65536);
- toUInt32.insert("engine->evaluate(\"0x10001\")", 65537);
- toUInt32.insert("engine->evaluate(\"NaN\")", 0);
- toUInt32.insert("engine->evaluate(\"Infinity\")", 0);
- toUInt32.insert("engine->evaluate(\"-Infinity\")", 0);
- toUInt32.insert("engine->evaluate(\"'ciao'\")", 0);
- toUInt32.insert("engine->evaluate(\"''\")", 0);
- toUInt32.insert("engine->evaluate(\"'0'\")", 0);
- toUInt32.insert("engine->evaluate(\"'123'\")", 123);
- toUInt32.insert("engine->evaluate(\"'12.4'\")", 12);
- toUInt32.insert("engine->nullValue()", 0);
- toUInt32.insert("engine->undefinedValue()", 0);
- }
- newRow(expr) << toUInt32.value(expr);
-}
-
-void tst_QScriptValue::toUInt32_test(const char*, const QScriptValue& value)
-{
- QFETCH(quint32, expected);
- QCOMPARE(value.toUInt32(), expected);
- QCOMPARE(value.toUInt32(), expected);
-}
-
-DEFINE_TEST_FUNCTION(toUInt32)
-
-
-void tst_QScriptValue::toUInt16_initData()
-{
- QTest::addColumn<quint16>("expected");
- initScriptValues();
-}
-
-void tst_QScriptValue::toUInt16_makeData(const char* expr)
-{
- static QHash<QString, quint16> toUInt16;
- if (toUInt16.isEmpty()) {
- toUInt16.insert("QScriptValue()", 0);
- toUInt16.insert("QScriptValue(QScriptValue::UndefinedValue)", 0);
- toUInt16.insert("QScriptValue(QScriptValue::NullValue)", 0);
- toUInt16.insert("QScriptValue(true)", 1);
- toUInt16.insert("QScriptValue(false)", 0);
- toUInt16.insert("QScriptValue(int(122))", 122);
- toUInt16.insert("QScriptValue(uint(124))", 124);
- toUInt16.insert("QScriptValue(0)", 0);
- toUInt16.insert("QScriptValue(0.0)", 0);
- toUInt16.insert("QScriptValue(123.0)", 123);
- toUInt16.insert("QScriptValue(6.37e-8)", 0);
- toUInt16.insert("QScriptValue(-6.37e-8)", 0);
- toUInt16.insert("QScriptValue(0x43211234)", 4660);
- toUInt16.insert("QScriptValue(0x10000)", 0);
- toUInt16.insert("QScriptValue(0x10001)", 1);
- toUInt16.insert("QScriptValue(qSNaN())", 0);
- toUInt16.insert("QScriptValue(qQNaN())", 0);
- toUInt16.insert("QScriptValue(qInf())", 0);
- toUInt16.insert("QScriptValue(-qInf())", 0);
- toUInt16.insert("QScriptValue(\"NaN\")", 0);
- toUInt16.insert("QScriptValue(\"Infinity\")", 0);
- toUInt16.insert("QScriptValue(\"-Infinity\")", 0);
- toUInt16.insert("QScriptValue(\"ciao\")", 0);
- toUInt16.insert("QScriptValue(QString::fromLatin1(\"ciao\"))", 0);
- toUInt16.insert("QScriptValue(QString(\"\"))", 0);
- toUInt16.insert("QScriptValue(QString())", 0);
- toUInt16.insert("QScriptValue(QString(\"0\"))", 0);
- toUInt16.insert("QScriptValue(QString(\"123\"))", 123);
- toUInt16.insert("QScriptValue(QString(\"12.4\"))", 12);
- toUInt16.insert("QScriptValue(0, QScriptValue::UndefinedValue)", 0);
- toUInt16.insert("QScriptValue(0, QScriptValue::NullValue)", 0);
- toUInt16.insert("QScriptValue(0, true)", 1);
- toUInt16.insert("QScriptValue(0, false)", 0);
- toUInt16.insert("QScriptValue(0, int(122))", 122);
- toUInt16.insert("QScriptValue(0, uint(124))", 124);
- toUInt16.insert("QScriptValue(0, 0)", 0);
- toUInt16.insert("QScriptValue(0, 0.0)", 0);
- toUInt16.insert("QScriptValue(0, 123.0)", 123);
- toUInt16.insert("QScriptValue(0, 6.37e-8)", 0);
- toUInt16.insert("QScriptValue(0, -6.37e-8)", 0);
- toUInt16.insert("QScriptValue(0, 0x43211234)", 4660);
- toUInt16.insert("QScriptValue(0, 0x10000)", 0);
- toUInt16.insert("QScriptValue(0, 0x10001)", 1);
- toUInt16.insert("QScriptValue(0, qSNaN())", 0);
- toUInt16.insert("QScriptValue(0, qQNaN())", 0);
- toUInt16.insert("QScriptValue(0, qInf())", 0);
- toUInt16.insert("QScriptValue(0, -qInf())", 0);
- toUInt16.insert("QScriptValue(0, \"NaN\")", 0);
- toUInt16.insert("QScriptValue(0, \"Infinity\")", 0);
- toUInt16.insert("QScriptValue(0, \"-Infinity\")", 0);
- toUInt16.insert("QScriptValue(0, \"ciao\")", 0);
- toUInt16.insert("QScriptValue(0, QString::fromLatin1(\"ciao\"))", 0);
- toUInt16.insert("QScriptValue(0, QString(\"\"))", 0);
- toUInt16.insert("QScriptValue(0, QString())", 0);
- toUInt16.insert("QScriptValue(0, QString(\"0\"))", 0);
- toUInt16.insert("QScriptValue(0, QString(\"123\"))", 123);
- toUInt16.insert("QScriptValue(0, QString(\"12.3\"))", 12);
- toUInt16.insert("QScriptValue(engine, QScriptValue::UndefinedValue)", 0);
- toUInt16.insert("QScriptValue(engine, QScriptValue::NullValue)", 0);
- toUInt16.insert("QScriptValue(engine, true)", 1);
- toUInt16.insert("QScriptValue(engine, false)", 0);
- toUInt16.insert("QScriptValue(engine, int(122))", 122);
- toUInt16.insert("QScriptValue(engine, uint(124))", 124);
- toUInt16.insert("QScriptValue(engine, 0)", 0);
- toUInt16.insert("QScriptValue(engine, 0.0)", 0);
- toUInt16.insert("QScriptValue(engine, 123.0)", 123);
- toUInt16.insert("QScriptValue(engine, 6.37e-8)", 0);
- toUInt16.insert("QScriptValue(engine, -6.37e-8)", 0);
- toUInt16.insert("QScriptValue(engine, 0x43211234)", 4660);
- toUInt16.insert("QScriptValue(engine, 0x10000)", 0);
- toUInt16.insert("QScriptValue(engine, 0x10001)", 1);
- toUInt16.insert("QScriptValue(engine, qSNaN())", 0);
- toUInt16.insert("QScriptValue(engine, qQNaN())", 0);
- toUInt16.insert("QScriptValue(engine, qInf())", 0);
- toUInt16.insert("QScriptValue(engine, -qInf())", 0);
- toUInt16.insert("QScriptValue(engine, \"NaN\")", 0);
- toUInt16.insert("QScriptValue(engine, \"Infinity\")", 0);
- toUInt16.insert("QScriptValue(engine, \"-Infinity\")", 0);
- toUInt16.insert("QScriptValue(engine, \"ciao\")", 0);
- toUInt16.insert("QScriptValue(engine, QString::fromLatin1(\"ciao\"))", 0);
- toUInt16.insert("QScriptValue(engine, QString(\"\"))", 0);
- toUInt16.insert("QScriptValue(engine, QString())", 0);
- toUInt16.insert("QScriptValue(engine, QString(\"0\"))", 0);
- toUInt16.insert("QScriptValue(engine, QString(\"123\"))", 123);
- toUInt16.insert("QScriptValue(engine, QString(\"1.23\"))", 1);
- toUInt16.insert("engine->evaluate(\"[]\")", 0);
- toUInt16.insert("engine->evaluate(\"{}\")", 0);
- toUInt16.insert("engine->evaluate(\"Object.prototype\")", 0);
- toUInt16.insert("engine->evaluate(\"Date.prototype\")", 0);
- toUInt16.insert("engine->evaluate(\"Array.prototype\")", 0);
- toUInt16.insert("engine->evaluate(\"Function.prototype\")", 0);
- toUInt16.insert("engine->evaluate(\"Error.prototype\")", 0);
- toUInt16.insert("engine->evaluate(\"Object\")", 0);
- toUInt16.insert("engine->evaluate(\"Array\")", 0);
- toUInt16.insert("engine->evaluate(\"Number\")", 0);
- toUInt16.insert("engine->evaluate(\"Function\")", 0);
- toUInt16.insert("engine->evaluate(\"(function() { return 1; })\")", 0);
- toUInt16.insert("engine->evaluate(\"(function() { return 'ciao'; })\")", 0);
- toUInt16.insert("engine->evaluate(\"(function() { throw new Error('foo'); })\")", 0);
- toUInt16.insert("engine->evaluate(\"/foo/\")", 0);
- toUInt16.insert("engine->evaluate(\"new Object()\")", 0);
- toUInt16.insert("engine->evaluate(\"new Array()\")", 0);
- toUInt16.insert("engine->evaluate(\"new Error()\")", 0);
- toUInt16.insert("engine->evaluate(\"a = new Object(); a.foo = 22; a.foo\")", 22);
- toUInt16.insert("engine->evaluate(\"Undefined\")", 0);
- toUInt16.insert("engine->evaluate(\"Null\")", 0);
- toUInt16.insert("engine->evaluate(\"True\")", 0);
- toUInt16.insert("engine->evaluate(\"False\")", 0);
- toUInt16.insert("engine->evaluate(\"undefined\")", 0);
- toUInt16.insert("engine->evaluate(\"null\")", 0);
- toUInt16.insert("engine->evaluate(\"true\")", 1);
- toUInt16.insert("engine->evaluate(\"false\")", 0);
- toUInt16.insert("engine->evaluate(\"122\")", 122);
- toUInt16.insert("engine->evaluate(\"124\")", 124);
- toUInt16.insert("engine->evaluate(\"0\")", 0);
- toUInt16.insert("engine->evaluate(\"0.0\")", 0);
- toUInt16.insert("engine->evaluate(\"123.0\")", 123);
- toUInt16.insert("engine->evaluate(\"6.37e-8\")", 0);
- toUInt16.insert("engine->evaluate(\"-6.37e-8\")", 0);
- toUInt16.insert("engine->evaluate(\"0x43211234\")", 4660);
- toUInt16.insert("engine->evaluate(\"0x10000\")", 0);
- toUInt16.insert("engine->evaluate(\"0x10001\")", 1);
- toUInt16.insert("engine->evaluate(\"NaN\")", 0);
- toUInt16.insert("engine->evaluate(\"Infinity\")", 0);
- toUInt16.insert("engine->evaluate(\"-Infinity\")", 0);
- toUInt16.insert("engine->evaluate(\"'ciao'\")", 0);
- toUInt16.insert("engine->evaluate(\"''\")", 0);
- toUInt16.insert("engine->evaluate(\"'0'\")", 0);
- toUInt16.insert("engine->evaluate(\"'123'\")", 123);
- toUInt16.insert("engine->evaluate(\"'12.4'\")", 12);
- toUInt16.insert("engine->nullValue()", 0);
- toUInt16.insert("engine->undefinedValue()", 0);
- }
- newRow(expr) << toUInt16.value(expr);
-}
-
-void tst_QScriptValue::toUInt16_test(const char*, const QScriptValue& value)
-{
- QFETCH(quint16, expected);
- QCOMPARE(value.toUInt16(), expected);
- QCOMPARE(value.toUInt16(), expected);
-}
-
-DEFINE_TEST_FUNCTION(toUInt16)
diff --git a/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue_generated_init.cpp b/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue_generated_init.cpp
new file mode 100644
index 0000000..b68aaf2
--- /dev/null
+++ b/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue_generated_init.cpp
@@ -0,0 +1,165 @@
+/*
+ Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+/****************************************************************************
+*************** This file has been generated. DO NOT MODIFY! ****************
+****************************************************************************/
+
+#include "tst_qscriptvalue.h"
+
+
+void tst_QScriptValue::initScriptValues()
+{
+ m_values.clear();
+ if (engine)
+ delete engine;
+ engine = new QScriptEngine;
+ DEFINE_TEST_VALUE(QScriptValue());
+ DEFINE_TEST_VALUE(QScriptValue(QScriptValue::UndefinedValue));
+ DEFINE_TEST_VALUE(QScriptValue(QScriptValue::NullValue));
+ DEFINE_TEST_VALUE(QScriptValue(true));
+ DEFINE_TEST_VALUE(QScriptValue(false));
+ DEFINE_TEST_VALUE(QScriptValue(int(122)));
+ DEFINE_TEST_VALUE(QScriptValue(uint(124)));
+ DEFINE_TEST_VALUE(QScriptValue(0));
+ DEFINE_TEST_VALUE(QScriptValue(0.0));
+ DEFINE_TEST_VALUE(QScriptValue(123.0));
+ DEFINE_TEST_VALUE(QScriptValue(6.37e-8));
+ DEFINE_TEST_VALUE(QScriptValue(-6.37e-8));
+ DEFINE_TEST_VALUE(QScriptValue(0x43211234));
+ DEFINE_TEST_VALUE(QScriptValue(0x10000));
+ DEFINE_TEST_VALUE(QScriptValue(0x10001));
+ DEFINE_TEST_VALUE(QScriptValue(qSNaN()));
+ DEFINE_TEST_VALUE(QScriptValue(qQNaN()));
+ DEFINE_TEST_VALUE(QScriptValue(qInf()));
+ DEFINE_TEST_VALUE(QScriptValue(-qInf()));
+ DEFINE_TEST_VALUE(QScriptValue("NaN"));
+ DEFINE_TEST_VALUE(QScriptValue("Infinity"));
+ DEFINE_TEST_VALUE(QScriptValue("-Infinity"));
+ DEFINE_TEST_VALUE(QScriptValue("ciao"));
+ DEFINE_TEST_VALUE(QScriptValue(QString::fromLatin1("ciao")));
+ DEFINE_TEST_VALUE(QScriptValue(QString("")));
+ DEFINE_TEST_VALUE(QScriptValue(QString()));
+ DEFINE_TEST_VALUE(QScriptValue(QString("0")));
+ DEFINE_TEST_VALUE(QScriptValue(QString("123")));
+ DEFINE_TEST_VALUE(QScriptValue(QString("12.4")));
+ DEFINE_TEST_VALUE(QScriptValue(0, QScriptValue::UndefinedValue));
+ DEFINE_TEST_VALUE(QScriptValue(0, QScriptValue::NullValue));
+ DEFINE_TEST_VALUE(QScriptValue(0, true));
+ DEFINE_TEST_VALUE(QScriptValue(0, false));
+ DEFINE_TEST_VALUE(QScriptValue(0, int(122)));
+ DEFINE_TEST_VALUE(QScriptValue(0, uint(124)));
+ DEFINE_TEST_VALUE(QScriptValue(0, 0));
+ DEFINE_TEST_VALUE(QScriptValue(0, 0.0));
+ DEFINE_TEST_VALUE(QScriptValue(0, 123.0));
+ DEFINE_TEST_VALUE(QScriptValue(0, 6.37e-8));
+ DEFINE_TEST_VALUE(QScriptValue(0, -6.37e-8));
+ DEFINE_TEST_VALUE(QScriptValue(0, 0x43211234));
+ DEFINE_TEST_VALUE(QScriptValue(0, 0x10000));
+ DEFINE_TEST_VALUE(QScriptValue(0, 0x10001));
+ DEFINE_TEST_VALUE(QScriptValue(0, qSNaN()));
+ DEFINE_TEST_VALUE(QScriptValue(0, qQNaN()));
+ DEFINE_TEST_VALUE(QScriptValue(0, qInf()));
+ DEFINE_TEST_VALUE(QScriptValue(0, -qInf()));
+ DEFINE_TEST_VALUE(QScriptValue(0, "NaN"));
+ DEFINE_TEST_VALUE(QScriptValue(0, "Infinity"));
+ DEFINE_TEST_VALUE(QScriptValue(0, "-Infinity"));
+ DEFINE_TEST_VALUE(QScriptValue(0, "ciao"));
+ DEFINE_TEST_VALUE(QScriptValue(0, QString::fromLatin1("ciao")));
+ DEFINE_TEST_VALUE(QScriptValue(0, QString("")));
+ DEFINE_TEST_VALUE(QScriptValue(0, QString()));
+ DEFINE_TEST_VALUE(QScriptValue(0, QString("0")));
+ DEFINE_TEST_VALUE(QScriptValue(0, QString("123")));
+ DEFINE_TEST_VALUE(QScriptValue(0, QString("12.3")));
+ DEFINE_TEST_VALUE(QScriptValue(engine, QScriptValue::UndefinedValue));
+ DEFINE_TEST_VALUE(QScriptValue(engine, QScriptValue::NullValue));
+ DEFINE_TEST_VALUE(QScriptValue(engine, true));
+ DEFINE_TEST_VALUE(QScriptValue(engine, false));
+ DEFINE_TEST_VALUE(QScriptValue(engine, int(122)));
+ DEFINE_TEST_VALUE(QScriptValue(engine, uint(124)));
+ DEFINE_TEST_VALUE(QScriptValue(engine, 0));
+ DEFINE_TEST_VALUE(QScriptValue(engine, 0.0));
+ DEFINE_TEST_VALUE(QScriptValue(engine, 123.0));
+ DEFINE_TEST_VALUE(QScriptValue(engine, 6.37e-8));
+ DEFINE_TEST_VALUE(QScriptValue(engine, -6.37e-8));
+ DEFINE_TEST_VALUE(QScriptValue(engine, 0x43211234));
+ DEFINE_TEST_VALUE(QScriptValue(engine, 0x10000));
+ DEFINE_TEST_VALUE(QScriptValue(engine, 0x10001));
+ DEFINE_TEST_VALUE(QScriptValue(engine, qSNaN()));
+ DEFINE_TEST_VALUE(QScriptValue(engine, qQNaN()));
+ DEFINE_TEST_VALUE(QScriptValue(engine, qInf()));
+ DEFINE_TEST_VALUE(QScriptValue(engine, -qInf()));
+ DEFINE_TEST_VALUE(QScriptValue(engine, "NaN"));
+ DEFINE_TEST_VALUE(QScriptValue(engine, "Infinity"));
+ DEFINE_TEST_VALUE(QScriptValue(engine, "-Infinity"));
+ DEFINE_TEST_VALUE(QScriptValue(engine, "ciao"));
+ DEFINE_TEST_VALUE(QScriptValue(engine, QString::fromLatin1("ciao")));
+ DEFINE_TEST_VALUE(QScriptValue(engine, QString("")));
+ DEFINE_TEST_VALUE(QScriptValue(engine, QString()));
+ DEFINE_TEST_VALUE(QScriptValue(engine, QString("0")));
+ DEFINE_TEST_VALUE(QScriptValue(engine, QString("123")));
+ DEFINE_TEST_VALUE(QScriptValue(engine, QString("1.23")));
+ DEFINE_TEST_VALUE(engine->evaluate("[]"));
+ DEFINE_TEST_VALUE(engine->evaluate("{}"));
+ DEFINE_TEST_VALUE(engine->evaluate("Object.prototype"));
+ DEFINE_TEST_VALUE(engine->evaluate("Date.prototype"));
+ DEFINE_TEST_VALUE(engine->evaluate("Array.prototype"));
+ DEFINE_TEST_VALUE(engine->evaluate("Function.prototype"));
+ DEFINE_TEST_VALUE(engine->evaluate("Error.prototype"));
+ DEFINE_TEST_VALUE(engine->evaluate("Object"));
+ DEFINE_TEST_VALUE(engine->evaluate("Array"));
+ DEFINE_TEST_VALUE(engine->evaluate("Number"));
+ DEFINE_TEST_VALUE(engine->evaluate("Function"));
+ DEFINE_TEST_VALUE(engine->evaluate("(function() { return 1; })"));
+ DEFINE_TEST_VALUE(engine->evaluate("(function() { return 'ciao'; })"));
+ DEFINE_TEST_VALUE(engine->evaluate("(function() { throw new Error('foo' })"));
+ DEFINE_TEST_VALUE(engine->evaluate("/foo/"));
+ DEFINE_TEST_VALUE(engine->evaluate("new Object()"));
+ DEFINE_TEST_VALUE(engine->evaluate("new Array()"));
+ DEFINE_TEST_VALUE(engine->evaluate("new Error()"));
+ DEFINE_TEST_VALUE(engine->evaluate("a = new Object( a.foo = 22; a.foo"));
+ DEFINE_TEST_VALUE(engine->evaluate("Undefined"));
+ DEFINE_TEST_VALUE(engine->evaluate("Null"));
+ DEFINE_TEST_VALUE(engine->evaluate("True"));
+ DEFINE_TEST_VALUE(engine->evaluate("False"));
+ DEFINE_TEST_VALUE(engine->evaluate("undefined"));
+ DEFINE_TEST_VALUE(engine->evaluate("null"));
+ DEFINE_TEST_VALUE(engine->evaluate("true"));
+ DEFINE_TEST_VALUE(engine->evaluate("false"));
+ DEFINE_TEST_VALUE(engine->evaluate("122"));
+ DEFINE_TEST_VALUE(engine->evaluate("124"));
+ DEFINE_TEST_VALUE(engine->evaluate("0"));
+ DEFINE_TEST_VALUE(engine->evaluate("0.0"));
+ DEFINE_TEST_VALUE(engine->evaluate("123.0"));
+ DEFINE_TEST_VALUE(engine->evaluate("6.37e-8"));
+ DEFINE_TEST_VALUE(engine->evaluate("-6.37e-8"));
+ DEFINE_TEST_VALUE(engine->evaluate("0x43211234"));
+ DEFINE_TEST_VALUE(engine->evaluate("0x10000"));
+ DEFINE_TEST_VALUE(engine->evaluate("0x10001"));
+ DEFINE_TEST_VALUE(engine->evaluate("NaN"));
+ DEFINE_TEST_VALUE(engine->evaluate("Infinity"));
+ DEFINE_TEST_VALUE(engine->evaluate("-Infinity"));
+ DEFINE_TEST_VALUE(engine->evaluate("'ciao'"));
+ DEFINE_TEST_VALUE(engine->evaluate("''"));
+ DEFINE_TEST_VALUE(engine->evaluate("'0'"));
+ DEFINE_TEST_VALUE(engine->evaluate("'123'"));
+ DEFINE_TEST_VALUE(engine->evaluate("'12.4'"));
+ DEFINE_TEST_VALUE(engine->nullValue());
+ DEFINE_TEST_VALUE(engine->undefinedValue());
+}
diff --git a/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue_generated_istype.cpp b/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue_generated_istype.cpp
new file mode 100644
index 0000000..f1de77d
--- /dev/null
+++ b/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue_generated_istype.cpp
@@ -0,0 +1,567 @@
+/*
+ Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+
+/****************************************************************************
+*************** This file has been generated. DO NOT MODIFY! ****************
+****************************************************************************/
+
+#include "tst_qscriptvalue.h"
+
+
+void tst_QScriptValue::isValid_initData()
+{
+ QTest::addColumn<bool>("expected");
+ initScriptValues();
+}
+
+static QString isValid_array[] = {
+ "QScriptValue(QScriptValue::UndefinedValue)",
+ "QScriptValue(QScriptValue::NullValue)",
+ "QScriptValue(true)",
+ "QScriptValue(false)",
+ "QScriptValue(int(122))",
+ "QScriptValue(uint(124))",
+ "QScriptValue(0)",
+ "QScriptValue(0.0)",
+ "QScriptValue(123.0)",
+ "QScriptValue(6.37e-8)",
+ "QScriptValue(-6.37e-8)",
+ "QScriptValue(0x43211234)",
+ "QScriptValue(0x10000)",
+ "QScriptValue(0x10001)",
+ "QScriptValue(qSNaN())",
+ "QScriptValue(qQNaN())",
+ "QScriptValue(qInf())",
+ "QScriptValue(-qInf())",
+ "QScriptValue(\"NaN\")",
+ "QScriptValue(\"Infinity\")",
+ "QScriptValue(\"-Infinity\")",
+ "QScriptValue(\"ciao\")",
+ "QScriptValue(QString::fromLatin1(\"ciao\"))",
+ "QScriptValue(QString(\"\"))",
+ "QScriptValue(QString())",
+ "QScriptValue(QString(\"0\"))",
+ "QScriptValue(QString(\"123\"))",
+ "QScriptValue(QString(\"12.4\"))",
+ "QScriptValue(0, QScriptValue::UndefinedValue)",
+ "QScriptValue(0, QScriptValue::NullValue)",
+ "QScriptValue(0, true)",
+ "QScriptValue(0, false)",
+ "QScriptValue(0, int(122))",
+ "QScriptValue(0, uint(124))",
+ "QScriptValue(0, 0)",
+ "QScriptValue(0, 0.0)",
+ "QScriptValue(0, 123.0)",
+ "QScriptValue(0, 6.37e-8)",
+ "QScriptValue(0, -6.37e-8)",
+ "QScriptValue(0, 0x43211234)",
+ "QScriptValue(0, 0x10000)",
+ "QScriptValue(0, 0x10001)",
+ "QScriptValue(0, qSNaN())",
+ "QScriptValue(0, qQNaN())",
+ "QScriptValue(0, qInf())",
+ "QScriptValue(0, -qInf())",
+ "QScriptValue(0, \"NaN\")",
+ "QScriptValue(0, \"Infinity\")",
+ "QScriptValue(0, \"-Infinity\")",
+ "QScriptValue(0, \"ciao\")",
+ "QScriptValue(0, QString::fromLatin1(\"ciao\"))",
+ "QScriptValue(0, QString(\"\"))",
+ "QScriptValue(0, QString())",
+ "QScriptValue(0, QString(\"0\"))",
+ "QScriptValue(0, QString(\"123\"))",
+ "QScriptValue(0, QString(\"12.3\"))",
+ "QScriptValue(engine, QScriptValue::UndefinedValue)",
+ "QScriptValue(engine, QScriptValue::NullValue)",
+ "QScriptValue(engine, true)",
+ "QScriptValue(engine, false)",
+ "QScriptValue(engine, int(122))",
+ "QScriptValue(engine, uint(124))",
+ "QScriptValue(engine, 0)",
+ "QScriptValue(engine, 0.0)",
+ "QScriptValue(engine, 123.0)",
+ "QScriptValue(engine, 6.37e-8)",
+ "QScriptValue(engine, -6.37e-8)",
+ "QScriptValue(engine, 0x43211234)",
+ "QScriptValue(engine, 0x10000)",
+ "QScriptValue(engine, 0x10001)",
+ "QScriptValue(engine, qSNaN())",
+ "QScriptValue(engine, qQNaN())",
+ "QScriptValue(engine, qInf())",
+ "QScriptValue(engine, -qInf())",
+ "QScriptValue(engine, \"NaN\")",
+ "QScriptValue(engine, \"Infinity\")",
+ "QScriptValue(engine, \"-Infinity\")",
+ "QScriptValue(engine, \"ciao\")",
+ "QScriptValue(engine, QString::fromLatin1(\"ciao\"))",
+ "QScriptValue(engine, QString(\"\"))",
+ "QScriptValue(engine, QString())",
+ "QScriptValue(engine, QString(\"0\"))",
+ "QScriptValue(engine, QString(\"123\"))",
+ "QScriptValue(engine, QString(\"1.23\"))",
+ "engine->evaluate(\"[]\")",
+ "engine->evaluate(\"{}\")",
+ "engine->evaluate(\"Object.prototype\")",
+ "engine->evaluate(\"Date.prototype\")",
+ "engine->evaluate(\"Array.prototype\")",
+ "engine->evaluate(\"Function.prototype\")",
+ "engine->evaluate(\"Error.prototype\")",
+ "engine->evaluate(\"Object\")",
+ "engine->evaluate(\"Array\")",
+ "engine->evaluate(\"Number\")",
+ "engine->evaluate(\"Function\")",
+ "engine->evaluate(\"(function() { return 1; })\")",
+ "engine->evaluate(\"(function() { return 'ciao'; })\")",
+ "engine->evaluate(\"(function() { throw new Error('foo' })\")",
+ "engine->evaluate(\"/foo/\")",
+ "engine->evaluate(\"new Object()\")",
+ "engine->evaluate(\"new Array()\")",
+ "engine->evaluate(\"new Error()\")",
+ "engine->evaluate(\"a = new Object( a.foo = 22; a.foo\")",
+ "engine->evaluate(\"Undefined\")",
+ "engine->evaluate(\"Null\")",
+ "engine->evaluate(\"True\")",
+ "engine->evaluate(\"False\")",
+ "engine->evaluate(\"undefined\")",
+ "engine->evaluate(\"null\")",
+ "engine->evaluate(\"true\")",
+ "engine->evaluate(\"false\")",
+ "engine->evaluate(\"122\")",
+ "engine->evaluate(\"124\")",
+ "engine->evaluate(\"0\")",
+ "engine->evaluate(\"0.0\")",
+ "engine->evaluate(\"123.0\")",
+ "engine->evaluate(\"6.37e-8\")",
+ "engine->evaluate(\"-6.37e-8\")",
+ "engine->evaluate(\"0x43211234\")",
+ "engine->evaluate(\"0x10000\")",
+ "engine->evaluate(\"0x10001\")",
+ "engine->evaluate(\"NaN\")",
+ "engine->evaluate(\"Infinity\")",
+ "engine->evaluate(\"-Infinity\")",
+ "engine->evaluate(\"'ciao'\")",
+ "engine->evaluate(\"''\")",
+ "engine->evaluate(\"'0'\")",
+ "engine->evaluate(\"'123'\")",
+ "engine->evaluate(\"'12.4'\")",
+ "engine->nullValue()",
+ "engine->undefinedValue()"};
+
+void tst_QScriptValue::isValid_makeData(const char* expr)
+{
+ static QSet<QString> isValid;
+ if (isValid.isEmpty()) {
+ isValid.reserve(131);
+ for (unsigned i = 0; i < 131; ++i)
+ isValid.insert(isValid_array[i]);
+ }
+ newRow(expr) << isValid.contains(expr);
+}
+
+void tst_QScriptValue::isValid_test(const char*, const QScriptValue& value)
+{
+ QFETCH(bool, expected);
+ QCOMPARE(value.isValid(), expected);
+ QCOMPARE(value.isValid(), expected);
+}
+
+DEFINE_TEST_FUNCTION(isValid)
+
+
+void tst_QScriptValue::isBool_initData()
+{
+ QTest::addColumn<bool>("expected");
+ initScriptValues();
+}
+
+static QString isBool_array[] = {
+ "QScriptValue(true)",
+ "QScriptValue(false)",
+ "QScriptValue(0, true)",
+ "QScriptValue(0, false)",
+ "QScriptValue(engine, true)",
+ "QScriptValue(engine, false)",
+ "engine->evaluate(\"true\")",
+ "engine->evaluate(\"false\")"};
+
+void tst_QScriptValue::isBool_makeData(const char* expr)
+{
+ static QSet<QString> isBool;
+ if (isBool.isEmpty()) {
+ isBool.reserve(8);
+ for (unsigned i = 0; i < 8; ++i)
+ isBool.insert(isBool_array[i]);
+ }
+ newRow(expr) << isBool.contains(expr);
+}
+
+void tst_QScriptValue::isBool_test(const char*, const QScriptValue& value)
+{
+ QFETCH(bool, expected);
+ QCOMPARE(value.isBool(), expected);
+ QCOMPARE(value.isBool(), expected);
+}
+
+DEFINE_TEST_FUNCTION(isBool)
+
+
+void tst_QScriptValue::isBoolean_initData()
+{
+ QTest::addColumn<bool>("expected");
+ initScriptValues();
+}
+
+static QString isBoolean_array[] = {
+ "QScriptValue(true)",
+ "QScriptValue(false)",
+ "QScriptValue(0, true)",
+ "QScriptValue(0, false)",
+ "QScriptValue(engine, true)",
+ "QScriptValue(engine, false)",
+ "engine->evaluate(\"true\")",
+ "engine->evaluate(\"false\")"};
+
+void tst_QScriptValue::isBoolean_makeData(const char* expr)
+{
+ static QSet<QString> isBoolean;
+ if (isBoolean.isEmpty()) {
+ isBoolean.reserve(8);
+ for (unsigned i = 0; i < 8; ++i)
+ isBoolean.insert(isBoolean_array[i]);
+ }
+ newRow(expr) << isBoolean.contains(expr);
+}
+
+void tst_QScriptValue::isBoolean_test(const char*, const QScriptValue& value)
+{
+ QFETCH(bool, expected);
+ QCOMPARE(value.isBoolean(), expected);
+ QCOMPARE(value.isBoolean(), expected);
+}
+
+DEFINE_TEST_FUNCTION(isBoolean)
+
+
+void tst_QScriptValue::isNumber_initData()
+{
+ QTest::addColumn<bool>("expected");
+ initScriptValues();
+}
+
+static QString isNumber_array[] = {
+ "QScriptValue(int(122))",
+ "QScriptValue(uint(124))",
+ "QScriptValue(0)",
+ "QScriptValue(0.0)",
+ "QScriptValue(123.0)",
+ "QScriptValue(6.37e-8)",
+ "QScriptValue(-6.37e-8)",
+ "QScriptValue(0x43211234)",
+ "QScriptValue(0x10000)",
+ "QScriptValue(0x10001)",
+ "QScriptValue(qSNaN())",
+ "QScriptValue(qQNaN())",
+ "QScriptValue(qInf())",
+ "QScriptValue(-qInf())",
+ "QScriptValue(0, int(122))",
+ "QScriptValue(0, uint(124))",
+ "QScriptValue(0, 0)",
+ "QScriptValue(0, 0.0)",
+ "QScriptValue(0, 123.0)",
+ "QScriptValue(0, 6.37e-8)",
+ "QScriptValue(0, -6.37e-8)",
+ "QScriptValue(0, 0x43211234)",
+ "QScriptValue(0, 0x10000)",
+ "QScriptValue(0, 0x10001)",
+ "QScriptValue(0, qSNaN())",
+ "QScriptValue(0, qQNaN())",
+ "QScriptValue(0, qInf())",
+ "QScriptValue(0, -qInf())",
+ "QScriptValue(engine, int(122))",
+ "QScriptValue(engine, uint(124))",
+ "QScriptValue(engine, 0)",
+ "QScriptValue(engine, 0.0)",
+ "QScriptValue(engine, 123.0)",
+ "QScriptValue(engine, 6.37e-8)",
+ "QScriptValue(engine, -6.37e-8)",
+ "QScriptValue(engine, 0x43211234)",
+ "QScriptValue(engine, 0x10000)",
+ "QScriptValue(engine, 0x10001)",
+ "QScriptValue(engine, qSNaN())",
+ "QScriptValue(engine, qQNaN())",
+ "QScriptValue(engine, qInf())",
+ "QScriptValue(engine, -qInf())",
+ "engine->evaluate(\"122\")",
+ "engine->evaluate(\"124\")",
+ "engine->evaluate(\"0\")",
+ "engine->evaluate(\"0.0\")",
+ "engine->evaluate(\"123.0\")",
+ "engine->evaluate(\"6.37e-8\")",
+ "engine->evaluate(\"-6.37e-8\")",
+ "engine->evaluate(\"0x43211234\")",
+ "engine->evaluate(\"0x10000\")",
+ "engine->evaluate(\"0x10001\")",
+ "engine->evaluate(\"NaN\")",
+ "engine->evaluate(\"Infinity\")",
+ "engine->evaluate(\"-Infinity\")"};
+
+void tst_QScriptValue::isNumber_makeData(const char* expr)
+{
+ static QSet<QString> isNumber;
+ if (isNumber.isEmpty()) {
+ isNumber.reserve(55);
+ for (unsigned i = 0; i < 55; ++i)
+ isNumber.insert(isNumber_array[i]);
+ }
+ newRow(expr) << isNumber.contains(expr);
+}
+
+void tst_QScriptValue::isNumber_test(const char*, const QScriptValue& value)
+{
+ QFETCH(bool, expected);
+ QCOMPARE(value.isNumber(), expected);
+ QCOMPARE(value.isNumber(), expected);
+}
+
+DEFINE_TEST_FUNCTION(isNumber)
+
+
+void tst_QScriptValue::isFunction_initData()
+{
+ QTest::addColumn<bool>("expected");
+ initScriptValues();
+}
+
+static QString isFunction_array[] = {
+ "engine->evaluate(\"Function.prototype\")",
+ "engine->evaluate(\"Object\")",
+ "engine->evaluate(\"Array\")",
+ "engine->evaluate(\"Number\")",
+ "engine->evaluate(\"Function\")",
+ "engine->evaluate(\"(function() { return 1; })\")",
+ "engine->evaluate(\"(function() { return 'ciao'; })\")",
+ "engine->evaluate(\"/foo/\")"};
+
+void tst_QScriptValue::isFunction_makeData(const char* expr)
+{
+ static QSet<QString> isFunction;
+ if (isFunction.isEmpty()) {
+ isFunction.reserve(8);
+ for (unsigned i = 0; i < 8; ++i)
+ isFunction.insert(isFunction_array[i]);
+ }
+ newRow(expr) << isFunction.contains(expr);
+}
+
+void tst_QScriptValue::isFunction_test(const char*, const QScriptValue& value)
+{
+ QFETCH(bool, expected);
+ QCOMPARE(value.isFunction(), expected);
+ QCOMPARE(value.isFunction(), expected);
+}
+
+DEFINE_TEST_FUNCTION(isFunction)
+
+
+void tst_QScriptValue::isNull_initData()
+{
+ QTest::addColumn<bool>("expected");
+ initScriptValues();
+}
+
+static QString isNull_array[] = {
+ "QScriptValue(QScriptValue::NullValue)",
+ "QScriptValue(0, QScriptValue::NullValue)",
+ "QScriptValue(engine, QScriptValue::NullValue)",
+ "engine->evaluate(\"null\")",
+ "engine->nullValue()"};
+
+void tst_QScriptValue::isNull_makeData(const char* expr)
+{
+ static QSet<QString> isNull;
+ if (isNull.isEmpty()) {
+ isNull.reserve(5);
+ for (unsigned i = 0; i < 5; ++i)
+ isNull.insert(isNull_array[i]);
+ }
+ newRow(expr) << isNull.contains(expr);
+}
+
+void tst_QScriptValue::isNull_test(const char*, const QScriptValue& value)
+{
+ QFETCH(bool, expected);
+ QCOMPARE(value.isNull(), expected);
+ QCOMPARE(value.isNull(), expected);
+}
+
+DEFINE_TEST_FUNCTION(isNull)
+
+
+void tst_QScriptValue::isString_initData()
+{
+ QTest::addColumn<bool>("expected");
+ initScriptValues();
+}
+
+static QString isString_array[] = {
+ "QScriptValue(\"NaN\")",
+ "QScriptValue(\"Infinity\")",
+ "QScriptValue(\"-Infinity\")",
+ "QScriptValue(\"ciao\")",
+ "QScriptValue(QString::fromLatin1(\"ciao\"))",
+ "QScriptValue(QString(\"\"))",
+ "QScriptValue(QString())",
+ "QScriptValue(QString(\"0\"))",
+ "QScriptValue(QString(\"123\"))",
+ "QScriptValue(QString(\"12.4\"))",
+ "QScriptValue(0, \"NaN\")",
+ "QScriptValue(0, \"Infinity\")",
+ "QScriptValue(0, \"-Infinity\")",
+ "QScriptValue(0, \"ciao\")",
+ "QScriptValue(0, QString::fromLatin1(\"ciao\"))",
+ "QScriptValue(0, QString(\"\"))",
+ "QScriptValue(0, QString())",
+ "QScriptValue(0, QString(\"0\"))",
+ "QScriptValue(0, QString(\"123\"))",
+ "QScriptValue(0, QString(\"12.3\"))",
+ "QScriptValue(engine, \"NaN\")",
+ "QScriptValue(engine, \"Infinity\")",
+ "QScriptValue(engine, \"-Infinity\")",
+ "QScriptValue(engine, \"ciao\")",
+ "QScriptValue(engine, QString::fromLatin1(\"ciao\"))",
+ "QScriptValue(engine, QString(\"\"))",
+ "QScriptValue(engine, QString())",
+ "QScriptValue(engine, QString(\"0\"))",
+ "QScriptValue(engine, QString(\"123\"))",
+ "QScriptValue(engine, QString(\"1.23\"))",
+ "engine->evaluate(\"'ciao'\")",
+ "engine->evaluate(\"''\")",
+ "engine->evaluate(\"'0'\")",
+ "engine->evaluate(\"'123'\")",
+ "engine->evaluate(\"'12.4'\")"};
+
+void tst_QScriptValue::isString_makeData(const char* expr)
+{
+ static QSet<QString> isString;
+ if (isString.isEmpty()) {
+ isString.reserve(35);
+ for (unsigned i = 0; i < 35; ++i)
+ isString.insert(isString_array[i]);
+ }
+ newRow(expr) << isString.contains(expr);
+}
+
+void tst_QScriptValue::isString_test(const char*, const QScriptValue& value)
+{
+ QFETCH(bool, expected);
+ QCOMPARE(value.isString(), expected);
+ QCOMPARE(value.isString(), expected);
+}
+
+DEFINE_TEST_FUNCTION(isString)
+
+
+void tst_QScriptValue::isUndefined_initData()
+{
+ QTest::addColumn<bool>("expected");
+ initScriptValues();
+}
+
+static QString isUndefined_array[] = {
+ "QScriptValue(QScriptValue::UndefinedValue)",
+ "QScriptValue(0, QScriptValue::UndefinedValue)",
+ "QScriptValue(engine, QScriptValue::UndefinedValue)",
+ "engine->evaluate(\"{}\")",
+ "engine->evaluate(\"undefined\")",
+ "engine->undefinedValue()"};
+
+void tst_QScriptValue::isUndefined_makeData(const char* expr)
+{
+ static QSet<QString> isUndefined;
+ if (isUndefined.isEmpty()) {
+ isUndefined.reserve(6);
+ for (unsigned i = 0; i < 6; ++i)
+ isUndefined.insert(isUndefined_array[i]);
+ }
+ newRow(expr) << isUndefined.contains(expr);
+}
+
+void tst_QScriptValue::isUndefined_test(const char*, const QScriptValue& value)
+{
+ QFETCH(bool, expected);
+ QCOMPARE(value.isUndefined(), expected);
+ QCOMPARE(value.isUndefined(), expected);
+}
+
+DEFINE_TEST_FUNCTION(isUndefined)
+
+
+
+
+
+void tst_QScriptValue::isObject_initData()
+{
+ QTest::addColumn<bool>("expected");
+ initScriptValues();
+}
+
+static QString isObject_array[] = {
+ "engine->evaluate(\"[]\")",
+ "engine->evaluate(\"Object.prototype\")",
+ "engine->evaluate(\"Date.prototype\")",
+ "engine->evaluate(\"Array.prototype\")",
+ "engine->evaluate(\"Function.prototype\")",
+ "engine->evaluate(\"Error.prototype\")",
+ "engine->evaluate(\"Object\")",
+ "engine->evaluate(\"Array\")",
+ "engine->evaluate(\"Number\")",
+ "engine->evaluate(\"Function\")",
+ "engine->evaluate(\"(function() { return 1; })\")",
+ "engine->evaluate(\"(function() { return 'ciao'; })\")",
+ "engine->evaluate(\"(function() { throw new Error('foo' })\")",
+ "engine->evaluate(\"/foo/\")",
+ "engine->evaluate(\"new Object()\")",
+ "engine->evaluate(\"new Array()\")",
+ "engine->evaluate(\"new Error()\")",
+ "engine->evaluate(\"a = new Object( a.foo = 22; a.foo\")",
+ "engine->evaluate(\"Undefined\")",
+ "engine->evaluate(\"Null\")",
+ "engine->evaluate(\"True\")",
+ "engine->evaluate(\"False\")"};
+
+void tst_QScriptValue::isObject_makeData(const char* expr)
+{
+ static QSet<QString> isObject;
+ if (isObject.isEmpty()) {
+ isObject.reserve(22);
+ for (unsigned i = 0; i < 22; ++i)
+ isObject.insert(isObject_array[i]);
+ }
+ newRow(expr) << isObject.contains(expr);
+}
+
+void tst_QScriptValue::isObject_test(const char*, const QScriptValue& value)
+{
+ QFETCH(bool, expected);
+ QCOMPARE(value.isObject(), expected);
+ QCOMPARE(value.isObject(), expected);
+}
+
+DEFINE_TEST_FUNCTION(isObject)
diff --git a/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue_generated_totype.cpp b/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue_generated_totype.cpp
new file mode 100644
index 0000000..a946aef
--- /dev/null
+++ b/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue_generated_totype.cpp
@@ -0,0 +1,1763 @@
+/*
+ Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+/****************************************************************************
+*************** This file has been generated. DO NOT MODIFY! ****************
+****************************************************************************/
+
+#include "tst_qscriptvalue.h"
+
+
+
+void tst_QScriptValue::toString_initData()
+{
+ QTest::addColumn<QString>("expected");
+ initScriptValues();
+}
+
+static QString toString_tagArray[] = {
+ "QScriptValue()",
+ "QScriptValue(QScriptValue::UndefinedValue)",
+ "QScriptValue(QScriptValue::NullValue)",
+ "QScriptValue(true)",
+ "QScriptValue(false)",
+ "QScriptValue(int(122))",
+ "QScriptValue(uint(124))",
+ "QScriptValue(0)",
+ "QScriptValue(0.0)",
+ "QScriptValue(123.0)",
+ "QScriptValue(6.37e-8)",
+ "QScriptValue(-6.37e-8)",
+ "QScriptValue(0x43211234)",
+ "QScriptValue(0x10000)",
+ "QScriptValue(0x10001)",
+ "QScriptValue(qSNaN())",
+ "QScriptValue(qQNaN())",
+ "QScriptValue(qInf())",
+ "QScriptValue(-qInf())",
+ "QScriptValue(\"NaN\")",
+ "QScriptValue(\"Infinity\")",
+ "QScriptValue(\"-Infinity\")",
+ "QScriptValue(\"ciao\")",
+ "QScriptValue(QString::fromLatin1(\"ciao\"))",
+ "QScriptValue(QString(\"\"))",
+ "QScriptValue(QString())",
+ "QScriptValue(QString(\"0\"))",
+ "QScriptValue(QString(\"123\"))",
+ "QScriptValue(QString(\"12.4\"))",
+ "QScriptValue(0, QScriptValue::UndefinedValue)",
+ "QScriptValue(0, QScriptValue::NullValue)",
+ "QScriptValue(0, true)",
+ "QScriptValue(0, false)",
+ "QScriptValue(0, int(122))",
+ "QScriptValue(0, uint(124))",
+ "QScriptValue(0, 0)",
+ "QScriptValue(0, 0.0)",
+ "QScriptValue(0, 123.0)",
+ "QScriptValue(0, 6.37e-8)",
+ "QScriptValue(0, -6.37e-8)",
+ "QScriptValue(0, 0x43211234)",
+ "QScriptValue(0, 0x10000)",
+ "QScriptValue(0, 0x10001)",
+ "QScriptValue(0, qSNaN())",
+ "QScriptValue(0, qQNaN())",
+ "QScriptValue(0, qInf())",
+ "QScriptValue(0, -qInf())",
+ "QScriptValue(0, \"NaN\")",
+ "QScriptValue(0, \"Infinity\")",
+ "QScriptValue(0, \"-Infinity\")",
+ "QScriptValue(0, \"ciao\")",
+ "QScriptValue(0, QString::fromLatin1(\"ciao\"))",
+ "QScriptValue(0, QString(\"\"))",
+ "QScriptValue(0, QString())",
+ "QScriptValue(0, QString(\"0\"))",
+ "QScriptValue(0, QString(\"123\"))",
+ "QScriptValue(0, QString(\"12.3\"))",
+ "QScriptValue(engine, QScriptValue::UndefinedValue)",
+ "QScriptValue(engine, QScriptValue::NullValue)",
+ "QScriptValue(engine, true)",
+ "QScriptValue(engine, false)",
+ "QScriptValue(engine, int(122))",
+ "QScriptValue(engine, uint(124))",
+ "QScriptValue(engine, 0)",
+ "QScriptValue(engine, 0.0)",
+ "QScriptValue(engine, 123.0)",
+ "QScriptValue(engine, 6.37e-8)",
+ "QScriptValue(engine, -6.37e-8)",
+ "QScriptValue(engine, 0x43211234)",
+ "QScriptValue(engine, 0x10000)",
+ "QScriptValue(engine, 0x10001)",
+ "QScriptValue(engine, qSNaN())",
+ "QScriptValue(engine, qQNaN())",
+ "QScriptValue(engine, qInf())",
+ "QScriptValue(engine, -qInf())",
+ "QScriptValue(engine, \"NaN\")",
+ "QScriptValue(engine, \"Infinity\")",
+ "QScriptValue(engine, \"-Infinity\")",
+ "QScriptValue(engine, \"ciao\")",
+ "QScriptValue(engine, QString::fromLatin1(\"ciao\"))",
+ "QScriptValue(engine, QString(\"\"))",
+ "QScriptValue(engine, QString())",
+ "QScriptValue(engine, QString(\"0\"))",
+ "QScriptValue(engine, QString(\"123\"))",
+ "QScriptValue(engine, QString(\"1.23\"))",
+ "engine->evaluate(\"[]\")",
+ "engine->evaluate(\"{}\")",
+ "engine->evaluate(\"Object.prototype\")",
+ "engine->evaluate(\"Date.prototype\")",
+ "engine->evaluate(\"Array.prototype\")",
+ "engine->evaluate(\"Function.prototype\")",
+ "engine->evaluate(\"Error.prototype\")",
+ "engine->evaluate(\"Object\")",
+ "engine->evaluate(\"Array\")",
+ "engine->evaluate(\"Number\")",
+ "engine->evaluate(\"Function\")",
+ "engine->evaluate(\"(function() { return 1; })\")",
+ "engine->evaluate(\"(function() { return 'ciao'; })\")",
+ "engine->evaluate(\"(function() { throw new Error('foo' })\")",
+ "engine->evaluate(\"/foo/\")",
+ "engine->evaluate(\"new Object()\")",
+ "engine->evaluate(\"new Array()\")",
+ "engine->evaluate(\"new Error()\")",
+ "engine->evaluate(\"a = new Object( a.foo = 22; a.foo\")",
+ "engine->evaluate(\"Undefined\")",
+ "engine->evaluate(\"Null\")",
+ "engine->evaluate(\"True\")",
+ "engine->evaluate(\"False\")",
+ "engine->evaluate(\"undefined\")",
+ "engine->evaluate(\"null\")",
+ "engine->evaluate(\"true\")",
+ "engine->evaluate(\"false\")",
+ "engine->evaluate(\"122\")",
+ "engine->evaluate(\"124\")",
+ "engine->evaluate(\"0\")",
+ "engine->evaluate(\"0.0\")",
+ "engine->evaluate(\"123.0\")",
+ "engine->evaluate(\"6.37e-8\")",
+ "engine->evaluate(\"-6.37e-8\")",
+ "engine->evaluate(\"0x43211234\")",
+ "engine->evaluate(\"0x10000\")",
+ "engine->evaluate(\"0x10001\")",
+ "engine->evaluate(\"NaN\")",
+ "engine->evaluate(\"Infinity\")",
+ "engine->evaluate(\"-Infinity\")",
+ "engine->evaluate(\"'ciao'\")",
+ "engine->evaluate(\"''\")",
+ "engine->evaluate(\"'0'\")",
+ "engine->evaluate(\"'123'\")",
+ "engine->evaluate(\"'12.4'\")",
+ "engine->nullValue()",
+ "engine->undefinedValue()"};
+
+static QString toString_valueArray[] = {
+ "", "undefined",
+ "null", "true",
+ "false", "122",
+ "124", "0",
+ "0", "123",
+ "6.37e-8", "-6.37e-8",
+ "1126240820", "65536",
+ "65537", "NaN",
+ "NaN", "Infinity",
+ "-Infinity", "NaN",
+ "Infinity", "-Infinity",
+ "ciao", "ciao",
+ "", "",
+ "0", "123",
+ "12.4", "undefined",
+ "null", "true",
+ "false", "122",
+ "124", "0",
+ "0", "123",
+ "6.37e-8", "-6.37e-8",
+ "1126240820", "65536",
+ "65537", "NaN",
+ "NaN", "Infinity",
+ "-Infinity", "NaN",
+ "Infinity", "-Infinity",
+ "ciao", "ciao",
+ "", "",
+ "0", "123",
+ "12.3", "undefined",
+ "null", "true",
+ "false", "122",
+ "124", "0",
+ "0", "123",
+ "6.37e-8", "-6.37e-8",
+ "1126240820", "65536",
+ "65537", "NaN",
+ "NaN", "Infinity",
+ "-Infinity", "NaN",
+ "Infinity", "-Infinity",
+ "ciao", "ciao",
+ "", "",
+ "0", "123",
+ "1.23", "",
+ "undefined", "[object Object]",
+ "Invalid Date", "",
+ "function () {\n [native code]\n}", "Error: Unknown error",
+ "function Object() {\n [native code]\n}", "function Array() {\n [native code]\n}",
+ "function Number() {\n [native code]\n}", "function Function() {\n [native code]\n}",
+ "function () { return 1; }", "function () { return 'ciao'; }",
+ "SyntaxError: Parse error", "/foo/",
+ "[object Object]", "",
+ "Error: Unknown error", "SyntaxError: Parse error",
+ "ReferenceError: Can't find variable: Undefined", "ReferenceError: Can't find variable: Null",
+ "ReferenceError: Can't find variable: True", "ReferenceError: Can't find variable: False",
+ "undefined", "null",
+ "true", "false",
+ "122", "124",
+ "0", "0",
+ "123", "6.37e-8",
+ "-6.37e-8", "1126240820",
+ "65536", "65537",
+ "NaN", "Infinity",
+ "-Infinity", "ciao",
+ "", "0",
+ "123", "12.4",
+ "null", "undefined"};
+
+void tst_QScriptValue::toString_makeData(const char* expr)
+{
+ static QHash<QString, QString> toString;
+ if (toString.isEmpty()) {
+ toString.reserve(132);
+ for (unsigned i = 0; i < 132; ++i)
+ toString.insert(toString_tagArray[i], toString_valueArray[i]);
+ }
+ newRow(expr) << toString.value(expr);
+}
+
+void tst_QScriptValue::toString_test(const char*, const QScriptValue& value)
+{
+ QFETCH(QString, expected);
+ QCOMPARE(value.toString(), expected);
+ QCOMPARE(value.toString(), expected);
+}
+
+DEFINE_TEST_FUNCTION(toString)
+
+
+void tst_QScriptValue::toNumber_initData()
+{
+ QTest::addColumn<qsreal>("expected");
+ initScriptValues();
+}
+
+static QString toNumber_tagArray[] = {
+ "QScriptValue()",
+ "QScriptValue(QScriptValue::UndefinedValue)",
+ "QScriptValue(QScriptValue::NullValue)",
+ "QScriptValue(true)",
+ "QScriptValue(false)",
+ "QScriptValue(int(122))",
+ "QScriptValue(uint(124))",
+ "QScriptValue(0)",
+ "QScriptValue(0.0)",
+ "QScriptValue(123.0)",
+ "QScriptValue(6.37e-8)",
+ "QScriptValue(-6.37e-8)",
+ "QScriptValue(0x43211234)",
+ "QScriptValue(0x10000)",
+ "QScriptValue(0x10001)",
+ "QScriptValue(qSNaN())",
+ "QScriptValue(qQNaN())",
+ "QScriptValue(qInf())",
+ "QScriptValue(-qInf())",
+ "QScriptValue(\"NaN\")",
+ "QScriptValue(\"Infinity\")",
+ "QScriptValue(\"-Infinity\")",
+ "QScriptValue(\"ciao\")",
+ "QScriptValue(QString::fromLatin1(\"ciao\"))",
+ "QScriptValue(QString(\"\"))",
+ "QScriptValue(QString())",
+ "QScriptValue(QString(\"0\"))",
+ "QScriptValue(QString(\"123\"))",
+ "QScriptValue(QString(\"12.4\"))",
+ "QScriptValue(0, QScriptValue::UndefinedValue)",
+ "QScriptValue(0, QScriptValue::NullValue)",
+ "QScriptValue(0, true)",
+ "QScriptValue(0, false)",
+ "QScriptValue(0, int(122))",
+ "QScriptValue(0, uint(124))",
+ "QScriptValue(0, 0)",
+ "QScriptValue(0, 0.0)",
+ "QScriptValue(0, 123.0)",
+ "QScriptValue(0, 6.37e-8)",
+ "QScriptValue(0, -6.37e-8)",
+ "QScriptValue(0, 0x43211234)",
+ "QScriptValue(0, 0x10000)",
+ "QScriptValue(0, 0x10001)",
+ "QScriptValue(0, qSNaN())",
+ "QScriptValue(0, qQNaN())",
+ "QScriptValue(0, qInf())",
+ "QScriptValue(0, -qInf())",
+ "QScriptValue(0, \"NaN\")",
+ "QScriptValue(0, \"Infinity\")",
+ "QScriptValue(0, \"-Infinity\")",
+ "QScriptValue(0, \"ciao\")",
+ "QScriptValue(0, QString::fromLatin1(\"ciao\"))",
+ "QScriptValue(0, QString(\"\"))",
+ "QScriptValue(0, QString())",
+ "QScriptValue(0, QString(\"0\"))",
+ "QScriptValue(0, QString(\"123\"))",
+ "QScriptValue(0, QString(\"12.3\"))",
+ "QScriptValue(engine, QScriptValue::UndefinedValue)",
+ "QScriptValue(engine, QScriptValue::NullValue)",
+ "QScriptValue(engine, true)",
+ "QScriptValue(engine, false)",
+ "QScriptValue(engine, int(122))",
+ "QScriptValue(engine, uint(124))",
+ "QScriptValue(engine, 0)",
+ "QScriptValue(engine, 0.0)",
+ "QScriptValue(engine, 123.0)",
+ "QScriptValue(engine, 6.37e-8)",
+ "QScriptValue(engine, -6.37e-8)",
+ "QScriptValue(engine, 0x43211234)",
+ "QScriptValue(engine, 0x10000)",
+ "QScriptValue(engine, 0x10001)",
+ "QScriptValue(engine, qSNaN())",
+ "QScriptValue(engine, qQNaN())",
+ "QScriptValue(engine, qInf())",
+ "QScriptValue(engine, -qInf())",
+ "QScriptValue(engine, \"NaN\")",
+ "QScriptValue(engine, \"Infinity\")",
+ "QScriptValue(engine, \"-Infinity\")",
+ "QScriptValue(engine, \"ciao\")",
+ "QScriptValue(engine, QString::fromLatin1(\"ciao\"))",
+ "QScriptValue(engine, QString(\"\"))",
+ "QScriptValue(engine, QString())",
+ "QScriptValue(engine, QString(\"0\"))",
+ "QScriptValue(engine, QString(\"123\"))",
+ "QScriptValue(engine, QString(\"1.23\"))",
+ "engine->evaluate(\"[]\")",
+ "engine->evaluate(\"{}\")",
+ "engine->evaluate(\"Object.prototype\")",
+ "engine->evaluate(\"Date.prototype\")",
+ "engine->evaluate(\"Array.prototype\")",
+ "engine->evaluate(\"Function.prototype\")",
+ "engine->evaluate(\"Error.prototype\")",
+ "engine->evaluate(\"Object\")",
+ "engine->evaluate(\"Array\")",
+ "engine->evaluate(\"Number\")",
+ "engine->evaluate(\"Function\")",
+ "engine->evaluate(\"(function() { return 1; })\")",
+ "engine->evaluate(\"(function() { return 'ciao'; })\")",
+ "engine->evaluate(\"(function() { throw new Error('foo' })\")",
+ "engine->evaluate(\"/foo/\")",
+ "engine->evaluate(\"new Object()\")",
+ "engine->evaluate(\"new Array()\")",
+ "engine->evaluate(\"new Error()\")",
+ "engine->evaluate(\"a = new Object( a.foo = 22; a.foo\")",
+ "engine->evaluate(\"Undefined\")",
+ "engine->evaluate(\"Null\")",
+ "engine->evaluate(\"True\")",
+ "engine->evaluate(\"False\")",
+ "engine->evaluate(\"undefined\")",
+ "engine->evaluate(\"null\")",
+ "engine->evaluate(\"true\")",
+ "engine->evaluate(\"false\")",
+ "engine->evaluate(\"122\")",
+ "engine->evaluate(\"124\")",
+ "engine->evaluate(\"0\")",
+ "engine->evaluate(\"0.0\")",
+ "engine->evaluate(\"123.0\")",
+ "engine->evaluate(\"6.37e-8\")",
+ "engine->evaluate(\"-6.37e-8\")",
+ "engine->evaluate(\"0x43211234\")",
+ "engine->evaluate(\"0x10000\")",
+ "engine->evaluate(\"0x10001\")",
+ "engine->evaluate(\"NaN\")",
+ "engine->evaluate(\"Infinity\")",
+ "engine->evaluate(\"-Infinity\")",
+ "engine->evaluate(\"'ciao'\")",
+ "engine->evaluate(\"''\")",
+ "engine->evaluate(\"'0'\")",
+ "engine->evaluate(\"'123'\")",
+ "engine->evaluate(\"'12.4'\")",
+ "engine->nullValue()",
+ "engine->undefinedValue()"};
+static qsreal toNumber_valueArray[] = {
+ 0, qQNaN(), 0, 1, 0, 122, 124, 0, 0, 123,
+ 6.369999999999999e-08, -6.369999999999999e-08, 1126240820, 65536, 65537, qQNaN(), qQNaN(), qInf(), qInf(), qQNaN(),
+ qInf(), qInf(), qQNaN(), qQNaN(), 0, 0, 0, 123, 12.4, qQNaN(),
+ 0, 1, 0, 122, 124, 0, 0, 123, 6.369999999999999e-08, -6.369999999999999e-08,
+ 1126240820, 65536, 65537, qQNaN(), qQNaN(), qInf(), qInf(), qQNaN(), qInf(), qInf(),
+ qQNaN(), qQNaN(), 0, 0, 0, 123, 12.3, qQNaN(), 0, 1,
+ 0, 122, 124, 0, 0, 123, 6.369999999999999e-08, -6.369999999999999e-08, 1126240820, 65536,
+ 65537, qQNaN(), qQNaN(), qInf(), qInf(), qQNaN(), qInf(), qInf(), qQNaN(), qQNaN(),
+ 0, 0, 0, 123, 1.23, 0, qQNaN(), qQNaN(), qQNaN(), 0,
+ qQNaN(), qQNaN(), qQNaN(), qQNaN(), qQNaN(), qQNaN(), qQNaN(), qQNaN(), qQNaN(), qQNaN(),
+ qQNaN(), 0, qQNaN(), qQNaN(), qQNaN(), qQNaN(), qQNaN(), qQNaN(), qQNaN(), 0,
+ 1, 0, 122, 124, 0, 0, 123, 6.369999999999999e-08, -6.369999999999999e-08, 1126240820,
+ 65536, 65537, qQNaN(), qInf(), qInf(), qQNaN(), 0, 0, 123, 12.4,
+ 0, qQNaN()};
+void tst_QScriptValue::toNumber_makeData(const char* expr)
+{
+ static QHash<QString, qsreal> toNumber;
+ if (toNumber.isEmpty()) {
+ toNumber.reserve(132);
+ for (unsigned i = 0; i < 132; ++i)
+ toNumber.insert(toNumber_tagArray[i], toNumber_valueArray[i]);
+ }
+ newRow(expr) << toNumber.value(expr);
+}
+
+void tst_QScriptValue::toNumber_test(const char*, const QScriptValue& value)
+{
+ QFETCH(qsreal, expected);
+ if (qIsNaN(expected)) {
+ QVERIFY(qIsNaN(value.toNumber()));
+ return;
+ }
+ if (qIsInf(expected)) {
+ QVERIFY(qIsInf(value.toNumber()));
+ QVERIFY(qIsInf(value.toNumber()));
+ return;
+ }
+ QCOMPARE(value.toNumber(), expected);
+ QCOMPARE(value.toNumber(), expected);
+}
+
+DEFINE_TEST_FUNCTION(toNumber)
+
+
+void tst_QScriptValue::toBool_initData()
+{
+ QTest::addColumn<bool>("expected");
+ initScriptValues();
+}
+
+static QString toBool_tagArray[] = {
+ "QScriptValue()",
+ "QScriptValue(QScriptValue::UndefinedValue)",
+ "QScriptValue(QScriptValue::NullValue)",
+ "QScriptValue(true)",
+ "QScriptValue(false)",
+ "QScriptValue(int(122))",
+ "QScriptValue(uint(124))",
+ "QScriptValue(0)",
+ "QScriptValue(0.0)",
+ "QScriptValue(123.0)",
+ "QScriptValue(6.37e-8)",
+ "QScriptValue(-6.37e-8)",
+ "QScriptValue(0x43211234)",
+ "QScriptValue(0x10000)",
+ "QScriptValue(0x10001)",
+ "QScriptValue(qSNaN())",
+ "QScriptValue(qQNaN())",
+ "QScriptValue(qInf())",
+ "QScriptValue(-qInf())",
+ "QScriptValue(\"NaN\")",
+ "QScriptValue(\"Infinity\")",
+ "QScriptValue(\"-Infinity\")",
+ "QScriptValue(\"ciao\")",
+ "QScriptValue(QString::fromLatin1(\"ciao\"))",
+ "QScriptValue(QString(\"\"))",
+ "QScriptValue(QString())",
+ "QScriptValue(QString(\"0\"))",
+ "QScriptValue(QString(\"123\"))",
+ "QScriptValue(QString(\"12.4\"))",
+ "QScriptValue(0, QScriptValue::UndefinedValue)",
+ "QScriptValue(0, QScriptValue::NullValue)",
+ "QScriptValue(0, true)",
+ "QScriptValue(0, false)",
+ "QScriptValue(0, int(122))",
+ "QScriptValue(0, uint(124))",
+ "QScriptValue(0, 0)",
+ "QScriptValue(0, 0.0)",
+ "QScriptValue(0, 123.0)",
+ "QScriptValue(0, 6.37e-8)",
+ "QScriptValue(0, -6.37e-8)",
+ "QScriptValue(0, 0x43211234)",
+ "QScriptValue(0, 0x10000)",
+ "QScriptValue(0, 0x10001)",
+ "QScriptValue(0, qSNaN())",
+ "QScriptValue(0, qQNaN())",
+ "QScriptValue(0, qInf())",
+ "QScriptValue(0, -qInf())",
+ "QScriptValue(0, \"NaN\")",
+ "QScriptValue(0, \"Infinity\")",
+ "QScriptValue(0, \"-Infinity\")",
+ "QScriptValue(0, \"ciao\")",
+ "QScriptValue(0, QString::fromLatin1(\"ciao\"))",
+ "QScriptValue(0, QString(\"\"))",
+ "QScriptValue(0, QString())",
+ "QScriptValue(0, QString(\"0\"))",
+ "QScriptValue(0, QString(\"123\"))",
+ "QScriptValue(0, QString(\"12.3\"))",
+ "QScriptValue(engine, QScriptValue::UndefinedValue)",
+ "QScriptValue(engine, QScriptValue::NullValue)",
+ "QScriptValue(engine, true)",
+ "QScriptValue(engine, false)",
+ "QScriptValue(engine, int(122))",
+ "QScriptValue(engine, uint(124))",
+ "QScriptValue(engine, 0)",
+ "QScriptValue(engine, 0.0)",
+ "QScriptValue(engine, 123.0)",
+ "QScriptValue(engine, 6.37e-8)",
+ "QScriptValue(engine, -6.37e-8)",
+ "QScriptValue(engine, 0x43211234)",
+ "QScriptValue(engine, 0x10000)",
+ "QScriptValue(engine, 0x10001)",
+ "QScriptValue(engine, qSNaN())",
+ "QScriptValue(engine, qQNaN())",
+ "QScriptValue(engine, qInf())",
+ "QScriptValue(engine, -qInf())",
+ "QScriptValue(engine, \"NaN\")",
+ "QScriptValue(engine, \"Infinity\")",
+ "QScriptValue(engine, \"-Infinity\")",
+ "QScriptValue(engine, \"ciao\")",
+ "QScriptValue(engine, QString::fromLatin1(\"ciao\"))",
+ "QScriptValue(engine, QString(\"\"))",
+ "QScriptValue(engine, QString())",
+ "QScriptValue(engine, QString(\"0\"))",
+ "QScriptValue(engine, QString(\"123\"))",
+ "QScriptValue(engine, QString(\"1.23\"))",
+ "engine->evaluate(\"[]\")",
+ "engine->evaluate(\"{}\")",
+ "engine->evaluate(\"Object.prototype\")",
+ "engine->evaluate(\"Date.prototype\")",
+ "engine->evaluate(\"Array.prototype\")",
+ "engine->evaluate(\"Function.prototype\")",
+ "engine->evaluate(\"Error.prototype\")",
+ "engine->evaluate(\"Object\")",
+ "engine->evaluate(\"Array\")",
+ "engine->evaluate(\"Number\")",
+ "engine->evaluate(\"Function\")",
+ "engine->evaluate(\"(function() { return 1; })\")",
+ "engine->evaluate(\"(function() { return 'ciao'; })\")",
+ "engine->evaluate(\"(function() { throw new Error('foo' })\")",
+ "engine->evaluate(\"/foo/\")",
+ "engine->evaluate(\"new Object()\")",
+ "engine->evaluate(\"new Array()\")",
+ "engine->evaluate(\"new Error()\")",
+ "engine->evaluate(\"a = new Object( a.foo = 22; a.foo\")",
+ "engine->evaluate(\"Undefined\")",
+ "engine->evaluate(\"Null\")",
+ "engine->evaluate(\"True\")",
+ "engine->evaluate(\"False\")",
+ "engine->evaluate(\"undefined\")",
+ "engine->evaluate(\"null\")",
+ "engine->evaluate(\"true\")",
+ "engine->evaluate(\"false\")",
+ "engine->evaluate(\"122\")",
+ "engine->evaluate(\"124\")",
+ "engine->evaluate(\"0\")",
+ "engine->evaluate(\"0.0\")",
+ "engine->evaluate(\"123.0\")",
+ "engine->evaluate(\"6.37e-8\")",
+ "engine->evaluate(\"-6.37e-8\")",
+ "engine->evaluate(\"0x43211234\")",
+ "engine->evaluate(\"0x10000\")",
+ "engine->evaluate(\"0x10001\")",
+ "engine->evaluate(\"NaN\")",
+ "engine->evaluate(\"Infinity\")",
+ "engine->evaluate(\"-Infinity\")",
+ "engine->evaluate(\"'ciao'\")",
+ "engine->evaluate(\"''\")",
+ "engine->evaluate(\"'0'\")",
+ "engine->evaluate(\"'123'\")",
+ "engine->evaluate(\"'12.4'\")",
+ "engine->nullValue()",
+ "engine->undefinedValue()"};
+
+static bool toBool_valueArray[] = {
+ false, false,
+ false, true,
+ false, true,
+ true, false,
+ false, true,
+ true, true,
+ true, true,
+ true, false,
+ false, true,
+ true, true,
+ true, true,
+ true, true,
+ false, false,
+ true, true,
+ true, false,
+ false, true,
+ false, true,
+ true, false,
+ false, true,
+ true, true,
+ true, true,
+ true, false,
+ false, true,
+ true, true,
+ true, true,
+ true, true,
+ false, false,
+ true, true,
+ true, false,
+ false, true,
+ false, true,
+ true, false,
+ false, true,
+ true, true,
+ true, true,
+ true, false,
+ false, true,
+ true, true,
+ true, true,
+ true, true,
+ false, false,
+ true, true,
+ true, true,
+ false, true,
+ true, true,
+ true, true,
+ true, true,
+ true, true,
+ true, true,
+ true, true,
+ true, true,
+ true, true,
+ true, true,
+ true, true,
+ false, false,
+ true, false,
+ true, true,
+ false, false,
+ true, true,
+ true, true,
+ true, true,
+ false, true,
+ true, true,
+ false, true,
+ true, true,
+ false, false};
+
+void tst_QScriptValue::toBool_makeData(const char* expr)
+{
+ static QHash<QString, bool> toBool;
+ if (toBool.isEmpty()) {
+ toBool.reserve(132);
+ for (unsigned i = 0; i < 132; ++i)
+ toBool.insert(toBool_tagArray[i], toBool_valueArray[i]);
+ }
+ newRow(expr) << toBool.value(expr);
+}
+
+void tst_QScriptValue::toBool_test(const char*, const QScriptValue& value)
+{
+ QFETCH(bool, expected);
+ QCOMPARE(value.toBool(), expected);
+ QCOMPARE(value.toBool(), expected);
+}
+
+DEFINE_TEST_FUNCTION(toBool)
+
+
+void tst_QScriptValue::toBoolean_initData()
+{
+ QTest::addColumn<bool>("expected");
+ initScriptValues();
+}
+
+static QString toBoolean_tagArray[] = {
+ "QScriptValue()",
+ "QScriptValue(QScriptValue::UndefinedValue)",
+ "QScriptValue(QScriptValue::NullValue)",
+ "QScriptValue(true)",
+ "QScriptValue(false)",
+ "QScriptValue(int(122))",
+ "QScriptValue(uint(124))",
+ "QScriptValue(0)",
+ "QScriptValue(0.0)",
+ "QScriptValue(123.0)",
+ "QScriptValue(6.37e-8)",
+ "QScriptValue(-6.37e-8)",
+ "QScriptValue(0x43211234)",
+ "QScriptValue(0x10000)",
+ "QScriptValue(0x10001)",
+ "QScriptValue(qSNaN())",
+ "QScriptValue(qQNaN())",
+ "QScriptValue(qInf())",
+ "QScriptValue(-qInf())",
+ "QScriptValue(\"NaN\")",
+ "QScriptValue(\"Infinity\")",
+ "QScriptValue(\"-Infinity\")",
+ "QScriptValue(\"ciao\")",
+ "QScriptValue(QString::fromLatin1(\"ciao\"))",
+ "QScriptValue(QString(\"\"))",
+ "QScriptValue(QString())",
+ "QScriptValue(QString(\"0\"))",
+ "QScriptValue(QString(\"123\"))",
+ "QScriptValue(QString(\"12.4\"))",
+ "QScriptValue(0, QScriptValue::UndefinedValue)",
+ "QScriptValue(0, QScriptValue::NullValue)",
+ "QScriptValue(0, true)",
+ "QScriptValue(0, false)",
+ "QScriptValue(0, int(122))",
+ "QScriptValue(0, uint(124))",
+ "QScriptValue(0, 0)",
+ "QScriptValue(0, 0.0)",
+ "QScriptValue(0, 123.0)",
+ "QScriptValue(0, 6.37e-8)",
+ "QScriptValue(0, -6.37e-8)",
+ "QScriptValue(0, 0x43211234)",
+ "QScriptValue(0, 0x10000)",
+ "QScriptValue(0, 0x10001)",
+ "QScriptValue(0, qSNaN())",
+ "QScriptValue(0, qQNaN())",
+ "QScriptValue(0, qInf())",
+ "QScriptValue(0, -qInf())",
+ "QScriptValue(0, \"NaN\")",
+ "QScriptValue(0, \"Infinity\")",
+ "QScriptValue(0, \"-Infinity\")",
+ "QScriptValue(0, \"ciao\")",
+ "QScriptValue(0, QString::fromLatin1(\"ciao\"))",
+ "QScriptValue(0, QString(\"\"))",
+ "QScriptValue(0, QString())",
+ "QScriptValue(0, QString(\"0\"))",
+ "QScriptValue(0, QString(\"123\"))",
+ "QScriptValue(0, QString(\"12.3\"))",
+ "QScriptValue(engine, QScriptValue::UndefinedValue)",
+ "QScriptValue(engine, QScriptValue::NullValue)",
+ "QScriptValue(engine, true)",
+ "QScriptValue(engine, false)",
+ "QScriptValue(engine, int(122))",
+ "QScriptValue(engine, uint(124))",
+ "QScriptValue(engine, 0)",
+ "QScriptValue(engine, 0.0)",
+ "QScriptValue(engine, 123.0)",
+ "QScriptValue(engine, 6.37e-8)",
+ "QScriptValue(engine, -6.37e-8)",
+ "QScriptValue(engine, 0x43211234)",
+ "QScriptValue(engine, 0x10000)",
+ "QScriptValue(engine, 0x10001)",
+ "QScriptValue(engine, qSNaN())",
+ "QScriptValue(engine, qQNaN())",
+ "QScriptValue(engine, qInf())",
+ "QScriptValue(engine, -qInf())",
+ "QScriptValue(engine, \"NaN\")",
+ "QScriptValue(engine, \"Infinity\")",
+ "QScriptValue(engine, \"-Infinity\")",
+ "QScriptValue(engine, \"ciao\")",
+ "QScriptValue(engine, QString::fromLatin1(\"ciao\"))",
+ "QScriptValue(engine, QString(\"\"))",
+ "QScriptValue(engine, QString())",
+ "QScriptValue(engine, QString(\"0\"))",
+ "QScriptValue(engine, QString(\"123\"))",
+ "QScriptValue(engine, QString(\"1.23\"))",
+ "engine->evaluate(\"[]\")",
+ "engine->evaluate(\"{}\")",
+ "engine->evaluate(\"Object.prototype\")",
+ "engine->evaluate(\"Date.prototype\")",
+ "engine->evaluate(\"Array.prototype\")",
+ "engine->evaluate(\"Function.prototype\")",
+ "engine->evaluate(\"Error.prototype\")",
+ "engine->evaluate(\"Object\")",
+ "engine->evaluate(\"Array\")",
+ "engine->evaluate(\"Number\")",
+ "engine->evaluate(\"Function\")",
+ "engine->evaluate(\"(function() { return 1; })\")",
+ "engine->evaluate(\"(function() { return 'ciao'; })\")",
+ "engine->evaluate(\"(function() { throw new Error('foo' })\")",
+ "engine->evaluate(\"/foo/\")",
+ "engine->evaluate(\"new Object()\")",
+ "engine->evaluate(\"new Array()\")",
+ "engine->evaluate(\"new Error()\")",
+ "engine->evaluate(\"a = new Object( a.foo = 22; a.foo\")",
+ "engine->evaluate(\"Undefined\")",
+ "engine->evaluate(\"Null\")",
+ "engine->evaluate(\"True\")",
+ "engine->evaluate(\"False\")",
+ "engine->evaluate(\"undefined\")",
+ "engine->evaluate(\"null\")",
+ "engine->evaluate(\"true\")",
+ "engine->evaluate(\"false\")",
+ "engine->evaluate(\"122\")",
+ "engine->evaluate(\"124\")",
+ "engine->evaluate(\"0\")",
+ "engine->evaluate(\"0.0\")",
+ "engine->evaluate(\"123.0\")",
+ "engine->evaluate(\"6.37e-8\")",
+ "engine->evaluate(\"-6.37e-8\")",
+ "engine->evaluate(\"0x43211234\")",
+ "engine->evaluate(\"0x10000\")",
+ "engine->evaluate(\"0x10001\")",
+ "engine->evaluate(\"NaN\")",
+ "engine->evaluate(\"Infinity\")",
+ "engine->evaluate(\"-Infinity\")",
+ "engine->evaluate(\"'ciao'\")",
+ "engine->evaluate(\"''\")",
+ "engine->evaluate(\"'0'\")",
+ "engine->evaluate(\"'123'\")",
+ "engine->evaluate(\"'12.4'\")",
+ "engine->nullValue()",
+ "engine->undefinedValue()"};
+
+static bool toBoolean_valueArray[] = {
+ false, false,
+ false, true,
+ false, true,
+ true, false,
+ false, true,
+ true, true,
+ true, true,
+ true, false,
+ false, true,
+ true, true,
+ true, true,
+ true, true,
+ false, false,
+ true, true,
+ true, false,
+ false, true,
+ false, true,
+ true, false,
+ false, true,
+ true, true,
+ true, true,
+ true, false,
+ false, true,
+ true, true,
+ true, true,
+ true, true,
+ false, false,
+ true, true,
+ true, false,
+ false, true,
+ false, true,
+ true, false,
+ false, true,
+ true, true,
+ true, true,
+ true, false,
+ false, true,
+ true, true,
+ true, true,
+ true, true,
+ false, false,
+ true, true,
+ true, true,
+ false, true,
+ true, true,
+ true, true,
+ true, true,
+ true, true,
+ true, true,
+ true, true,
+ true, true,
+ true, true,
+ true, true,
+ true, true,
+ false, false,
+ true, false,
+ true, true,
+ false, false,
+ true, true,
+ true, true,
+ true, true,
+ false, true,
+ true, true,
+ false, true,
+ true, true,
+ false, false};
+
+void tst_QScriptValue::toBoolean_makeData(const char* expr)
+{
+ static QHash<QString, bool> toBoolean;
+ if (toBoolean.isEmpty()) {
+ toBoolean.reserve(132);
+ for (unsigned i = 0; i < 132; ++i)
+ toBoolean.insert(toBoolean_tagArray[i], toBoolean_valueArray[i]);
+ }
+ newRow(expr) << toBoolean.value(expr);
+}
+
+void tst_QScriptValue::toBoolean_test(const char*, const QScriptValue& value)
+{
+ QFETCH(bool, expected);
+ QCOMPARE(value.toBoolean(), expected);
+ QCOMPARE(value.toBoolean(), expected);
+}
+
+DEFINE_TEST_FUNCTION(toBoolean)
+
+
+void tst_QScriptValue::toInteger_initData()
+{
+ QTest::addColumn<qsreal>("expected");
+ initScriptValues();
+}
+
+static QString toInteger_tagArray[] = {
+ "QScriptValue()",
+ "QScriptValue(QScriptValue::UndefinedValue)",
+ "QScriptValue(QScriptValue::NullValue)",
+ "QScriptValue(true)",
+ "QScriptValue(false)",
+ "QScriptValue(int(122))",
+ "QScriptValue(uint(124))",
+ "QScriptValue(0)",
+ "QScriptValue(0.0)",
+ "QScriptValue(123.0)",
+ "QScriptValue(6.37e-8)",
+ "QScriptValue(-6.37e-8)",
+ "QScriptValue(0x43211234)",
+ "QScriptValue(0x10000)",
+ "QScriptValue(0x10001)",
+ "QScriptValue(qSNaN())",
+ "QScriptValue(qQNaN())",
+ "QScriptValue(qInf())",
+ "QScriptValue(-qInf())",
+ "QScriptValue(\"NaN\")",
+ "QScriptValue(\"Infinity\")",
+ "QScriptValue(\"-Infinity\")",
+ "QScriptValue(\"ciao\")",
+ "QScriptValue(QString::fromLatin1(\"ciao\"))",
+ "QScriptValue(QString(\"\"))",
+ "QScriptValue(QString())",
+ "QScriptValue(QString(\"0\"))",
+ "QScriptValue(QString(\"123\"))",
+ "QScriptValue(QString(\"12.4\"))",
+ "QScriptValue(0, QScriptValue::UndefinedValue)",
+ "QScriptValue(0, QScriptValue::NullValue)",
+ "QScriptValue(0, true)",
+ "QScriptValue(0, false)",
+ "QScriptValue(0, int(122))",
+ "QScriptValue(0, uint(124))",
+ "QScriptValue(0, 0)",
+ "QScriptValue(0, 0.0)",
+ "QScriptValue(0, 123.0)",
+ "QScriptValue(0, 6.37e-8)",
+ "QScriptValue(0, -6.37e-8)",
+ "QScriptValue(0, 0x43211234)",
+ "QScriptValue(0, 0x10000)",
+ "QScriptValue(0, 0x10001)",
+ "QScriptValue(0, qSNaN())",
+ "QScriptValue(0, qQNaN())",
+ "QScriptValue(0, qInf())",
+ "QScriptValue(0, -qInf())",
+ "QScriptValue(0, \"NaN\")",
+ "QScriptValue(0, \"Infinity\")",
+ "QScriptValue(0, \"-Infinity\")",
+ "QScriptValue(0, \"ciao\")",
+ "QScriptValue(0, QString::fromLatin1(\"ciao\"))",
+ "QScriptValue(0, QString(\"\"))",
+ "QScriptValue(0, QString())",
+ "QScriptValue(0, QString(\"0\"))",
+ "QScriptValue(0, QString(\"123\"))",
+ "QScriptValue(0, QString(\"12.3\"))",
+ "QScriptValue(engine, QScriptValue::UndefinedValue)",
+ "QScriptValue(engine, QScriptValue::NullValue)",
+ "QScriptValue(engine, true)",
+ "QScriptValue(engine, false)",
+ "QScriptValue(engine, int(122))",
+ "QScriptValue(engine, uint(124))",
+ "QScriptValue(engine, 0)",
+ "QScriptValue(engine, 0.0)",
+ "QScriptValue(engine, 123.0)",
+ "QScriptValue(engine, 6.37e-8)",
+ "QScriptValue(engine, -6.37e-8)",
+ "QScriptValue(engine, 0x43211234)",
+ "QScriptValue(engine, 0x10000)",
+ "QScriptValue(engine, 0x10001)",
+ "QScriptValue(engine, qSNaN())",
+ "QScriptValue(engine, qQNaN())",
+ "QScriptValue(engine, qInf())",
+ "QScriptValue(engine, -qInf())",
+ "QScriptValue(engine, \"NaN\")",
+ "QScriptValue(engine, \"Infinity\")",
+ "QScriptValue(engine, \"-Infinity\")",
+ "QScriptValue(engine, \"ciao\")",
+ "QScriptValue(engine, QString::fromLatin1(\"ciao\"))",
+ "QScriptValue(engine, QString(\"\"))",
+ "QScriptValue(engine, QString())",
+ "QScriptValue(engine, QString(\"0\"))",
+ "QScriptValue(engine, QString(\"123\"))",
+ "QScriptValue(engine, QString(\"1.23\"))",
+ "engine->evaluate(\"[]\")",
+ "engine->evaluate(\"{}\")",
+ "engine->evaluate(\"Object.prototype\")",
+ "engine->evaluate(\"Date.prototype\")",
+ "engine->evaluate(\"Array.prototype\")",
+ "engine->evaluate(\"Function.prototype\")",
+ "engine->evaluate(\"Error.prototype\")",
+ "engine->evaluate(\"Object\")",
+ "engine->evaluate(\"Array\")",
+ "engine->evaluate(\"Number\")",
+ "engine->evaluate(\"Function\")",
+ "engine->evaluate(\"(function() { return 1; })\")",
+ "engine->evaluate(\"(function() { return 'ciao'; })\")",
+ "engine->evaluate(\"(function() { throw new Error('foo' })\")",
+ "engine->evaluate(\"/foo/\")",
+ "engine->evaluate(\"new Object()\")",
+ "engine->evaluate(\"new Array()\")",
+ "engine->evaluate(\"new Error()\")",
+ "engine->evaluate(\"a = new Object( a.foo = 22; a.foo\")",
+ "engine->evaluate(\"Undefined\")",
+ "engine->evaluate(\"Null\")",
+ "engine->evaluate(\"True\")",
+ "engine->evaluate(\"False\")",
+ "engine->evaluate(\"undefined\")",
+ "engine->evaluate(\"null\")",
+ "engine->evaluate(\"true\")",
+ "engine->evaluate(\"false\")",
+ "engine->evaluate(\"122\")",
+ "engine->evaluate(\"124\")",
+ "engine->evaluate(\"0\")",
+ "engine->evaluate(\"0.0\")",
+ "engine->evaluate(\"123.0\")",
+ "engine->evaluate(\"6.37e-8\")",
+ "engine->evaluate(\"-6.37e-8\")",
+ "engine->evaluate(\"0x43211234\")",
+ "engine->evaluate(\"0x10000\")",
+ "engine->evaluate(\"0x10001\")",
+ "engine->evaluate(\"NaN\")",
+ "engine->evaluate(\"Infinity\")",
+ "engine->evaluate(\"-Infinity\")",
+ "engine->evaluate(\"'ciao'\")",
+ "engine->evaluate(\"''\")",
+ "engine->evaluate(\"'0'\")",
+ "engine->evaluate(\"'123'\")",
+ "engine->evaluate(\"'12.4'\")",
+ "engine->nullValue()",
+ "engine->undefinedValue()"};
+static qsreal toInteger_valueArray[] = {
+ 0, 0, 0, 1, 0, 122, 124, 0, 0, 123,
+ 0, 0, 1126240820, 65536, 65537, 0, 0, qInf(), qInf(), 0,
+ qInf(), qInf(), 0, 0, 0, 0, 0, 123, 12, 0,
+ 0, 1, 0, 122, 124, 0, 0, 123, 0, 0,
+ 1126240820, 65536, 65537, 0, 0, qInf(), qInf(), 0, qInf(), qInf(),
+ 0, 0, 0, 0, 0, 123, 12, 0, 0, 1,
+ 0, 122, 124, 0, 0, 123, 0, 0, 1126240820, 65536,
+ 65537, 0, 0, qInf(), qInf(), 0, qInf(), qInf(), 0, 0,
+ 0, 0, 0, 123, 1, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 1, 0, 122, 124, 0, 0, 123, 0, 0, 1126240820,
+ 65536, 65537, 0, qInf(), qInf(), 0, 0, 0, 123, 12,
+ 0, 0};
+void tst_QScriptValue::toInteger_makeData(const char* expr)
+{
+ static QHash<QString, qsreal> toInteger;
+ if (toInteger.isEmpty()) {
+ toInteger.reserve(132);
+ for (unsigned i = 0; i < 132; ++i)
+ toInteger.insert(toInteger_tagArray[i], toInteger_valueArray[i]);
+ }
+ newRow(expr) << toInteger.value(expr);
+}
+
+void tst_QScriptValue::toInteger_test(const char*, const QScriptValue& value)
+{
+ QFETCH(qsreal, expected);
+ if (qIsInf(expected)) {
+ QVERIFY(qIsInf(value.toInteger()));
+ QVERIFY(qIsInf(value.toInteger()));
+ return;
+ }
+ QCOMPARE(value.toInteger(), expected);
+ QCOMPARE(value.toInteger(), expected);
+}
+
+DEFINE_TEST_FUNCTION(toInteger)
+
+
+void tst_QScriptValue::toInt32_initData()
+{
+ QTest::addColumn<qint32>("expected");
+ initScriptValues();
+}
+
+static QString toInt32_tagArray[] = {
+ "QScriptValue()",
+ "QScriptValue(QScriptValue::UndefinedValue)",
+ "QScriptValue(QScriptValue::NullValue)",
+ "QScriptValue(true)",
+ "QScriptValue(false)",
+ "QScriptValue(int(122))",
+ "QScriptValue(uint(124))",
+ "QScriptValue(0)",
+ "QScriptValue(0.0)",
+ "QScriptValue(123.0)",
+ "QScriptValue(6.37e-8)",
+ "QScriptValue(-6.37e-8)",
+ "QScriptValue(0x43211234)",
+ "QScriptValue(0x10000)",
+ "QScriptValue(0x10001)",
+ "QScriptValue(qSNaN())",
+ "QScriptValue(qQNaN())",
+ "QScriptValue(qInf())",
+ "QScriptValue(-qInf())",
+ "QScriptValue(\"NaN\")",
+ "QScriptValue(\"Infinity\")",
+ "QScriptValue(\"-Infinity\")",
+ "QScriptValue(\"ciao\")",
+ "QScriptValue(QString::fromLatin1(\"ciao\"))",
+ "QScriptValue(QString(\"\"))",
+ "QScriptValue(QString())",
+ "QScriptValue(QString(\"0\"))",
+ "QScriptValue(QString(\"123\"))",
+ "QScriptValue(QString(\"12.4\"))",
+ "QScriptValue(0, QScriptValue::UndefinedValue)",
+ "QScriptValue(0, QScriptValue::NullValue)",
+ "QScriptValue(0, true)",
+ "QScriptValue(0, false)",
+ "QScriptValue(0, int(122))",
+ "QScriptValue(0, uint(124))",
+ "QScriptValue(0, 0)",
+ "QScriptValue(0, 0.0)",
+ "QScriptValue(0, 123.0)",
+ "QScriptValue(0, 6.37e-8)",
+ "QScriptValue(0, -6.37e-8)",
+ "QScriptValue(0, 0x43211234)",
+ "QScriptValue(0, 0x10000)",
+ "QScriptValue(0, 0x10001)",
+ "QScriptValue(0, qSNaN())",
+ "QScriptValue(0, qQNaN())",
+ "QScriptValue(0, qInf())",
+ "QScriptValue(0, -qInf())",
+ "QScriptValue(0, \"NaN\")",
+ "QScriptValue(0, \"Infinity\")",
+ "QScriptValue(0, \"-Infinity\")",
+ "QScriptValue(0, \"ciao\")",
+ "QScriptValue(0, QString::fromLatin1(\"ciao\"))",
+ "QScriptValue(0, QString(\"\"))",
+ "QScriptValue(0, QString())",
+ "QScriptValue(0, QString(\"0\"))",
+ "QScriptValue(0, QString(\"123\"))",
+ "QScriptValue(0, QString(\"12.3\"))",
+ "QScriptValue(engine, QScriptValue::UndefinedValue)",
+ "QScriptValue(engine, QScriptValue::NullValue)",
+ "QScriptValue(engine, true)",
+ "QScriptValue(engine, false)",
+ "QScriptValue(engine, int(122))",
+ "QScriptValue(engine, uint(124))",
+ "QScriptValue(engine, 0)",
+ "QScriptValue(engine, 0.0)",
+ "QScriptValue(engine, 123.0)",
+ "QScriptValue(engine, 6.37e-8)",
+ "QScriptValue(engine, -6.37e-8)",
+ "QScriptValue(engine, 0x43211234)",
+ "QScriptValue(engine, 0x10000)",
+ "QScriptValue(engine, 0x10001)",
+ "QScriptValue(engine, qSNaN())",
+ "QScriptValue(engine, qQNaN())",
+ "QScriptValue(engine, qInf())",
+ "QScriptValue(engine, -qInf())",
+ "QScriptValue(engine, \"NaN\")",
+ "QScriptValue(engine, \"Infinity\")",
+ "QScriptValue(engine, \"-Infinity\")",
+ "QScriptValue(engine, \"ciao\")",
+ "QScriptValue(engine, QString::fromLatin1(\"ciao\"))",
+ "QScriptValue(engine, QString(\"\"))",
+ "QScriptValue(engine, QString())",
+ "QScriptValue(engine, QString(\"0\"))",
+ "QScriptValue(engine, QString(\"123\"))",
+ "QScriptValue(engine, QString(\"1.23\"))",
+ "engine->evaluate(\"[]\")",
+ "engine->evaluate(\"{}\")",
+ "engine->evaluate(\"Object.prototype\")",
+ "engine->evaluate(\"Date.prototype\")",
+ "engine->evaluate(\"Array.prototype\")",
+ "engine->evaluate(\"Function.prototype\")",
+ "engine->evaluate(\"Error.prototype\")",
+ "engine->evaluate(\"Object\")",
+ "engine->evaluate(\"Array\")",
+ "engine->evaluate(\"Number\")",
+ "engine->evaluate(\"Function\")",
+ "engine->evaluate(\"(function() { return 1; })\")",
+ "engine->evaluate(\"(function() { return 'ciao'; })\")",
+ "engine->evaluate(\"(function() { throw new Error('foo' })\")",
+ "engine->evaluate(\"/foo/\")",
+ "engine->evaluate(\"new Object()\")",
+ "engine->evaluate(\"new Array()\")",
+ "engine->evaluate(\"new Error()\")",
+ "engine->evaluate(\"a = new Object( a.foo = 22; a.foo\")",
+ "engine->evaluate(\"Undefined\")",
+ "engine->evaluate(\"Null\")",
+ "engine->evaluate(\"True\")",
+ "engine->evaluate(\"False\")",
+ "engine->evaluate(\"undefined\")",
+ "engine->evaluate(\"null\")",
+ "engine->evaluate(\"true\")",
+ "engine->evaluate(\"false\")",
+ "engine->evaluate(\"122\")",
+ "engine->evaluate(\"124\")",
+ "engine->evaluate(\"0\")",
+ "engine->evaluate(\"0.0\")",
+ "engine->evaluate(\"123.0\")",
+ "engine->evaluate(\"6.37e-8\")",
+ "engine->evaluate(\"-6.37e-8\")",
+ "engine->evaluate(\"0x43211234\")",
+ "engine->evaluate(\"0x10000\")",
+ "engine->evaluate(\"0x10001\")",
+ "engine->evaluate(\"NaN\")",
+ "engine->evaluate(\"Infinity\")",
+ "engine->evaluate(\"-Infinity\")",
+ "engine->evaluate(\"'ciao'\")",
+ "engine->evaluate(\"''\")",
+ "engine->evaluate(\"'0'\")",
+ "engine->evaluate(\"'123'\")",
+ "engine->evaluate(\"'12.4'\")",
+ "engine->nullValue()",
+ "engine->undefinedValue()"};
+
+static qint32 toInt32_valueArray[] = {
+ 0, 0,
+ 0, 1,
+ 0, 122,
+ 124, 0,
+ 0, 123,
+ 0, 0,
+ 1126240820, 65536,
+ 65537, 0,
+ 0, 0,
+ 0, 0,
+ 0, 0,
+ 0, 0,
+ 0, 0,
+ 0, 123,
+ 12, 0,
+ 0, 1,
+ 0, 122,
+ 124, 0,
+ 0, 123,
+ 0, 0,
+ 1126240820, 65536,
+ 65537, 0,
+ 0, 0,
+ 0, 0,
+ 0, 0,
+ 0, 0,
+ 0, 0,
+ 0, 123,
+ 12, 0,
+ 0, 1,
+ 0, 122,
+ 124, 0,
+ 0, 123,
+ 0, 0,
+ 1126240820, 65536,
+ 65537, 0,
+ 0, 0,
+ 0, 0,
+ 0, 0,
+ 0, 0,
+ 0, 0,
+ 0, 123,
+ 1, 0,
+ 0, 0,
+ 0, 0,
+ 0, 0,
+ 0, 0,
+ 0, 0,
+ 0, 0,
+ 0, 0,
+ 0, 0,
+ 0, 0,
+ 0, 0,
+ 0, 0,
+ 0, 0,
+ 1, 0,
+ 122, 124,
+ 0, 0,
+ 123, 0,
+ 0, 1126240820,
+ 65536, 65537,
+ 0, 0,
+ 0, 0,
+ 0, 0,
+ 123, 12,
+ 0, 0};
+
+void tst_QScriptValue::toInt32_makeData(const char* expr)
+{
+ static QHash<QString, qint32> toInt32;
+ if (toInt32.isEmpty()) {
+ toInt32.reserve(132);
+ for (unsigned i = 0; i < 132; ++i)
+ toInt32.insert(toInt32_tagArray[i], toInt32_valueArray[i]);
+ }
+ newRow(expr) << toInt32.value(expr);
+}
+
+void tst_QScriptValue::toInt32_test(const char*, const QScriptValue& value)
+{
+ QFETCH(qint32, expected);
+ QCOMPARE(value.toInt32(), expected);
+ QCOMPARE(value.toInt32(), expected);
+}
+
+DEFINE_TEST_FUNCTION(toInt32)
+
+
+void tst_QScriptValue::toUInt32_initData()
+{
+ QTest::addColumn<quint32>("expected");
+ initScriptValues();
+}
+
+static QString toUInt32_tagArray[] = {
+ "QScriptValue()",
+ "QScriptValue(QScriptValue::UndefinedValue)",
+ "QScriptValue(QScriptValue::NullValue)",
+ "QScriptValue(true)",
+ "QScriptValue(false)",
+ "QScriptValue(int(122))",
+ "QScriptValue(uint(124))",
+ "QScriptValue(0)",
+ "QScriptValue(0.0)",
+ "QScriptValue(123.0)",
+ "QScriptValue(6.37e-8)",
+ "QScriptValue(-6.37e-8)",
+ "QScriptValue(0x43211234)",
+ "QScriptValue(0x10000)",
+ "QScriptValue(0x10001)",
+ "QScriptValue(qSNaN())",
+ "QScriptValue(qQNaN())",
+ "QScriptValue(qInf())",
+ "QScriptValue(-qInf())",
+ "QScriptValue(\"NaN\")",
+ "QScriptValue(\"Infinity\")",
+ "QScriptValue(\"-Infinity\")",
+ "QScriptValue(\"ciao\")",
+ "QScriptValue(QString::fromLatin1(\"ciao\"))",
+ "QScriptValue(QString(\"\"))",
+ "QScriptValue(QString())",
+ "QScriptValue(QString(\"0\"))",
+ "QScriptValue(QString(\"123\"))",
+ "QScriptValue(QString(\"12.4\"))",
+ "QScriptValue(0, QScriptValue::UndefinedValue)",
+ "QScriptValue(0, QScriptValue::NullValue)",
+ "QScriptValue(0, true)",
+ "QScriptValue(0, false)",
+ "QScriptValue(0, int(122))",
+ "QScriptValue(0, uint(124))",
+ "QScriptValue(0, 0)",
+ "QScriptValue(0, 0.0)",
+ "QScriptValue(0, 123.0)",
+ "QScriptValue(0, 6.37e-8)",
+ "QScriptValue(0, -6.37e-8)",
+ "QScriptValue(0, 0x43211234)",
+ "QScriptValue(0, 0x10000)",
+ "QScriptValue(0, 0x10001)",
+ "QScriptValue(0, qSNaN())",
+ "QScriptValue(0, qQNaN())",
+ "QScriptValue(0, qInf())",
+ "QScriptValue(0, -qInf())",
+ "QScriptValue(0, \"NaN\")",
+ "QScriptValue(0, \"Infinity\")",
+ "QScriptValue(0, \"-Infinity\")",
+ "QScriptValue(0, \"ciao\")",
+ "QScriptValue(0, QString::fromLatin1(\"ciao\"))",
+ "QScriptValue(0, QString(\"\"))",
+ "QScriptValue(0, QString())",
+ "QScriptValue(0, QString(\"0\"))",
+ "QScriptValue(0, QString(\"123\"))",
+ "QScriptValue(0, QString(\"12.3\"))",
+ "QScriptValue(engine, QScriptValue::UndefinedValue)",
+ "QScriptValue(engine, QScriptValue::NullValue)",
+ "QScriptValue(engine, true)",
+ "QScriptValue(engine, false)",
+ "QScriptValue(engine, int(122))",
+ "QScriptValue(engine, uint(124))",
+ "QScriptValue(engine, 0)",
+ "QScriptValue(engine, 0.0)",
+ "QScriptValue(engine, 123.0)",
+ "QScriptValue(engine, 6.37e-8)",
+ "QScriptValue(engine, -6.37e-8)",
+ "QScriptValue(engine, 0x43211234)",
+ "QScriptValue(engine, 0x10000)",
+ "QScriptValue(engine, 0x10001)",
+ "QScriptValue(engine, qSNaN())",
+ "QScriptValue(engine, qQNaN())",
+ "QScriptValue(engine, qInf())",
+ "QScriptValue(engine, -qInf())",
+ "QScriptValue(engine, \"NaN\")",
+ "QScriptValue(engine, \"Infinity\")",
+ "QScriptValue(engine, \"-Infinity\")",
+ "QScriptValue(engine, \"ciao\")",
+ "QScriptValue(engine, QString::fromLatin1(\"ciao\"))",
+ "QScriptValue(engine, QString(\"\"))",
+ "QScriptValue(engine, QString())",
+ "QScriptValue(engine, QString(\"0\"))",
+ "QScriptValue(engine, QString(\"123\"))",
+ "QScriptValue(engine, QString(\"1.23\"))",
+ "engine->evaluate(\"[]\")",
+ "engine->evaluate(\"{}\")",
+ "engine->evaluate(\"Object.prototype\")",
+ "engine->evaluate(\"Date.prototype\")",
+ "engine->evaluate(\"Array.prototype\")",
+ "engine->evaluate(\"Function.prototype\")",
+ "engine->evaluate(\"Error.prototype\")",
+ "engine->evaluate(\"Object\")",
+ "engine->evaluate(\"Array\")",
+ "engine->evaluate(\"Number\")",
+ "engine->evaluate(\"Function\")",
+ "engine->evaluate(\"(function() { return 1; })\")",
+ "engine->evaluate(\"(function() { return 'ciao'; })\")",
+ "engine->evaluate(\"(function() { throw new Error('foo' })\")",
+ "engine->evaluate(\"/foo/\")",
+ "engine->evaluate(\"new Object()\")",
+ "engine->evaluate(\"new Array()\")",
+ "engine->evaluate(\"new Error()\")",
+ "engine->evaluate(\"a = new Object( a.foo = 22; a.foo\")",
+ "engine->evaluate(\"Undefined\")",
+ "engine->evaluate(\"Null\")",
+ "engine->evaluate(\"True\")",
+ "engine->evaluate(\"False\")",
+ "engine->evaluate(\"undefined\")",
+ "engine->evaluate(\"null\")",
+ "engine->evaluate(\"true\")",
+ "engine->evaluate(\"false\")",
+ "engine->evaluate(\"122\")",
+ "engine->evaluate(\"124\")",
+ "engine->evaluate(\"0\")",
+ "engine->evaluate(\"0.0\")",
+ "engine->evaluate(\"123.0\")",
+ "engine->evaluate(\"6.37e-8\")",
+ "engine->evaluate(\"-6.37e-8\")",
+ "engine->evaluate(\"0x43211234\")",
+ "engine->evaluate(\"0x10000\")",
+ "engine->evaluate(\"0x10001\")",
+ "engine->evaluate(\"NaN\")",
+ "engine->evaluate(\"Infinity\")",
+ "engine->evaluate(\"-Infinity\")",
+ "engine->evaluate(\"'ciao'\")",
+ "engine->evaluate(\"''\")",
+ "engine->evaluate(\"'0'\")",
+ "engine->evaluate(\"'123'\")",
+ "engine->evaluate(\"'12.4'\")",
+ "engine->nullValue()",
+ "engine->undefinedValue()"};
+
+static quint32 toUInt32_valueArray[] = {
+ 0, 0,
+ 0, 1,
+ 0, 122,
+ 124, 0,
+ 0, 123,
+ 0, 0,
+ 1126240820, 65536,
+ 65537, 0,
+ 0, 0,
+ 0, 0,
+ 0, 0,
+ 0, 0,
+ 0, 0,
+ 0, 123,
+ 12, 0,
+ 0, 1,
+ 0, 122,
+ 124, 0,
+ 0, 123,
+ 0, 0,
+ 1126240820, 65536,
+ 65537, 0,
+ 0, 0,
+ 0, 0,
+ 0, 0,
+ 0, 0,
+ 0, 0,
+ 0, 123,
+ 12, 0,
+ 0, 1,
+ 0, 122,
+ 124, 0,
+ 0, 123,
+ 0, 0,
+ 1126240820, 65536,
+ 65537, 0,
+ 0, 0,
+ 0, 0,
+ 0, 0,
+ 0, 0,
+ 0, 0,
+ 0, 123,
+ 1, 0,
+ 0, 0,
+ 0, 0,
+ 0, 0,
+ 0, 0,
+ 0, 0,
+ 0, 0,
+ 0, 0,
+ 0, 0,
+ 0, 0,
+ 0, 0,
+ 0, 0,
+ 0, 0,
+ 1, 0,
+ 122, 124,
+ 0, 0,
+ 123, 0,
+ 0, 1126240820,
+ 65536, 65537,
+ 0, 0,
+ 0, 0,
+ 0, 0,
+ 123, 12,
+ 0, 0};
+
+void tst_QScriptValue::toUInt32_makeData(const char* expr)
+{
+ static QHash<QString, quint32> toUInt32;
+ if (toUInt32.isEmpty()) {
+ toUInt32.reserve(132);
+ for (unsigned i = 0; i < 132; ++i)
+ toUInt32.insert(toUInt32_tagArray[i], toUInt32_valueArray[i]);
+ }
+ newRow(expr) << toUInt32.value(expr);
+}
+
+void tst_QScriptValue::toUInt32_test(const char*, const QScriptValue& value)
+{
+ QFETCH(quint32, expected);
+ QCOMPARE(value.toUInt32(), expected);
+ QCOMPARE(value.toUInt32(), expected);
+}
+
+DEFINE_TEST_FUNCTION(toUInt32)
+
+
+void tst_QScriptValue::toUInt16_initData()
+{
+ QTest::addColumn<quint16>("expected");
+ initScriptValues();
+}
+
+static QString toUInt16_tagArray[] = {
+ "QScriptValue()",
+ "QScriptValue(QScriptValue::UndefinedValue)",
+ "QScriptValue(QScriptValue::NullValue)",
+ "QScriptValue(true)",
+ "QScriptValue(false)",
+ "QScriptValue(int(122))",
+ "QScriptValue(uint(124))",
+ "QScriptValue(0)",
+ "QScriptValue(0.0)",
+ "QScriptValue(123.0)",
+ "QScriptValue(6.37e-8)",
+ "QScriptValue(-6.37e-8)",
+ "QScriptValue(0x43211234)",
+ "QScriptValue(0x10000)",
+ "QScriptValue(0x10001)",
+ "QScriptValue(qSNaN())",
+ "QScriptValue(qQNaN())",
+ "QScriptValue(qInf())",
+ "QScriptValue(-qInf())",
+ "QScriptValue(\"NaN\")",
+ "QScriptValue(\"Infinity\")",
+ "QScriptValue(\"-Infinity\")",
+ "QScriptValue(\"ciao\")",
+ "QScriptValue(QString::fromLatin1(\"ciao\"))",
+ "QScriptValue(QString(\"\"))",
+ "QScriptValue(QString())",
+ "QScriptValue(QString(\"0\"))",
+ "QScriptValue(QString(\"123\"))",
+ "QScriptValue(QString(\"12.4\"))",
+ "QScriptValue(0, QScriptValue::UndefinedValue)",
+ "QScriptValue(0, QScriptValue::NullValue)",
+ "QScriptValue(0, true)",
+ "QScriptValue(0, false)",
+ "QScriptValue(0, int(122))",
+ "QScriptValue(0, uint(124))",
+ "QScriptValue(0, 0)",
+ "QScriptValue(0, 0.0)",
+ "QScriptValue(0, 123.0)",
+ "QScriptValue(0, 6.37e-8)",
+ "QScriptValue(0, -6.37e-8)",
+ "QScriptValue(0, 0x43211234)",
+ "QScriptValue(0, 0x10000)",
+ "QScriptValue(0, 0x10001)",
+ "QScriptValue(0, qSNaN())",
+ "QScriptValue(0, qQNaN())",
+ "QScriptValue(0, qInf())",
+ "QScriptValue(0, -qInf())",
+ "QScriptValue(0, \"NaN\")",
+ "QScriptValue(0, \"Infinity\")",
+ "QScriptValue(0, \"-Infinity\")",
+ "QScriptValue(0, \"ciao\")",
+ "QScriptValue(0, QString::fromLatin1(\"ciao\"))",
+ "QScriptValue(0, QString(\"\"))",
+ "QScriptValue(0, QString())",
+ "QScriptValue(0, QString(\"0\"))",
+ "QScriptValue(0, QString(\"123\"))",
+ "QScriptValue(0, QString(\"12.3\"))",
+ "QScriptValue(engine, QScriptValue::UndefinedValue)",
+ "QScriptValue(engine, QScriptValue::NullValue)",
+ "QScriptValue(engine, true)",
+ "QScriptValue(engine, false)",
+ "QScriptValue(engine, int(122))",
+ "QScriptValue(engine, uint(124))",
+ "QScriptValue(engine, 0)",
+ "QScriptValue(engine, 0.0)",
+ "QScriptValue(engine, 123.0)",
+ "QScriptValue(engine, 6.37e-8)",
+ "QScriptValue(engine, -6.37e-8)",
+ "QScriptValue(engine, 0x43211234)",
+ "QScriptValue(engine, 0x10000)",
+ "QScriptValue(engine, 0x10001)",
+ "QScriptValue(engine, qSNaN())",
+ "QScriptValue(engine, qQNaN())",
+ "QScriptValue(engine, qInf())",
+ "QScriptValue(engine, -qInf())",
+ "QScriptValue(engine, \"NaN\")",
+ "QScriptValue(engine, \"Infinity\")",
+ "QScriptValue(engine, \"-Infinity\")",
+ "QScriptValue(engine, \"ciao\")",
+ "QScriptValue(engine, QString::fromLatin1(\"ciao\"))",
+ "QScriptValue(engine, QString(\"\"))",
+ "QScriptValue(engine, QString())",
+ "QScriptValue(engine, QString(\"0\"))",
+ "QScriptValue(engine, QString(\"123\"))",
+ "QScriptValue(engine, QString(\"1.23\"))",
+ "engine->evaluate(\"[]\")",
+ "engine->evaluate(\"{}\")",
+ "engine->evaluate(\"Object.prototype\")",
+ "engine->evaluate(\"Date.prototype\")",
+ "engine->evaluate(\"Array.prototype\")",
+ "engine->evaluate(\"Function.prototype\")",
+ "engine->evaluate(\"Error.prototype\")",
+ "engine->evaluate(\"Object\")",
+ "engine->evaluate(\"Array\")",
+ "engine->evaluate(\"Number\")",
+ "engine->evaluate(\"Function\")",
+ "engine->evaluate(\"(function() { return 1; })\")",
+ "engine->evaluate(\"(function() { return 'ciao'; })\")",
+ "engine->evaluate(\"(function() { throw new Error('foo' })\")",
+ "engine->evaluate(\"/foo/\")",
+ "engine->evaluate(\"new Object()\")",
+ "engine->evaluate(\"new Array()\")",
+ "engine->evaluate(\"new Error()\")",
+ "engine->evaluate(\"a = new Object( a.foo = 22; a.foo\")",
+ "engine->evaluate(\"Undefined\")",
+ "engine->evaluate(\"Null\")",
+ "engine->evaluate(\"True\")",
+ "engine->evaluate(\"False\")",
+ "engine->evaluate(\"undefined\")",
+ "engine->evaluate(\"null\")",
+ "engine->evaluate(\"true\")",
+ "engine->evaluate(\"false\")",
+ "engine->evaluate(\"122\")",
+ "engine->evaluate(\"124\")",
+ "engine->evaluate(\"0\")",
+ "engine->evaluate(\"0.0\")",
+ "engine->evaluate(\"123.0\")",
+ "engine->evaluate(\"6.37e-8\")",
+ "engine->evaluate(\"-6.37e-8\")",
+ "engine->evaluate(\"0x43211234\")",
+ "engine->evaluate(\"0x10000\")",
+ "engine->evaluate(\"0x10001\")",
+ "engine->evaluate(\"NaN\")",
+ "engine->evaluate(\"Infinity\")",
+ "engine->evaluate(\"-Infinity\")",
+ "engine->evaluate(\"'ciao'\")",
+ "engine->evaluate(\"''\")",
+ "engine->evaluate(\"'0'\")",
+ "engine->evaluate(\"'123'\")",
+ "engine->evaluate(\"'12.4'\")",
+ "engine->nullValue()",
+ "engine->undefinedValue()"};
+
+static quint16 toUInt16_valueArray[] = {
+ 0, 0,
+ 0, 1,
+ 0, 122,
+ 124, 0,
+ 0, 123,
+ 0, 0,
+ 4660, 0,
+ 1, 0,
+ 0, 0,
+ 0, 0,
+ 0, 0,
+ 0, 0,
+ 0, 0,
+ 0, 123,
+ 12, 0,
+ 0, 1,
+ 0, 122,
+ 124, 0,
+ 0, 123,
+ 0, 0,
+ 4660, 0,
+ 1, 0,
+ 0, 0,
+ 0, 0,
+ 0, 0,
+ 0, 0,
+ 0, 0,
+ 0, 123,
+ 12, 0,
+ 0, 1,
+ 0, 122,
+ 124, 0,
+ 0, 123,
+ 0, 0,
+ 4660, 0,
+ 1, 0,
+ 0, 0,
+ 0, 0,
+ 0, 0,
+ 0, 0,
+ 0, 0,
+ 0, 123,
+ 1, 0,
+ 0, 0,
+ 0, 0,
+ 0, 0,
+ 0, 0,
+ 0, 0,
+ 0, 0,
+ 0, 0,
+ 0, 0,
+ 0, 0,
+ 0, 0,
+ 0, 0,
+ 0, 0,
+ 1, 0,
+ 122, 124,
+ 0, 0,
+ 123, 0,
+ 0, 4660,
+ 0, 1,
+ 0, 0,
+ 0, 0,
+ 0, 0,
+ 123, 12,
+ 0, 0};
+
+void tst_QScriptValue::toUInt16_makeData(const char* expr)
+{
+ static QHash<QString, quint16> toUInt16;
+ if (toUInt16.isEmpty()) {
+ toUInt16.reserve(132);
+ for (unsigned i = 0; i < 132; ++i)
+ toUInt16.insert(toUInt16_tagArray[i], toUInt16_valueArray[i]);
+ }
+ newRow(expr) << toUInt16.value(expr);
+}
+
+void tst_QScriptValue::toUInt16_test(const char*, const QScriptValue& value)
+{
+ QFETCH(quint16, expected);
+ QCOMPARE(value.toUInt16(), expected);
+ QCOMPARE(value.toUInt16(), expected);
+}
+
+DEFINE_TEST_FUNCTION(toUInt16)
diff --git a/JavaScriptCore/runtime/Arguments.h b/JavaScriptCore/runtime/Arguments.h
index 9dda24c..5b8e51c 100644
--- a/JavaScriptCore/runtime/Arguments.h
+++ b/JavaScriptCore/runtime/Arguments.h
@@ -216,7 +216,7 @@ namespace JSC {
}
// This JSActivation function is defined here so it can get at Arguments::setRegisters.
- inline void JSActivation::copyRegisters(Arguments* arguments)
+ inline void JSActivation::copyRegisters()
{
ASSERT(!d()->registerArray);
@@ -232,18 +232,8 @@ namespace JSC {
Register* registerArray = copyRegisterArray(d()->registers - registerOffset, registerArraySize);
setRegisters(registerArray + registerOffset, registerArray);
- if (arguments && !arguments->isTornOff())
- static_cast<Arguments*>(arguments)->setActivation(this);
}
- ALWAYS_INLINE Arguments* Register::arguments() const
- {
- if (jsValue() == JSValue())
- return 0;
- return asArguments(jsValue());
- }
-
-
} // namespace JSC
#endif // Arguments_h
diff --git a/JavaScriptCore/runtime/ArrayConstructor.cpp b/JavaScriptCore/runtime/ArrayConstructor.cpp
index fb44494..c159be4 100644
--- a/JavaScriptCore/runtime/ArrayConstructor.cpp
+++ b/JavaScriptCore/runtime/ArrayConstructor.cpp
@@ -37,8 +37,8 @@ ASSERT_CLASS_FITS_IN_CELL(ArrayConstructor);
static JSValue JSC_HOST_CALL arrayConstructorIsArray(ExecState*, JSObject*, JSValue, const ArgList&);
-ArrayConstructor::ArrayConstructor(ExecState* exec, NonNullPassRefPtr<Structure> structure, ArrayPrototype* arrayPrototype, Structure* prototypeFunctionStructure)
- : InternalFunction(&exec->globalData(), structure, Identifier(exec, arrayPrototype->classInfo()->className))
+ArrayConstructor::ArrayConstructor(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, ArrayPrototype* arrayPrototype, Structure* prototypeFunctionStructure)
+ : InternalFunction(&exec->globalData(), globalObject, structure, Identifier(exec, arrayPrototype->classInfo()->className))
{
// ECMA 15.4.3.1 Array.prototype
putDirectWithoutTransition(exec->propertyNames().prototype, arrayPrototype, DontEnum | DontDelete | ReadOnly);
@@ -47,7 +47,7 @@ ArrayConstructor::ArrayConstructor(ExecState* exec, NonNullPassRefPtr<Structure>
putDirectWithoutTransition(exec->propertyNames().length, jsNumber(exec, 1), ReadOnly | DontEnum | DontDelete);
// ES5
- putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 1, exec->propertyNames().isArray, arrayConstructorIsArray), DontEnum);
+ putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 1, exec->propertyNames().isArray, arrayConstructorIsArray), DontEnum);
}
static inline JSObject* constructArrayWithSizeQuirk(ExecState* exec, const ArgList& args)
diff --git a/JavaScriptCore/runtime/ArrayConstructor.h b/JavaScriptCore/runtime/ArrayConstructor.h
index 6d25400..5e1408f 100644
--- a/JavaScriptCore/runtime/ArrayConstructor.h
+++ b/JavaScriptCore/runtime/ArrayConstructor.h
@@ -29,7 +29,7 @@ namespace JSC {
class ArrayConstructor : public InternalFunction {
public:
- ArrayConstructor(ExecState*, NonNullPassRefPtr<Structure>, ArrayPrototype*, Structure*);
+ ArrayConstructor(ExecState*, JSGlobalObject*, NonNullPassRefPtr<Structure>, ArrayPrototype*, Structure*);
virtual ConstructType getConstructData(ConstructData&);
virtual CallType getCallData(CallData&);
diff --git a/JavaScriptCore/runtime/ArrayPrototype.cpp b/JavaScriptCore/runtime/ArrayPrototype.cpp
index 99564a8..70ce69f 100644
--- a/JavaScriptCore/runtime/ArrayPrototype.cpp
+++ b/JavaScriptCore/runtime/ArrayPrototype.cpp
@@ -116,9 +116,10 @@ const ClassInfo ArrayPrototype::info = {"Array", &JSArray::info, 0, ExecState::a
*/
// ECMA 15.4.4
-ArrayPrototype::ArrayPrototype(NonNullPassRefPtr<Structure> structure)
+ArrayPrototype::ArrayPrototype(JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure)
: JSArray(structure)
{
+ putAnonymousValue(0, globalObject);
}
bool ArrayPrototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
diff --git a/JavaScriptCore/runtime/ArrayPrototype.h b/JavaScriptCore/runtime/ArrayPrototype.h
index e52914c..42665e3 100644
--- a/JavaScriptCore/runtime/ArrayPrototype.h
+++ b/JavaScriptCore/runtime/ArrayPrototype.h
@@ -28,13 +28,21 @@ namespace JSC {
class ArrayPrototype : public JSArray {
public:
- explicit ArrayPrototype(NonNullPassRefPtr<Structure>);
+ explicit ArrayPrototype(JSGlobalObject*, NonNullPassRefPtr<Structure>);
bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
virtual bool getOwnPropertyDescriptor(ExecState*, const Identifier&, PropertyDescriptor&);
virtual const ClassInfo* classInfo() const { return &info; }
static const ClassInfo info;
+
+ static PassRefPtr<Structure> createStructure(JSValue prototype)
+ {
+ return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount);
+ }
+
+ protected:
+ static const unsigned AnonymousSlotCount = JSArray::AnonymousSlotCount + 1;
};
} // namespace JSC
diff --git a/JavaScriptCore/runtime/BooleanConstructor.cpp b/JavaScriptCore/runtime/BooleanConstructor.cpp
index b0d8df3..07bcc97 100644
--- a/JavaScriptCore/runtime/BooleanConstructor.cpp
+++ b/JavaScriptCore/runtime/BooleanConstructor.cpp
@@ -28,8 +28,8 @@ namespace JSC {
ASSERT_CLASS_FITS_IN_CELL(BooleanConstructor);
-BooleanConstructor::BooleanConstructor(ExecState* exec, NonNullPassRefPtr<Structure> structure, BooleanPrototype* booleanPrototype)
- : InternalFunction(&exec->globalData(), structure, Identifier(exec, booleanPrototype->classInfo()->className))
+BooleanConstructor::BooleanConstructor(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, BooleanPrototype* booleanPrototype)
+ : InternalFunction(&exec->globalData(), globalObject, structure, Identifier(exec, booleanPrototype->classInfo()->className))
{
putDirectWithoutTransition(exec->propertyNames().prototype, booleanPrototype, DontEnum | DontDelete | ReadOnly);
diff --git a/JavaScriptCore/runtime/BooleanConstructor.h b/JavaScriptCore/runtime/BooleanConstructor.h
index 1d8a26a..0f3efa7 100644
--- a/JavaScriptCore/runtime/BooleanConstructor.h
+++ b/JavaScriptCore/runtime/BooleanConstructor.h
@@ -29,7 +29,7 @@ namespace JSC {
class BooleanConstructor : public InternalFunction {
public:
- BooleanConstructor(ExecState*, NonNullPassRefPtr<Structure>, BooleanPrototype*);
+ BooleanConstructor(ExecState*, JSGlobalObject*, NonNullPassRefPtr<Structure>, BooleanPrototype*);
private:
virtual ConstructType getConstructData(ConstructData&);
diff --git a/JavaScriptCore/runtime/BooleanPrototype.cpp b/JavaScriptCore/runtime/BooleanPrototype.cpp
index 8d338f9..4378164 100644
--- a/JavaScriptCore/runtime/BooleanPrototype.cpp
+++ b/JavaScriptCore/runtime/BooleanPrototype.cpp
@@ -37,13 +37,13 @@ static JSValue JSC_HOST_CALL booleanProtoFuncValueOf(ExecState*, JSObject*, JSVa
// ECMA 15.6.4
-BooleanPrototype::BooleanPrototype(ExecState* exec, NonNullPassRefPtr<Structure> structure, Structure* prototypeFunctionStructure)
+BooleanPrototype::BooleanPrototype(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, Structure* prototypeFunctionStructure)
: BooleanObject(structure)
{
setInternalValue(jsBoolean(false));
- putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 0, exec->propertyNames().toString, booleanProtoFuncToString), DontEnum);
- putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 0, exec->propertyNames().valueOf, booleanProtoFuncValueOf), DontEnum);
+ putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 0, exec->propertyNames().toString, booleanProtoFuncToString), DontEnum);
+ putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 0, exec->propertyNames().valueOf, booleanProtoFuncValueOf), DontEnum);
}
diff --git a/JavaScriptCore/runtime/BooleanPrototype.h b/JavaScriptCore/runtime/BooleanPrototype.h
index cc69b3f..ddadc43 100644
--- a/JavaScriptCore/runtime/BooleanPrototype.h
+++ b/JavaScriptCore/runtime/BooleanPrototype.h
@@ -27,7 +27,7 @@ namespace JSC {
class BooleanPrototype : public BooleanObject {
public:
- BooleanPrototype(ExecState*, NonNullPassRefPtr<Structure>, Structure* prototypeFunctionStructure);
+ BooleanPrototype(ExecState*, JSGlobalObject*, NonNullPassRefPtr<Structure>, Structure* prototypeFunctionStructure);
};
} // namespace JSC
diff --git a/JavaScriptCore/runtime/DateConstructor.cpp b/JavaScriptCore/runtime/DateConstructor.cpp
index ab95d06..d732a4f 100644
--- a/JavaScriptCore/runtime/DateConstructor.cpp
+++ b/JavaScriptCore/runtime/DateConstructor.cpp
@@ -58,14 +58,14 @@ static JSValue JSC_HOST_CALL dateParse(ExecState*, JSObject*, JSValue, const Arg
static JSValue JSC_HOST_CALL dateNow(ExecState*, JSObject*, JSValue, const ArgList&);
static JSValue JSC_HOST_CALL dateUTC(ExecState*, JSObject*, JSValue, const ArgList&);
-DateConstructor::DateConstructor(ExecState* exec, NonNullPassRefPtr<Structure> structure, Structure* prototypeFunctionStructure, DatePrototype* datePrototype)
- : InternalFunction(&exec->globalData(), structure, Identifier(exec, datePrototype->classInfo()->className))
+DateConstructor::DateConstructor(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, Structure* prototypeFunctionStructure, DatePrototype* datePrototype)
+ : InternalFunction(&exec->globalData(), globalObject, structure, Identifier(exec, datePrototype->classInfo()->className))
{
putDirectWithoutTransition(exec->propertyNames().prototype, datePrototype, DontEnum|DontDelete|ReadOnly);
- putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 1, exec->propertyNames().parse, dateParse), DontEnum);
- putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 7, exec->propertyNames().UTC, dateUTC), DontEnum);
- putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 0, exec->propertyNames().now, dateNow), DontEnum);
+ putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 1, exec->propertyNames().parse, dateParse), DontEnum);
+ putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 7, exec->propertyNames().UTC, dateUTC), DontEnum);
+ putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 0, exec->propertyNames().now, dateNow), DontEnum);
putDirectWithoutTransition(exec->propertyNames().length, jsNumber(exec, 7), ReadOnly | DontEnum | DontDelete);
}
diff --git a/JavaScriptCore/runtime/DateConstructor.h b/JavaScriptCore/runtime/DateConstructor.h
index 10e450e..c8ca456 100644
--- a/JavaScriptCore/runtime/DateConstructor.h
+++ b/JavaScriptCore/runtime/DateConstructor.h
@@ -29,7 +29,7 @@ namespace JSC {
class DateConstructor : public InternalFunction {
public:
- DateConstructor(ExecState*, NonNullPassRefPtr<Structure>, Structure* prototypeFunctionStructure, DatePrototype*);
+ DateConstructor(ExecState*, JSGlobalObject*, NonNullPassRefPtr<Structure>, Structure* prototypeFunctionStructure, DatePrototype*);
private:
virtual ConstructType getConstructData(ConstructData&);
diff --git a/JavaScriptCore/runtime/DatePrototype.cpp b/JavaScriptCore/runtime/DatePrototype.cpp
index 108ff55..a5dfabd 100644
--- a/JavaScriptCore/runtime/DatePrototype.cpp
+++ b/JavaScriptCore/runtime/DatePrototype.cpp
@@ -418,10 +418,11 @@ const ClassInfo DatePrototype::info = {"Date", &DateInstance::info, 0, ExecState
// ECMA 15.9.4
-DatePrototype::DatePrototype(ExecState* exec, NonNullPassRefPtr<Structure> structure)
+DatePrototype::DatePrototype(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure)
: DateInstance(exec, structure)
{
// The constructor will be added later, after DateConstructor has been built.
+ putAnonymousValue(0, globalObject);
}
bool DatePrototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
diff --git a/JavaScriptCore/runtime/DatePrototype.h b/JavaScriptCore/runtime/DatePrototype.h
index 612ca06..e3672aa 100644
--- a/JavaScriptCore/runtime/DatePrototype.h
+++ b/JavaScriptCore/runtime/DatePrototype.h
@@ -29,7 +29,7 @@ namespace JSC {
class DatePrototype : public DateInstance {
public:
- DatePrototype(ExecState*, NonNullPassRefPtr<Structure>);
+ DatePrototype(ExecState*, JSGlobalObject*, NonNullPassRefPtr<Structure>);
virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
virtual bool getOwnPropertyDescriptor(ExecState*, const Identifier&, PropertyDescriptor&);
diff --git a/JavaScriptCore/runtime/ErrorConstructor.cpp b/JavaScriptCore/runtime/ErrorConstructor.cpp
index b9c3f58..4a4559e 100644
--- a/JavaScriptCore/runtime/ErrorConstructor.cpp
+++ b/JavaScriptCore/runtime/ErrorConstructor.cpp
@@ -29,8 +29,8 @@ namespace JSC {
ASSERT_CLASS_FITS_IN_CELL(ErrorConstructor);
-ErrorConstructor::ErrorConstructor(ExecState* exec, NonNullPassRefPtr<Structure> structure, ErrorPrototype* errorPrototype)
- : InternalFunction(&exec->globalData(), structure, Identifier(exec, errorPrototype->classInfo()->className))
+ErrorConstructor::ErrorConstructor(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, ErrorPrototype* errorPrototype)
+ : InternalFunction(&exec->globalData(), globalObject, structure, Identifier(exec, errorPrototype->classInfo()->className))
{
// ECMA 15.11.3.1 Error.prototype
putDirectWithoutTransition(exec->propertyNames().prototype, errorPrototype, DontEnum | DontDelete | ReadOnly);
diff --git a/JavaScriptCore/runtime/ErrorConstructor.h b/JavaScriptCore/runtime/ErrorConstructor.h
index e3d789b..c0e3323 100644
--- a/JavaScriptCore/runtime/ErrorConstructor.h
+++ b/JavaScriptCore/runtime/ErrorConstructor.h
@@ -30,7 +30,7 @@ namespace JSC {
class ErrorConstructor : public InternalFunction {
public:
- ErrorConstructor(ExecState*, NonNullPassRefPtr<Structure>, ErrorPrototype*);
+ ErrorConstructor(ExecState*, JSGlobalObject*, NonNullPassRefPtr<Structure>, ErrorPrototype*);
private:
virtual ConstructType getConstructData(ConstructData&);
diff --git a/JavaScriptCore/runtime/ErrorPrototype.cpp b/JavaScriptCore/runtime/ErrorPrototype.cpp
index eb35733..72fa4c4 100644
--- a/JavaScriptCore/runtime/ErrorPrototype.cpp
+++ b/JavaScriptCore/runtime/ErrorPrototype.cpp
@@ -35,7 +35,7 @@ ASSERT_CLASS_FITS_IN_CELL(ErrorPrototype);
static JSValue JSC_HOST_CALL errorProtoFuncToString(ExecState*, JSObject*, JSValue, const ArgList&);
// ECMA 15.9.4
-ErrorPrototype::ErrorPrototype(ExecState* exec, NonNullPassRefPtr<Structure> structure, Structure* prototypeFunctionStructure)
+ErrorPrototype::ErrorPrototype(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, Structure* prototypeFunctionStructure)
: ErrorInstance(structure)
{
// The constructor will be added later in ErrorConstructor's constructor
@@ -43,7 +43,7 @@ ErrorPrototype::ErrorPrototype(ExecState* exec, NonNullPassRefPtr<Structure> str
putDirectWithoutTransition(exec->propertyNames().name, jsNontrivialString(exec, "Error"), DontEnum);
putDirectWithoutTransition(exec->propertyNames().message, jsNontrivialString(exec, "Unknown error"), DontEnum);
- putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 0, exec->propertyNames().toString, errorProtoFuncToString), DontEnum);
+ putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 0, exec->propertyNames().toString, errorProtoFuncToString), DontEnum);
}
JSValue JSC_HOST_CALL errorProtoFuncToString(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&)
diff --git a/JavaScriptCore/runtime/ErrorPrototype.h b/JavaScriptCore/runtime/ErrorPrototype.h
index a561590..fce2742 100644
--- a/JavaScriptCore/runtime/ErrorPrototype.h
+++ b/JavaScriptCore/runtime/ErrorPrototype.h
@@ -29,7 +29,7 @@ namespace JSC {
class ErrorPrototype : public ErrorInstance {
public:
- ErrorPrototype(ExecState*, NonNullPassRefPtr<Structure>, Structure* prototypeFunctionStructure);
+ ErrorPrototype(ExecState*, JSGlobalObject*, NonNullPassRefPtr<Structure>, Structure* prototypeFunctionStructure);
};
} // namespace JSC
diff --git a/JavaScriptCore/runtime/Executable.h b/JavaScriptCore/runtime/Executable.h
index 3e1609e..ac63c49 100644
--- a/JavaScriptCore/runtime/Executable.h
+++ b/JavaScriptCore/runtime/Executable.h
@@ -26,6 +26,7 @@
#ifndef Executable_h
#define Executable_h
+#include "CallData.h"
#include "JSFunction.h"
#include "Interpreter.h"
#include "Nodes.h"
@@ -90,21 +91,27 @@ namespace JSC {
#if ENABLE(JIT)
class NativeExecutable : public ExecutableBase {
+ friend class JIT;
public:
- NativeExecutable(ExecState* exec)
- : ExecutableBase(NUM_PARAMETERS_IS_HOST)
+ static PassRefPtr<NativeExecutable> create(MacroAssemblerCodePtr thunk, NativeFunction function)
{
- m_jitCodeForCall = exec->globalData().jitStubs.ctiNativeCallThunk()->m_jitCodeForCall;
- m_jitCodeForConstruct = exec->globalData().jitStubs.ctiNativeCallThunk()->m_jitCodeForCall; // FIXME: this thunk should have a construct form
+ return adoptRef(new NativeExecutable(JITCode::HostFunction(thunk), function));
}
- NativeExecutable(JITCode thunk)
+
+ ~NativeExecutable();
+
+ NativeFunction function() { return m_function; }
+
+ private:
+ NativeExecutable(JITCode thunk, NativeFunction function)
: ExecutableBase(NUM_PARAMETERS_IS_HOST)
+ , m_function(function)
{
m_jitCodeForCall = thunk;
m_jitCodeForConstruct = thunk;
}
- ~NativeExecutable();
+ NativeFunction m_function;
};
#endif
@@ -278,6 +285,17 @@ namespace JSC {
{
return new (exec) JSFunction(exec, this, scopeChain);
}
+
+ // Returns either call or construct bytecode. This can be appropriate
+ // for answering questions that that don't vary between call and construct --
+ // for example, argumentsRegister().
+ FunctionCodeBlock& generatedByteCode()
+ {
+ if (m_codeBlockForCall)
+ return *m_codeBlockForCall;
+ ASSERT(m_codeBlockForConstruct);
+ return *m_codeBlockForConstruct;
+ }
FunctionCodeBlock& bytecodeForCall(ExecState* exec, ScopeChainNode* scopeChainNode)
{
@@ -403,6 +421,13 @@ namespace JSC {
return m_executable->isHostFunction();
}
+#if ENABLE(JIT)
+ inline NativeFunction JSFunction::nativeFunction()
+ {
+ ASSERT(isHostFunction());
+ return static_cast<NativeExecutable*>(m_executable.get())->function();
+ }
+#endif
}
#endif
diff --git a/JavaScriptCore/runtime/FunctionConstructor.cpp b/JavaScriptCore/runtime/FunctionConstructor.cpp
index 9b0b1bb..c8299a9 100644
--- a/JavaScriptCore/runtime/FunctionConstructor.cpp
+++ b/JavaScriptCore/runtime/FunctionConstructor.cpp
@@ -35,8 +35,8 @@ namespace JSC {
ASSERT_CLASS_FITS_IN_CELL(FunctionConstructor);
-FunctionConstructor::FunctionConstructor(ExecState* exec, NonNullPassRefPtr<Structure> structure, FunctionPrototype* functionPrototype)
- : InternalFunction(&exec->globalData(), structure, Identifier(exec, functionPrototype->classInfo()->className))
+FunctionConstructor::FunctionConstructor(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, FunctionPrototype* functionPrototype)
+ : InternalFunction(&exec->globalData(), globalObject, structure, Identifier(exec, functionPrototype->classInfo()->className))
{
putDirectWithoutTransition(exec->propertyNames().prototype, functionPrototype, DontEnum | DontDelete | ReadOnly);
diff --git a/JavaScriptCore/runtime/FunctionConstructor.h b/JavaScriptCore/runtime/FunctionConstructor.h
index 197f320..6af4861 100644
--- a/JavaScriptCore/runtime/FunctionConstructor.h
+++ b/JavaScriptCore/runtime/FunctionConstructor.h
@@ -29,7 +29,7 @@ namespace JSC {
class FunctionConstructor : public InternalFunction {
public:
- FunctionConstructor(ExecState*, NonNullPassRefPtr<Structure>, FunctionPrototype*);
+ FunctionConstructor(ExecState*, JSGlobalObject*, NonNullPassRefPtr<Structure>, FunctionPrototype*);
private:
virtual ConstructType getConstructData(ConstructData&);
diff --git a/JavaScriptCore/runtime/FunctionPrototype.cpp b/JavaScriptCore/runtime/FunctionPrototype.cpp
index a77b5b2..1762816 100644
--- a/JavaScriptCore/runtime/FunctionPrototype.cpp
+++ b/JavaScriptCore/runtime/FunctionPrototype.cpp
@@ -38,18 +38,18 @@ static JSValue JSC_HOST_CALL functionProtoFuncToString(ExecState*, JSObject*, JS
static JSValue JSC_HOST_CALL functionProtoFuncApply(ExecState*, JSObject*, JSValue, const ArgList&);
static JSValue JSC_HOST_CALL functionProtoFuncCall(ExecState*, JSObject*, JSValue, const ArgList&);
-FunctionPrototype::FunctionPrototype(ExecState* exec, NonNullPassRefPtr<Structure> structure)
- : InternalFunction(&exec->globalData(), structure, exec->propertyNames().nullIdentifier)
+FunctionPrototype::FunctionPrototype(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure)
+ : InternalFunction(&exec->globalData(), globalObject, structure, exec->propertyNames().nullIdentifier)
{
putDirectWithoutTransition(exec->propertyNames().length, jsNumber(exec, 0), DontDelete | ReadOnly | DontEnum);
}
-void FunctionPrototype::addFunctionProperties(ExecState* exec, Structure* prototypeFunctionStructure, NativeFunctionWrapper** callFunction, NativeFunctionWrapper** applyFunction)
+void FunctionPrototype::addFunctionProperties(ExecState* exec, JSGlobalObject* globalObject, Structure* prototypeFunctionStructure, NativeFunctionWrapper** callFunction, NativeFunctionWrapper** applyFunction)
{
- putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 0, exec->propertyNames().toString, functionProtoFuncToString), DontEnum);
- *applyFunction = new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 2, exec->propertyNames().apply, functionProtoFuncApply);
+ putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 0, exec->propertyNames().toString, functionProtoFuncToString), DontEnum);
+ *applyFunction = new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 2, exec->propertyNames().apply, functionProtoFuncApply);
putDirectFunctionWithoutTransition(exec, *applyFunction, DontEnum);
- *callFunction = new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 1, exec->propertyNames().call, functionProtoFuncCall);
+ *callFunction = new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 1, exec->propertyNames().call, functionProtoFuncCall);
putDirectFunctionWithoutTransition(exec, *callFunction, DontEnum);
}
@@ -87,12 +87,12 @@ JSValue JSC_HOST_CALL functionProtoFuncToString(ExecState* exec, JSObject*, JSVa
{
if (thisValue.inherits(&JSFunction::info)) {
JSFunction* function = asFunction(thisValue);
- if (!function->isHostFunction()) {
- FunctionExecutable* executable = function->jsExecutable();
- UString sourceString = executable->source().toString();
- insertSemicolonIfNeeded(sourceString);
- return jsMakeNontrivialString(exec, "function ", function->name(exec), "(", executable->paramString(), ") ", sourceString);
- }
+ if (function->isHostFunction())
+ return jsMakeNontrivialString(exec, "function ", function->name(exec), "() {\n [native code]\n}");
+ FunctionExecutable* executable = function->jsExecutable();
+ UString sourceString = executable->source().toString();
+ insertSemicolonIfNeeded(sourceString);
+ return jsMakeNontrivialString(exec, "function ", function->name(exec), "(", executable->paramString(), ") ", sourceString);
}
if (thisValue.inherits(&InternalFunction::info)) {
diff --git a/JavaScriptCore/runtime/FunctionPrototype.h b/JavaScriptCore/runtime/FunctionPrototype.h
index af783f7..5661194 100644
--- a/JavaScriptCore/runtime/FunctionPrototype.h
+++ b/JavaScriptCore/runtime/FunctionPrototype.h
@@ -29,8 +29,8 @@ namespace JSC {
class FunctionPrototype : public InternalFunction {
public:
- FunctionPrototype(ExecState*, NonNullPassRefPtr<Structure>);
- void addFunctionProperties(ExecState*, Structure* prototypeFunctionStructure, NativeFunctionWrapper** callFunction, NativeFunctionWrapper** applyFunction);
+ FunctionPrototype(ExecState*, JSGlobalObject*, NonNullPassRefPtr<Structure>);
+ void addFunctionProperties(ExecState*, JSGlobalObject*, Structure* prototypeFunctionStructure, NativeFunctionWrapper** callFunction, NativeFunctionWrapper** applyFunction);
static PassRefPtr<Structure> createStructure(JSValue proto)
{
diff --git a/JavaScriptCore/runtime/GlobalEvalFunction.cpp b/JavaScriptCore/runtime/GlobalEvalFunction.cpp
index c26002b..3ad4644 100644
--- a/JavaScriptCore/runtime/GlobalEvalFunction.cpp
+++ b/JavaScriptCore/runtime/GlobalEvalFunction.cpp
@@ -32,8 +32,8 @@ namespace JSC {
ASSERT_CLASS_FITS_IN_CELL(GlobalEvalFunction);
-GlobalEvalFunction::GlobalEvalFunction(ExecState* exec, NonNullPassRefPtr<Structure> structure, int len, const Identifier& name, NativeFunction function, JSGlobalObject* cachedGlobalObject)
- : PrototypeFunction(exec, structure, len, name, function)
+GlobalEvalFunction::GlobalEvalFunction(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, int len, const Identifier& name, NativeFunction function, JSGlobalObject* cachedGlobalObject)
+ : PrototypeFunction(exec, globalObject, structure, len, name, function)
, m_cachedGlobalObject(cachedGlobalObject)
{
ASSERT_ARG(cachedGlobalObject, cachedGlobalObject);
diff --git a/JavaScriptCore/runtime/GlobalEvalFunction.h b/JavaScriptCore/runtime/GlobalEvalFunction.h
index a14ce4d..b889ca9 100644
--- a/JavaScriptCore/runtime/GlobalEvalFunction.h
+++ b/JavaScriptCore/runtime/GlobalEvalFunction.h
@@ -32,7 +32,7 @@ namespace JSC {
class GlobalEvalFunction : public PrototypeFunction {
public:
- GlobalEvalFunction(ExecState*, NonNullPassRefPtr<Structure>, int len, const Identifier&, NativeFunction, JSGlobalObject* expectedThisObject);
+ GlobalEvalFunction(ExecState*, JSGlobalObject*, NonNullPassRefPtr<Structure>, int len, const Identifier&, NativeFunction, JSGlobalObject* expectedThisObject);
JSGlobalObject* cachedGlobalObject() const { return m_cachedGlobalObject; }
static PassRefPtr<Structure> createStructure(JSValue prototype)
diff --git a/JavaScriptCore/runtime/InternalFunction.cpp b/JavaScriptCore/runtime/InternalFunction.cpp
index 717b5ff..f774993 100644
--- a/JavaScriptCore/runtime/InternalFunction.cpp
+++ b/JavaScriptCore/runtime/InternalFunction.cpp
@@ -24,6 +24,7 @@
#include "InternalFunction.h"
#include "FunctionPrototype.h"
+#include "JSGlobalObject.h"
#include "JSString.h"
namespace JSC {
@@ -37,15 +38,20 @@ const ClassInfo* InternalFunction::classInfo() const
return &info;
}
-InternalFunction::InternalFunction(JSGlobalData* globalData, NonNullPassRefPtr<Structure> structure, const Identifier& name)
- : JSObject(structure)
+InternalFunction::InternalFunction(NonNullPassRefPtr<Structure> structure)
+ : JSObjectWithGlobalObject(structure)
+{
+}
+
+InternalFunction::InternalFunction(JSGlobalData* globalData, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, const Identifier& name)
+ : JSObjectWithGlobalObject(globalObject, structure)
{
putDirect(globalData->propertyNames->name, jsString(globalData, name.isNull() ? "" : name.ustring()), DontDelete | ReadOnly | DontEnum);
}
const UString& InternalFunction::name(ExecState* exec)
{
- return asString(getDirect(exec->globalData().propertyNames->name))->value(exec);
+ return asString(getDirect(exec->globalData().propertyNames->name))->tryGetValue();
}
const UString InternalFunction::displayName(ExecState* exec)
@@ -53,7 +59,7 @@ const UString InternalFunction::displayName(ExecState* exec)
JSValue displayName = getDirect(exec->globalData().propertyNames->displayName);
if (displayName && isJSString(&exec->globalData(), displayName))
- return asString(displayName)->value(exec);
+ return asString(displayName)->tryGetValue();
return UString::null();
}
diff --git a/JavaScriptCore/runtime/InternalFunction.h b/JavaScriptCore/runtime/InternalFunction.h
index d19b82b..401f17b 100644
--- a/JavaScriptCore/runtime/InternalFunction.h
+++ b/JavaScriptCore/runtime/InternalFunction.h
@@ -24,14 +24,14 @@
#ifndef InternalFunction_h
#define InternalFunction_h
-#include "JSObject.h"
+#include "JSObjectWithGlobalObject.h"
#include "Identifier.h"
namespace JSC {
class FunctionPrototype;
- class InternalFunction : public JSObject {
+ class InternalFunction : public JSObjectWithGlobalObject {
public:
virtual const ClassInfo* classInfo() const;
static JS_EXPORTDATA const ClassInfo info;
@@ -48,8 +48,10 @@ namespace JSC {
protected:
static const unsigned StructureFlags = ImplementsHasInstance | JSObject::StructureFlags;
- InternalFunction(NonNullPassRefPtr<Structure> structure) : JSObject(structure) { }
- InternalFunction(JSGlobalData*, NonNullPassRefPtr<Structure>, const Identifier&);
+ // Only used to allow us to determine the JSFunction vptr
+ InternalFunction(NonNullPassRefPtr<Structure> structure);
+
+ InternalFunction(JSGlobalData*, JSGlobalObject*, NonNullPassRefPtr<Structure>, const Identifier&);
private:
virtual CallType getCallData(CallData&) = 0;
diff --git a/JavaScriptCore/runtime/JSActivation.cpp b/JavaScriptCore/runtime/JSActivation.cpp
index f468ff1..fd415ce 100644
--- a/JavaScriptCore/runtime/JSActivation.cpp
+++ b/JavaScriptCore/runtime/JSActivation.cpp
@@ -70,6 +70,11 @@ void JSActivation::markChildren(MarkStack& markStack)
bool JSActivation::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
{
+ if (propertyName == exec->propertyNames().arguments) {
+ slot.setCustom(this, getArgumentsGetter());
+ return true;
+ }
+
if (symbolTableGet(propertyName, slot))
return true;
@@ -78,12 +83,6 @@ bool JSActivation::getOwnPropertySlot(ExecState* exec, const Identifier& propert
return true;
}
- // Only return the built-in arguments object if it wasn't overridden above.
- if (propertyName == exec->propertyNames().arguments) {
- slot.setCustom(this, getArgumentsGetter());
- return true;
- }
-
// We don't call through to JSObject because there's no way to give an
// activation object getter properties or a prototype.
ASSERT(!hasGetterSetterProperties());
@@ -140,26 +139,19 @@ bool JSActivation::isDynamicScope(bool& requiresDynamicChecks) const
return false;
}
-JSValue JSActivation::argumentsGetter(ExecState* exec, JSValue slotBase, const Identifier&)
+JSValue JSActivation::argumentsGetter(ExecState*, JSValue slotBase, const Identifier&)
{
JSActivation* activation = asActivation(slotBase);
-
- if (activation->d()->functionExecutable->usesArguments()) {
- PropertySlot slot;
- activation->symbolTableGet(exec->propertyNames().arguments, slot);
- return slot.getValue(exec, exec->propertyNames().arguments);
- }
-
CallFrame* callFrame = CallFrame::create(activation->d()->registers);
- Arguments* arguments = callFrame->optionalCalleeArguments();
- if (!arguments) {
- arguments = new (callFrame) Arguments(callFrame);
- arguments->copyRegisters();
- callFrame->setCalleeArguments(arguments);
+ int argumentsRegister = activation->d()->functionExecutable->generatedByteCode().argumentsRegister();
+ if (!callFrame->r(argumentsRegister).jsValue()) {
+ JSValue arguments = JSValue(new (callFrame) Arguments(callFrame));
+ callFrame->r(argumentsRegister) = arguments;
+ callFrame->r(unmodifiedArgumentsRegister(argumentsRegister)) = arguments;
}
- ASSERT(arguments->inherits(&Arguments::info));
- return arguments;
+ ASSERT(callFrame->r(argumentsRegister).jsValue().inherits(&Arguments::info));
+ return callFrame->r(argumentsRegister).jsValue();
}
// These two functions serve the purpose of isolating the common case from a
diff --git a/JavaScriptCore/runtime/JSActivation.h b/JavaScriptCore/runtime/JSActivation.h
index a5f8f58..d5e7991 100644
--- a/JavaScriptCore/runtime/JSActivation.h
+++ b/JavaScriptCore/runtime/JSActivation.h
@@ -60,7 +60,7 @@ namespace JSC {
virtual JSObject* toThisObject(ExecState*) const;
- void copyRegisters(Arguments* arguments);
+ void copyRegisters();
virtual const ClassInfo* classInfo() const { return &info; }
static const ClassInfo info;
diff --git a/JavaScriptCore/runtime/JSCell.h b/JavaScriptCore/runtime/JSCell.h
index ae5aca3..c083825 100644
--- a/JavaScriptCore/runtime/JSCell.h
+++ b/JavaScriptCore/runtime/JSCell.h
@@ -207,12 +207,16 @@ namespace JSC {
inline CallType JSValue::getCallData(CallData& callData)
{
- return isCell() ? asCell()->getCallData(callData) : CallTypeNone;
+ CallType result = isCell() ? asCell()->getCallData(callData) : CallTypeNone;
+ ASSERT(result == CallTypeNone || isValidCallee());
+ return result;
}
inline ConstructType JSValue::getConstructData(ConstructData& constructData)
{
- return isCell() ? asCell()->getConstructData(constructData) : ConstructTypeNone;
+ ConstructType result = isCell() ? asCell()->getConstructData(constructData) : ConstructTypeNone;
+ ASSERT(result == ConstructTypeNone || isValidCallee());
+ return result;
}
ALWAYS_INLINE bool JSValue::getUInt32(uint32_t& v) const
diff --git a/JavaScriptCore/runtime/JSFunction.cpp b/JavaScriptCore/runtime/JSFunction.cpp
index c9f295b..9d36e91 100644
--- a/JavaScriptCore/runtime/JSFunction.cpp
+++ b/JavaScriptCore/runtime/JSFunction.cpp
@@ -43,7 +43,7 @@ namespace JSC {
ASSERT_CLASS_FITS_IN_CELL(JSFunction);
-const ClassInfo JSFunction::info = { "Function", &InternalFunction::info, 0, 0 };
+const ClassInfo JSFunction::info = { "Function", 0, 0, 0 };
bool JSFunction::isHostFunctionNonInline() const
{
@@ -53,34 +53,36 @@ bool JSFunction::isHostFunctionNonInline() const
JSFunction::JSFunction(NonNullPassRefPtr<Structure> structure)
: Base(structure)
, m_executable(adoptRef(new VPtrHackExecutable()))
+ , m_scopeChain(NoScopeChain())
{
}
-JSFunction::JSFunction(ExecState* exec, NonNullPassRefPtr<Structure> structure, int length, const Identifier& name, NativeExecutable* thunk, NativeFunction func)
- : Base(&exec->globalData(), structure, name)
+JSFunction::JSFunction(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, int length, const Identifier& name, PassRefPtr<NativeExecutable> thunk)
+ : Base(globalObject, structure)
#if ENABLE(JIT)
, m_executable(thunk)
#endif
+ , m_scopeChain(globalObject->globalScopeChain())
{
+ putDirect(exec->globalData().propertyNames->name, jsString(exec, name.isNull() ? "" : name.ustring()), DontDelete | ReadOnly | DontEnum);
#if ENABLE(JIT)
- setNativeFunction(func);
putDirect(exec->propertyNames().length, jsNumber(exec, length), DontDelete | ReadOnly | DontEnum);
#else
UNUSED_PARAM(thunk);
UNUSED_PARAM(length);
- UNUSED_PARAM(func);
ASSERT_NOT_REACHED();
#endif
}
-JSFunction::JSFunction(ExecState* exec, NonNullPassRefPtr<Structure> structure, int length, const Identifier& name, NativeFunction func)
- : Base(&exec->globalData(), structure, name)
+JSFunction::JSFunction(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, int length, const Identifier& name, NativeFunction func)
+ : Base(globalObject, structure)
#if ENABLE(JIT)
- , m_executable(exec->globalData().jitStubs.ctiNativeCallThunk())
+ , m_executable(exec->globalData().getHostFunction(func))
#endif
+ , m_scopeChain(globalObject->globalScopeChain())
{
+ putDirect(exec->globalData().propertyNames->name, jsString(exec, name.isNull() ? "" : name.ustring()), DontDelete | ReadOnly | DontEnum);
#if ENABLE(JIT)
- setNativeFunction(func);
putDirect(exec->propertyNames().length, jsNumber(exec, length), DontDelete | ReadOnly | DontEnum);
#else
UNUSED_PARAM(length);
@@ -90,10 +92,12 @@ JSFunction::JSFunction(ExecState* exec, NonNullPassRefPtr<Structure> structure,
}
JSFunction::JSFunction(ExecState* exec, NonNullPassRefPtr<FunctionExecutable> executable, ScopeChainNode* scopeChainNode)
- : Base(&exec->globalData(), exec->lexicalGlobalObject()->functionStructure(), executable->name())
+ : Base(scopeChainNode->globalObject, scopeChainNode->globalObject->functionStructure())
, m_executable(executable)
+ , m_scopeChain(scopeChainNode)
{
- setScopeChain(scopeChainNode);
+ const Identifier& name = static_cast<FunctionExecutable*>(m_executable.get())->name();
+ putDirect(exec->globalData().propertyNames->name, jsString(exec, name.isNull() ? "" : name.ustring()), DontDelete | ReadOnly | DontEnum);
}
JSFunction::~JSFunction()
@@ -111,34 +115,60 @@ JSFunction::~JSFunction()
if (jsExecutable()->isGeneratedForConstruct())
jsExecutable()->generatedBytecodeForConstruct().unlinkCallers();
#endif
- scopeChain().~ScopeChain(); // FIXME: Don't we need to do this in the interpreter too?
}
}
+const UString& JSFunction::name(ExecState* exec)
+{
+ return asString(getDirect(exec->globalData().propertyNames->name))->tryGetValue();
+}
+
+const UString JSFunction::displayName(ExecState* exec)
+{
+ JSValue displayName = getDirect(exec->globalData().propertyNames->displayName);
+
+ if (displayName && isJSString(&exec->globalData(), displayName))
+ return asString(displayName)->tryGetValue();
+
+ return UString::null();
+}
+
+const UString JSFunction::calculatedDisplayName(ExecState* exec)
+{
+ const UString explicitName = displayName(exec);
+
+ if (!explicitName.isEmpty())
+ return explicitName;
+
+ return name(exec);
+}
+
void JSFunction::markChildren(MarkStack& markStack)
{
Base::markChildren(markStack);
if (!isHostFunction()) {
jsExecutable()->markAggregate(markStack);
- scopeChain().markAggregate(markStack);
+ scope().markAggregate(markStack);
}
}
CallType JSFunction::getCallData(CallData& callData)
{
+#if ENABLE(JIT)
if (isHostFunction()) {
callData.native.function = nativeFunction();
return CallTypeHost;
}
+#endif
callData.js.functionExecutable = jsExecutable();
- callData.js.scopeChain = scopeChain().node();
+ callData.js.scopeChain = scope().node();
return CallTypeJS;
}
JSValue JSFunction::call(ExecState* exec, JSValue thisValue, const ArgList& args)
{
ASSERT(!isHostFunction());
- return exec->interpreter()->executeCall(jsExecutable(), exec, this, thisValue.toThisObject(exec), args, scopeChain().node(), exec->exceptionSlot());
+ return exec->interpreter()->executeCall(jsExecutable(), exec, this, thisValue.toThisObject(exec), args, scope().node(), exec->exceptionSlot());
}
JSValue JSFunction::argumentsGetter(ExecState* exec, JSValue slotBase, const Identifier&)
@@ -171,7 +201,7 @@ bool JSFunction::getOwnPropertySlot(ExecState* exec, const Identifier& propertyN
JSValue* location = getDirectLocation(propertyName);
if (!location) {
- JSObject* prototype = new (exec) JSObject(scopeChain().globalObject()->emptyObjectStructure());
+ JSObject* prototype = new (exec) JSObject(scope().globalObject()->emptyObjectStructure());
prototype->putDirect(exec->propertyNames().constructor, this, DontEnum);
putDirect(exec->propertyNames().prototype, prototype, DontDelete);
location = getDirectLocation(propertyName);
@@ -264,7 +294,7 @@ ConstructType JSFunction::getConstructData(ConstructData& constructData)
if (isHostFunction())
return ConstructTypeNone;
constructData.js.functionExecutable = jsExecutable();
- constructData.js.scopeChain = scopeChain().node();
+ constructData.js.scopeChain = scope().node();
return ConstructTypeJS;
}
@@ -279,7 +309,7 @@ JSObject* JSFunction::construct(ExecState* exec, const ArgList& args)
structure = exec->lexicalGlobalObject()->emptyObjectStructure();
JSObject* thisObj = new (exec) JSObject(structure);
- JSValue result = exec->interpreter()->executeConstruct(jsExecutable(), exec, this, thisObj, args, scopeChain().node(), exec->exceptionSlot());
+ JSValue result = exec->interpreter()->executeConstruct(jsExecutable(), exec, this, thisObj, args, scope().node(), exec->exceptionSlot());
if (exec->hadException() || !result.isObject())
return thisObj;
return asObject(result);
diff --git a/JavaScriptCore/runtime/JSFunction.h b/JavaScriptCore/runtime/JSFunction.h
index 301b908..acdfe0d 100644
--- a/JavaScriptCore/runtime/JSFunction.h
+++ b/JavaScriptCore/runtime/JSFunction.h
@@ -24,7 +24,7 @@
#ifndef JSFunction_h
#define JSFunction_h
-#include "InternalFunction.h"
+#include "JSObjectWithGlobalObject.h"
namespace JSC {
@@ -35,23 +35,35 @@ namespace JSC {
class JSGlobalObject;
class NativeExecutable;
- class JSFunction : public InternalFunction {
+ class JSFunction : public JSObjectWithGlobalObject {
friend class JIT;
friend class JSGlobalData;
- typedef InternalFunction Base;
+ typedef JSObjectWithGlobalObject Base;
public:
- JSFunction(ExecState*, NonNullPassRefPtr<Structure>, int length, const Identifier&, NativeFunction);
- JSFunction(ExecState*, NonNullPassRefPtr<Structure>, int length, const Identifier&, NativeExecutable*, NativeFunction);
+ JSFunction(ExecState*, JSGlobalObject*, NonNullPassRefPtr<Structure>, int length, const Identifier&, NativeFunction);
+ JSFunction(ExecState*, JSGlobalObject*, NonNullPassRefPtr<Structure>, int length, const Identifier&, PassRefPtr<NativeExecutable>);
JSFunction(ExecState*, NonNullPassRefPtr<FunctionExecutable>, ScopeChainNode*);
virtual ~JSFunction();
JSObject* construct(ExecState*, const ArgList&);
JSValue call(ExecState*, JSValue thisValue, const ArgList&);
- void setScope(const ScopeChain& scopeChain) { setScopeChain(scopeChain); }
- ScopeChain& scope() { return scopeChain(); }
+ const UString& name(ExecState*);
+ const UString displayName(ExecState*);
+ const UString calculatedDisplayName(ExecState*);
+
+ ScopeChain& scope()
+ {
+ ASSERT(!isHostFunctionNonInline());
+ return m_scopeChain;
+ }
+ void setScope(const ScopeChain& scopeChain)
+ {
+ ASSERT(!isHostFunctionNonInline());
+ m_scopeChain = scopeChain;
+ }
ExecutableBase* executable() const { return m_executable.get(); }
@@ -66,16 +78,13 @@ namespace JSC {
return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount);
}
- NativeFunction nativeFunction()
- {
- return *WTF::bitwise_cast<NativeFunction*>(m_data);
- }
+ NativeFunction nativeFunction();
virtual ConstructType getConstructData(ConstructData&);
virtual CallType getCallData(CallData&);
protected:
- const static unsigned StructureFlags = OverridesGetOwnPropertySlot | ImplementsHasInstance | OverridesMarkChildren | OverridesGetPropertyNames | InternalFunction::StructureFlags;
+ const static unsigned StructureFlags = OverridesGetOwnPropertySlot | ImplementsHasInstance | OverridesMarkChildren | OverridesGetPropertyNames | JSObject::StructureFlags;
private:
JSFunction(NonNullPassRefPtr<Structure>);
@@ -97,31 +106,7 @@ namespace JSC {
static JSValue lengthGetter(ExecState*, JSValue, const Identifier&);
RefPtr<ExecutableBase> m_executable;
- ScopeChain& scopeChain()
- {
- ASSERT(!isHostFunctionNonInline());
- return *WTF::bitwise_cast<ScopeChain*>(m_data);
- }
- void clearScopeChain()
- {
- ASSERT(!isHostFunctionNonInline());
- new (m_data) ScopeChain(NoScopeChain());
- }
- void setScopeChain(ScopeChainNode* sc)
- {
- ASSERT(!isHostFunctionNonInline());
- new (m_data) ScopeChain(sc);
- }
- void setScopeChain(const ScopeChain& sc)
- {
- ASSERT(!isHostFunctionNonInline());
- *WTF::bitwise_cast<ScopeChain*>(m_data) = sc;
- }
- void setNativeFunction(NativeFunction func)
- {
- *WTF::bitwise_cast<NativeFunction*>(m_data) = func;
- }
- unsigned char m_data[sizeof(void*)];
+ ScopeChain m_scopeChain;
};
JSFunction* asFunction(JSValue);
diff --git a/JavaScriptCore/runtime/JSGlobalData.cpp b/JavaScriptCore/runtime/JSGlobalData.cpp
index 652fcb0..3f24ea4 100644
--- a/JavaScriptCore/runtime/JSGlobalData.cpp
+++ b/JavaScriptCore/runtime/JSGlobalData.cpp
@@ -253,6 +253,17 @@ const Vector<Instruction>& JSGlobalData::numericCompareFunction(ExecState* exec)
return lazyNumericCompareFunction;
}
+#if ENABLE(JIT)
+PassRefPtr<NativeExecutable> JSGlobalData::getHostFunction(NativeFunction function)
+{
+ return jitStubs.hostFunctionStub(this, function);
+}
+PassRefPtr<NativeExecutable> JSGlobalData::getHostFunction(NativeFunction function, ThunkGenerator generator)
+{
+ return jitStubs.hostFunctionStub(this, function, generator);
+}
+#endif
+
JSGlobalData::ClientData::~ClientData()
{
}
diff --git a/JavaScriptCore/runtime/JSGlobalData.h b/JavaScriptCore/runtime/JSGlobalData.h
index 711e148..f48aec8 100644
--- a/JavaScriptCore/runtime/JSGlobalData.h
+++ b/JavaScriptCore/runtime/JSGlobalData.h
@@ -170,10 +170,12 @@ namespace JSC {
Interpreter* interpreter;
#if ENABLE(JIT)
JITThunks jitStubs;
- NativeExecutable* getThunk(ThunkGenerator generator)
+ MacroAssemblerCodePtr getCTIStub(ThunkGenerator generator)
{
- return jitStubs.specializedThunk(this, generator);
+ return jitStubs.ctiStub(this, generator);
}
+ PassRefPtr<NativeExecutable> getHostFunction(NativeFunction function);
+ PassRefPtr<NativeExecutable> getHostFunction(NativeFunction function, ThunkGenerator generator);
#endif
TimeoutChecker timeoutChecker;
Terminator terminator;
diff --git a/JavaScriptCore/runtime/JSGlobalObject.cpp b/JavaScriptCore/runtime/JSGlobalObject.cpp
index 7fd491a..fb9b3eb 100644
--- a/JavaScriptCore/runtime/JSGlobalObject.cpp
+++ b/JavaScriptCore/runtime/JSGlobalObject.cpp
@@ -203,14 +203,14 @@ void JSGlobalObject::reset(JSValue prototype)
// Prototypes
- d()->functionPrototype = new (exec) FunctionPrototype(exec, FunctionPrototype::createStructure(jsNull())); // The real prototype will be set once ObjectPrototype is created.
+ d()->functionPrototype = new (exec) FunctionPrototype(exec, this, FunctionPrototype::createStructure(jsNull())); // The real prototype will be set once ObjectPrototype is created.
d()->prototypeFunctionStructure = PrototypeFunction::createStructure(d()->functionPrototype);
NativeFunctionWrapper* callFunction = 0;
NativeFunctionWrapper* applyFunction = 0;
- d()->functionPrototype->addFunctionProperties(exec, d()->prototypeFunctionStructure.get(), &callFunction, &applyFunction);
+ d()->functionPrototype->addFunctionProperties(exec, this, d()->prototypeFunctionStructure.get(), &callFunction, &applyFunction);
d()->callFunction = callFunction;
d()->applyFunction = applyFunction;
- d()->objectPrototype = new (exec) ObjectPrototype(exec, ObjectPrototype::createStructure(jsNull()), d()->prototypeFunctionStructure.get());
+ d()->objectPrototype = new (exec) ObjectPrototype(exec, this, ObjectPrototype::createStructure(jsNull()), d()->prototypeFunctionStructure.get());
d()->functionPrototype->structure()->setPrototypeWithoutTransition(d()->objectPrototype);
d()->emptyObjectStructure = d()->objectPrototype->inheritorID();
@@ -219,63 +219,54 @@ void JSGlobalObject::reset(JSValue prototype)
d()->callbackFunctionStructure = JSCallbackFunction::createStructure(d()->functionPrototype);
d()->argumentsStructure = Arguments::createStructure(d()->objectPrototype);
d()->callbackConstructorStructure = JSCallbackConstructor::createStructure(d()->objectPrototype);
- d()->callbackObjectStructure = JSCallbackObject<JSObject>::createStructure(d()->objectPrototype);
+ d()->callbackObjectStructure = JSCallbackObject<JSObjectWithGlobalObject>::createStructure(d()->objectPrototype);
- d()->arrayPrototype = new (exec) ArrayPrototype(ArrayPrototype::createStructure(d()->objectPrototype));
+ d()->arrayPrototype = new (exec) ArrayPrototype(this, ArrayPrototype::createStructure(d()->objectPrototype));
d()->arrayStructure = JSArray::createStructure(d()->arrayPrototype);
d()->regExpMatchesArrayStructure = RegExpMatchesArray::createStructure(d()->arrayPrototype);
- d()->stringPrototype = new (exec) StringPrototype(exec, StringPrototype::createStructure(d()->objectPrototype));
+ d()->stringPrototype = new (exec) StringPrototype(exec, this, StringPrototype::createStructure(d()->objectPrototype));
d()->stringObjectStructure = StringObject::createStructure(d()->stringPrototype);
- d()->booleanPrototype = new (exec) BooleanPrototype(exec, BooleanPrototype::createStructure(d()->objectPrototype), d()->prototypeFunctionStructure.get());
+ d()->booleanPrototype = new (exec) BooleanPrototype(exec, this, BooleanPrototype::createStructure(d()->objectPrototype), d()->prototypeFunctionStructure.get());
d()->booleanObjectStructure = BooleanObject::createStructure(d()->booleanPrototype);
- d()->numberPrototype = new (exec) NumberPrototype(exec, NumberPrototype::createStructure(d()->objectPrototype), d()->prototypeFunctionStructure.get());
+ d()->numberPrototype = new (exec) NumberPrototype(exec, this, NumberPrototype::createStructure(d()->objectPrototype), d()->prototypeFunctionStructure.get());
d()->numberObjectStructure = NumberObject::createStructure(d()->numberPrototype);
- d()->datePrototype = new (exec) DatePrototype(exec, DatePrototype::createStructure(d()->objectPrototype));
+ d()->datePrototype = new (exec) DatePrototype(exec, this, DatePrototype::createStructure(d()->objectPrototype));
d()->dateStructure = DateInstance::createStructure(d()->datePrototype);
- d()->regExpPrototype = new (exec) RegExpPrototype(exec, RegExpPrototype::createStructure(d()->objectPrototype), d()->prototypeFunctionStructure.get());
+ d()->regExpPrototype = new (exec) RegExpPrototype(exec, this, RegExpPrototype::createStructure(d()->objectPrototype), d()->prototypeFunctionStructure.get());
d()->regExpStructure = RegExpObject::createStructure(d()->regExpPrototype);
d()->methodCallDummy = constructEmptyObject(exec);
- ErrorPrototype* errorPrototype = new (exec) ErrorPrototype(exec, ErrorPrototype::createStructure(d()->objectPrototype), d()->prototypeFunctionStructure.get());
+ ErrorPrototype* errorPrototype = new (exec) ErrorPrototype(exec, this, ErrorPrototype::createStructure(d()->objectPrototype), d()->prototypeFunctionStructure.get());
d()->errorStructure = ErrorInstance::createStructure(errorPrototype);
- RefPtr<Structure> nativeErrorPrototypeStructure = NativeErrorPrototype::createStructure(errorPrototype);
-
- NativeErrorPrototype* evalErrorPrototype = new (exec) NativeErrorPrototype(exec, nativeErrorPrototypeStructure, "EvalError", "EvalError");
- NativeErrorPrototype* rangeErrorPrototype = new (exec) NativeErrorPrototype(exec, nativeErrorPrototypeStructure, "RangeError", "RangeError");
- NativeErrorPrototype* referenceErrorPrototype = new (exec) NativeErrorPrototype(exec, nativeErrorPrototypeStructure, "ReferenceError", "ReferenceError");
- NativeErrorPrototype* syntaxErrorPrototype = new (exec) NativeErrorPrototype(exec, nativeErrorPrototypeStructure, "SyntaxError", "SyntaxError");
- NativeErrorPrototype* typeErrorPrototype = new (exec) NativeErrorPrototype(exec, nativeErrorPrototypeStructure, "TypeError", "TypeError");
- NativeErrorPrototype* URIErrorPrototype = new (exec) NativeErrorPrototype(exec, nativeErrorPrototypeStructure, "URIError", "URIError");
-
// Constructors
- JSCell* objectConstructor = new (exec) ObjectConstructor(exec, ObjectConstructor::createStructure(d()->functionPrototype), d()->objectPrototype, d()->prototypeFunctionStructure.get());
- JSCell* functionConstructor = new (exec) FunctionConstructor(exec, FunctionConstructor::createStructure(d()->functionPrototype), d()->functionPrototype);
- JSCell* arrayConstructor = new (exec) ArrayConstructor(exec, ArrayConstructor::createStructure(d()->functionPrototype), d()->arrayPrototype, d()->prototypeFunctionStructure.get());
- JSCell* stringConstructor = new (exec) StringConstructor(exec, StringConstructor::createStructure(d()->functionPrototype), d()->prototypeFunctionStructure.get(), d()->stringPrototype);
- JSCell* booleanConstructor = new (exec) BooleanConstructor(exec, BooleanConstructor::createStructure(d()->functionPrototype), d()->booleanPrototype);
- JSCell* numberConstructor = new (exec) NumberConstructor(exec, NumberConstructor::createStructure(d()->functionPrototype), d()->numberPrototype);
- JSCell* dateConstructor = new (exec) DateConstructor(exec, DateConstructor::createStructure(d()->functionPrototype), d()->prototypeFunctionStructure.get(), d()->datePrototype);
+ JSCell* objectConstructor = new (exec) ObjectConstructor(exec, this, ObjectConstructor::createStructure(d()->functionPrototype), d()->objectPrototype, d()->prototypeFunctionStructure.get());
+ JSCell* functionConstructor = new (exec) FunctionConstructor(exec, this, FunctionConstructor::createStructure(d()->functionPrototype), d()->functionPrototype);
+ JSCell* arrayConstructor = new (exec) ArrayConstructor(exec, this, ArrayConstructor::createStructure(d()->functionPrototype), d()->arrayPrototype, d()->prototypeFunctionStructure.get());
+ JSCell* stringConstructor = new (exec) StringConstructor(exec, this, StringConstructor::createStructure(d()->functionPrototype), d()->prototypeFunctionStructure.get(), d()->stringPrototype);
+ JSCell* booleanConstructor = new (exec) BooleanConstructor(exec, this, BooleanConstructor::createStructure(d()->functionPrototype), d()->booleanPrototype);
+ JSCell* numberConstructor = new (exec) NumberConstructor(exec, this, NumberConstructor::createStructure(d()->functionPrototype), d()->numberPrototype);
+ JSCell* dateConstructor = new (exec) DateConstructor(exec, this, DateConstructor::createStructure(d()->functionPrototype), d()->prototypeFunctionStructure.get(), d()->datePrototype);
- d()->regExpConstructor = new (exec) RegExpConstructor(exec, RegExpConstructor::createStructure(d()->functionPrototype), d()->regExpPrototype);
+ d()->regExpConstructor = new (exec) RegExpConstructor(exec, this, RegExpConstructor::createStructure(d()->functionPrototype), d()->regExpPrototype);
- d()->errorConstructor = new (exec) ErrorConstructor(exec, ErrorConstructor::createStructure(d()->functionPrototype), errorPrototype);
+ d()->errorConstructor = new (exec) ErrorConstructor(exec, this, ErrorConstructor::createStructure(d()->functionPrototype), errorPrototype);
+ RefPtr<Structure> nativeErrorPrototypeStructure = NativeErrorPrototype::createStructure(errorPrototype);
RefPtr<Structure> nativeErrorStructure = NativeErrorConstructor::createStructure(d()->functionPrototype);
-
- d()->evalErrorConstructor = new (exec) NativeErrorConstructor(exec, nativeErrorStructure, evalErrorPrototype);
- d()->rangeErrorConstructor = new (exec) NativeErrorConstructor(exec, nativeErrorStructure, rangeErrorPrototype);
- d()->referenceErrorConstructor = new (exec) NativeErrorConstructor(exec, nativeErrorStructure, referenceErrorPrototype);
- d()->syntaxErrorConstructor = new (exec) NativeErrorConstructor(exec, nativeErrorStructure, syntaxErrorPrototype);
- d()->typeErrorConstructor = new (exec) NativeErrorConstructor(exec, nativeErrorStructure, typeErrorPrototype);
- d()->URIErrorConstructor = new (exec) NativeErrorConstructor(exec, nativeErrorStructure, URIErrorPrototype);
+ d()->evalErrorConstructor = new (exec) NativeErrorConstructor(exec, this, nativeErrorStructure, nativeErrorPrototypeStructure, "EvalError");
+ d()->rangeErrorConstructor = new (exec) NativeErrorConstructor(exec, this, nativeErrorStructure, nativeErrorPrototypeStructure, "RangeError");
+ d()->referenceErrorConstructor = new (exec) NativeErrorConstructor(exec, this, nativeErrorStructure, nativeErrorPrototypeStructure, "ReferenceError");
+ d()->syntaxErrorConstructor = new (exec) NativeErrorConstructor(exec, this, nativeErrorStructure, nativeErrorPrototypeStructure, "SyntaxError");
+ d()->typeErrorConstructor = new (exec) NativeErrorConstructor(exec, this, nativeErrorStructure, nativeErrorPrototypeStructure, "TypeError");
+ d()->URIErrorConstructor = new (exec) NativeErrorConstructor(exec, this, nativeErrorStructure, nativeErrorPrototypeStructure, "URIError");
d()->objectPrototype->putDirectFunctionWithoutTransition(exec->propertyNames().constructor, objectConstructor, DontEnum);
d()->functionPrototype->putDirectFunctionWithoutTransition(exec->propertyNames().constructor, functionConstructor, DontEnum);
@@ -287,13 +278,6 @@ void JSGlobalObject::reset(JSValue prototype)
d()->regExpPrototype->putDirectFunctionWithoutTransition(exec->propertyNames().constructor, d()->regExpConstructor, DontEnum);
errorPrototype->putDirectFunctionWithoutTransition(exec->propertyNames().constructor, d()->errorConstructor, DontEnum);
- evalErrorPrototype->putDirect(exec->propertyNames().constructor, d()->evalErrorConstructor, DontEnum);
- rangeErrorPrototype->putDirect(exec->propertyNames().constructor, d()->rangeErrorConstructor, DontEnum);
- referenceErrorPrototype->putDirect(exec->propertyNames().constructor, d()->referenceErrorConstructor, DontEnum);
- syntaxErrorPrototype->putDirect(exec->propertyNames().constructor, d()->syntaxErrorConstructor, DontEnum);
- typeErrorPrototype->putDirect(exec->propertyNames().constructor, d()->typeErrorConstructor, DontEnum);
- URIErrorPrototype->putDirect(exec->propertyNames().constructor, d()->URIErrorConstructor, DontEnum);
-
// Set global constructors
// FIXME: These properties could be handled by a static hash table.
@@ -316,31 +300,31 @@ void JSGlobalObject::reset(JSValue prototype)
// Set global values.
GlobalPropertyInfo staticGlobals[] = {
- GlobalPropertyInfo(Identifier(exec, "Math"), new (exec) MathObject(exec, MathObject::createStructure(d()->objectPrototype)), DontEnum | DontDelete),
+ GlobalPropertyInfo(Identifier(exec, "Math"), new (exec) MathObject(exec, this, MathObject::createStructure(d()->objectPrototype)), DontEnum | DontDelete),
GlobalPropertyInfo(Identifier(exec, "NaN"), jsNaN(exec), DontEnum | DontDelete | ReadOnly),
GlobalPropertyInfo(Identifier(exec, "Infinity"), jsNumber(exec, Inf), DontEnum | DontDelete | ReadOnly),
GlobalPropertyInfo(Identifier(exec, "undefined"), jsUndefined(), DontEnum | DontDelete | ReadOnly),
- GlobalPropertyInfo(Identifier(exec, "JSON"), new (exec) JSONObject(JSONObject::createStructure(d()->objectPrototype)), DontEnum | DontDelete)
+ GlobalPropertyInfo(Identifier(exec, "JSON"), new (exec) JSONObject(this, JSONObject::createStructure(d()->objectPrototype)), DontEnum | DontDelete)
};
addStaticGlobals(staticGlobals, sizeof(staticGlobals) / sizeof(GlobalPropertyInfo));
// Set global functions.
- d()->evalFunction = new (exec) GlobalEvalFunction(exec, GlobalEvalFunction::createStructure(d()->functionPrototype), 1, exec->propertyNames().eval, globalFuncEval, this);
+ d()->evalFunction = new (exec) GlobalEvalFunction(exec, this, GlobalEvalFunction::createStructure(d()->functionPrototype), 1, exec->propertyNames().eval, globalFuncEval, this);
putDirectFunctionWithoutTransition(exec, d()->evalFunction, DontEnum);
- putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, d()->prototypeFunctionStructure.get(), 2, Identifier(exec, "parseInt"), globalFuncParseInt), DontEnum);
- putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "parseFloat"), globalFuncParseFloat), DontEnum);
- putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "isNaN"), globalFuncIsNaN), DontEnum);
- putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "isFinite"), globalFuncIsFinite), DontEnum);
- putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "escape"), globalFuncEscape), DontEnum);
- putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "unescape"), globalFuncUnescape), DontEnum);
- putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "decodeURI"), globalFuncDecodeURI), DontEnum);
- putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "decodeURIComponent"), globalFuncDecodeURIComponent), DontEnum);
- putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "encodeURI"), globalFuncEncodeURI), DontEnum);
- putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "encodeURIComponent"), globalFuncEncodeURIComponent), DontEnum);
+ putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, this, d()->prototypeFunctionStructure.get(), 2, Identifier(exec, "parseInt"), globalFuncParseInt), DontEnum);
+ putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, this, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "parseFloat"), globalFuncParseFloat), DontEnum);
+ putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, this, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "isNaN"), globalFuncIsNaN), DontEnum);
+ putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, this, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "isFinite"), globalFuncIsFinite), DontEnum);
+ putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, this, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "escape"), globalFuncEscape), DontEnum);
+ putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, this, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "unescape"), globalFuncUnescape), DontEnum);
+ putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, this, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "decodeURI"), globalFuncDecodeURI), DontEnum);
+ putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, this, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "decodeURIComponent"), globalFuncDecodeURIComponent), DontEnum);
+ putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, this, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "encodeURI"), globalFuncEncodeURI), DontEnum);
+ putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, this, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "encodeURIComponent"), globalFuncEncodeURIComponent), DontEnum);
#ifndef NDEBUG
- putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "jscprint"), globalFuncJSCPrint), DontEnum);
+ putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, this, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "jscprint"), globalFuncJSCPrint), DontEnum);
#endif
resetPrototype(prototype);
diff --git a/JavaScriptCore/runtime/JSGlobalObject.h b/JavaScriptCore/runtime/JSGlobalObject.h
index e38dc79..09a92a1 100644
--- a/JavaScriptCore/runtime/JSGlobalObject.h
+++ b/JavaScriptCore/runtime/JSGlobalObject.h
@@ -160,10 +160,20 @@ namespace JSC {
public:
void* operator new(size_t, JSGlobalData*);
-
+
explicit JSGlobalObject()
: JSVariableObject(JSGlobalObject::createStructure(jsNull()), new JSGlobalObjectData(destroyJSGlobalObjectData))
{
+ COMPILE_ASSERT(JSGlobalObject::AnonymousSlotCount == 1, JSGlobalObject_has_only_a_single_slot);
+ putAnonymousValue(0, this);
+ init(this);
+ }
+
+ explicit JSGlobalObject(NonNullPassRefPtr<Structure> structure)
+ : JSVariableObject(structure, new JSGlobalObjectData(destroyJSGlobalObjectData))
+ {
+ COMPILE_ASSERT(JSGlobalObject::AnonymousSlotCount == 1, JSGlobalObject_has_only_a_single_slot);
+ putAnonymousValue(0, this);
init(this);
}
@@ -171,6 +181,8 @@ namespace JSC {
JSGlobalObject(NonNullPassRefPtr<Structure> structure, JSGlobalObjectData* data, JSObject* thisValue)
: JSVariableObject(structure, data)
{
+ COMPILE_ASSERT(JSGlobalObject::AnonymousSlotCount == 1, JSGlobalObject_has_only_a_single_slot);
+ putAnonymousValue(0, this);
init(thisValue);
}
@@ -285,6 +297,7 @@ namespace JSC {
protected:
+ static const unsigned AnonymousSlotCount = JSVariableObject::AnonymousSlotCount + 1;
static const unsigned StructureFlags = OverridesGetOwnPropertySlot | OverridesMarkChildren | OverridesGetPropertyNames | JSVariableObject::StructureFlags;
struct GlobalPropertyInfo {
diff --git a/JavaScriptCore/runtime/JSONObject.cpp b/JavaScriptCore/runtime/JSONObject.cpp
index f6c6b5f..bd0e25f 100644
--- a/JavaScriptCore/runtime/JSONObject.cpp
+++ b/JavaScriptCore/runtime/JSONObject.cpp
@@ -30,6 +30,7 @@
#include "Error.h"
#include "ExceptionHelpers.h"
#include "JSArray.h"
+#include "JSGlobalObject.h"
#include "LiteralParser.h"
#include "Lookup.h"
#include "PropertyNameArray.h"
@@ -49,6 +50,11 @@ static JSValue JSC_HOST_CALL JSONProtoFuncStringify(ExecState*, JSObject*, JSVal
namespace JSC {
+JSONObject::JSONObject(JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure)
+ : JSObjectWithGlobalObject(globalObject, structure)
+{
+}
+
// PropertyNameForFunctionCall objects must be on the stack, since the JSValue that they create is not marked.
class PropertyNameForFunctionCall {
public:
diff --git a/JavaScriptCore/runtime/JSONObject.h b/JavaScriptCore/runtime/JSONObject.h
index 7a9e0a4..f64be12 100644
--- a/JavaScriptCore/runtime/JSONObject.h
+++ b/JavaScriptCore/runtime/JSONObject.h
@@ -26,18 +26,15 @@
#ifndef JSONObject_h
#define JSONObject_h
-#include "JSObject.h"
+#include "JSObjectWithGlobalObject.h"
namespace JSC {
class Stringifier;
- class JSONObject : public JSObject {
+ class JSONObject : public JSObjectWithGlobalObject {
public:
- JSONObject(NonNullPassRefPtr<Structure> structure)
- : JSObject(structure)
- {
- }
+ JSONObject(JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure);
static PassRefPtr<Structure> createStructure(JSValue prototype)
{
diff --git a/JavaScriptCore/runtime/JSObject.cpp b/JavaScriptCore/runtime/JSObject.cpp
index 61d3bb1..3ac8a34 100644
--- a/JavaScriptCore/runtime/JSObject.cpp
+++ b/JavaScriptCore/runtime/JSObject.cpp
@@ -27,6 +27,7 @@
#include "DatePrototype.h"
#include "ErrorConstructor.h"
#include "GetterSetter.h"
+#include "JSFunction.h"
#include "JSGlobalObject.h"
#include "NativeErrorConstructor.h"
#include "ObjectPrototype.h"
@@ -509,11 +510,21 @@ void JSObject::putDirectFunction(ExecState* exec, InternalFunction* function, un
putDirectFunction(Identifier(exec, function->name(exec)), function, attr);
}
+void JSObject::putDirectFunction(ExecState* exec, JSFunction* function, unsigned attr)
+{
+ putDirectFunction(Identifier(exec, function->name(exec)), function, attr);
+}
+
void JSObject::putDirectFunctionWithoutTransition(ExecState* exec, InternalFunction* function, unsigned attr)
{
putDirectFunctionWithoutTransition(Identifier(exec, function->name(exec)), function, attr);
}
+void JSObject::putDirectFunctionWithoutTransition(ExecState* exec, JSFunction* function, unsigned attr)
+{
+ putDirectFunctionWithoutTransition(Identifier(exec, function->name(exec)), function, attr);
+}
+
NEVER_INLINE void JSObject::fillGetterPropertySlot(PropertySlot& slot, JSValue* location)
{
if (JSObject* getterFunction = asGetterSetter(*location)->getter()) {
diff --git a/JavaScriptCore/runtime/JSObject.h b/JavaScriptCore/runtime/JSObject.h
index 64a1118..e942ad0 100644
--- a/JavaScriptCore/runtime/JSObject.h
+++ b/JavaScriptCore/runtime/JSObject.h
@@ -74,6 +74,7 @@ namespace JSC {
friend class BatchedTransitionOptimizer;
friend class JIT;
friend class JSCell;
+ friend void setUpStaticFunctionSlot(ExecState* exec, const HashEntry* entry, JSObject* thisObj, const Identifier& propertyName, PropertySlot& slot);
public:
explicit JSObject(NonNullPassRefPtr<Structure>);
@@ -176,10 +177,12 @@ namespace JSC {
void putDirectFunction(const Identifier& propertyName, JSCell* value, unsigned attr = 0);
void putDirectFunction(const Identifier& propertyName, JSCell* value, unsigned attr, bool checkReadOnly, PutPropertySlot& slot);
void putDirectFunction(ExecState* exec, InternalFunction* function, unsigned attr = 0);
+ void putDirectFunction(ExecState* exec, JSFunction* function, unsigned attr = 0);
void putDirectWithoutTransition(const Identifier& propertyName, JSValue value, unsigned attr = 0);
void putDirectFunctionWithoutTransition(const Identifier& propertyName, JSCell* value, unsigned attr = 0);
void putDirectFunctionWithoutTransition(ExecState* exec, InternalFunction* function, unsigned attr = 0);
+ void putDirectFunctionWithoutTransition(ExecState* exec, JSFunction* function, unsigned attr = 0);
// Fast access to known property offsets.
JSValue getDirectOffset(size_t offset) const { return JSValue::decode(propertyStorage()[offset]); }
@@ -217,9 +220,6 @@ namespace JSC {
m_structure->flattenDictionaryStructure(this);
}
- protected:
- static const unsigned StructureFlags = 0;
-
void putAnonymousValue(unsigned index, JSValue value)
{
ASSERT(index < m_structure->anonymousSlotCount());
@@ -230,7 +230,10 @@ namespace JSC {
ASSERT(index < m_structure->anonymousSlotCount());
return *locationForOffset(index);
}
-
+
+ protected:
+ static const unsigned StructureFlags = 0;
+
private:
// Nobody should ever ask any of these questions on something already known to be a JSObject.
using JSCell::isAPIValueWrapper;
diff --git a/JavaScriptCore/runtime/JSObjectWithGlobalObject.cpp b/JavaScriptCore/runtime/JSObjectWithGlobalObject.cpp
new file mode 100644
index 0000000..e9d6c96
--- /dev/null
+++ b/JavaScriptCore/runtime/JSObjectWithGlobalObject.cpp
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "JSObjectWithGlobalObject.h"
+
+#include "JSGlobalObject.h"
+
+namespace JSC {
+
+JSObjectWithGlobalObject::JSObjectWithGlobalObject(JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure)
+ : JSObject(structure)
+{
+ COMPILE_ASSERT(AnonymousSlotCount == 1, AnonymousSlotCount_must_be_one);
+ ASSERT(!globalObject || globalObject->isGlobalObject());
+ putAnonymousValue(GlobalObjectSlot, globalObject);
+}
+
+JSGlobalObject* JSObjectWithGlobalObject::globalObject() const
+{
+ return asGlobalObject((getAnonymousValue(GlobalObjectSlot).asCell()));
+}
+
+} // namespace JSC
diff --git a/JavaScriptCore/runtime/JSObjectWithGlobalObject.h b/JavaScriptCore/runtime/JSObjectWithGlobalObject.h
new file mode 100644
index 0000000..9416a62
--- /dev/null
+++ b/JavaScriptCore/runtime/JSObjectWithGlobalObject.h
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef JSObjectWithGlobalObject_h
+#define JSObjectWithGlobalObject_h
+
+#include "JSObject.h"
+
+namespace JSC {
+
+class JSGlobalObject;
+
+class JSObjectWithGlobalObject : public JSObject {
+public:
+ static PassRefPtr<Structure> createStructure(JSValue proto)
+ {
+ return Structure::create(proto, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount);
+ }
+
+ JSGlobalObject* globalObject() const;
+
+protected:
+ JSObjectWithGlobalObject(JSGlobalObject*, NonNullPassRefPtr<Structure>);
+
+ JSObjectWithGlobalObject(NonNullPassRefPtr<Structure> structure)
+ : JSObject(structure)
+ {
+ // Should only be used by JSFunction when we aquire the JSFunction vptr.
+ }
+ static const unsigned AnonymousSlotCount = JSObject::AnonymousSlotCount + 1;
+ static const unsigned GlobalObjectSlot = 0;
+};
+
+} // namespace JSC
+
+#endif // JSObjectWithGlobalObject_h
diff --git a/JavaScriptCore/runtime/JSString.cpp b/JavaScriptCore/runtime/JSString.cpp
index df67133..473eb77 100644
--- a/JavaScriptCore/runtime/JSString.cpp
+++ b/JavaScriptCore/runtime/JSString.cpp
@@ -57,7 +57,8 @@ void JSString::resolveRope(ExecState* exec) const
m_fiberCount = 0;
ASSERT(!isRope());
ASSERT(m_value == UString());
- throwOutOfMemoryError(exec);
+ if (exec)
+ throwOutOfMemoryError(exec);
return;
}
UChar* position = buffer + m_length;
diff --git a/JavaScriptCore/runtime/JSString.h b/JavaScriptCore/runtime/JSString.h
index 5001b01..dec925d 100644
--- a/JavaScriptCore/runtime/JSString.h
+++ b/JavaScriptCore/runtime/JSString.h
@@ -327,11 +327,10 @@ namespace JSC {
resolveRope(exec);
return m_value;
}
- const UString tryGetValue() const
+ const UString& tryGetValue() const
{
- // If this is a rope, m_value should be null -
- // if this is not a rope, m_value should be non-null.
- ASSERT(isRope() == m_value.isNull());
+ if (isRope())
+ resolveRope(0);
return m_value;
}
unsigned length() { return m_length; }
@@ -498,7 +497,7 @@ namespace JSC {
if (isRope())
return getIndexSlowCase(exec, i);
ASSERT(i < m_value.size());
- return jsSingleCharacterSubstring(exec, value(exec), i);
+ return jsSingleCharacterSubstring(exec, m_value, i);
}
inline JSString* jsString(JSGlobalData* globalData, const UString& s)
diff --git a/JavaScriptCore/runtime/JSValue.cpp b/JavaScriptCore/runtime/JSValue.cpp
index 502312c..3a2d713 100644
--- a/JavaScriptCore/runtime/JSValue.cpp
+++ b/JavaScriptCore/runtime/JSValue.cpp
@@ -181,4 +181,9 @@ NEVER_INLINE double nonInlineNaN()
#endif
}
+bool JSValue::isValidCallee()
+{
+ return asObject(asObject(asCell())->getAnonymousValue(0))->isGlobalObject();
+}
+
} // namespace JSC
diff --git a/JavaScriptCore/runtime/JSValue.h b/JavaScriptCore/runtime/JSValue.h
index bcf82ee..914e2d5 100644
--- a/JavaScriptCore/runtime/JSValue.h
+++ b/JavaScriptCore/runtime/JSValue.h
@@ -203,6 +203,7 @@ namespace JSC {
bool isCell() const;
JSCell* asCell() const;
+ bool isValidCallee();
#ifndef NDEBUG
char* description();
diff --git a/JavaScriptCore/runtime/Lookup.cpp b/JavaScriptCore/runtime/Lookup.cpp
index 0042e4d..57d4f0c 100644
--- a/JavaScriptCore/runtime/Lookup.cpp
+++ b/JavaScriptCore/runtime/Lookup.cpp
@@ -20,6 +20,7 @@
#include "config.h"
#include "Lookup.h"
+#include "Executable.h"
#include "JSFunction.h"
#include "PrototypeFunction.h"
@@ -70,17 +71,20 @@ void HashTable::deleteTable() const
void setUpStaticFunctionSlot(ExecState* exec, const HashEntry* entry, JSObject* thisObj, const Identifier& propertyName, PropertySlot& slot)
{
+ ASSERT(thisObj->structure()->anonymousSlotCount() > 0);
+ ASSERT(thisObj->getAnonymousValue(0).isCell() && asObject(thisObj->getAnonymousValue(0).asCell())->isGlobalObject());
ASSERT(entry->attributes() & Function);
JSValue* location = thisObj->getDirectLocation(propertyName);
if (!location) {
- InternalFunction* function;
+ NativeFunctionWrapper* function;
+ JSGlobalObject* globalObject = asGlobalObject(thisObj->getAnonymousValue(0).asCell());
#if ENABLE(JIT)
if (entry->generator())
- function = new (exec) NativeFunctionWrapper(exec, exec->lexicalGlobalObject()->prototypeFunctionStructure(), entry->functionLength(), propertyName, exec->globalData().getThunk(entry->generator()), entry->function());
+ function = new (exec) NativeFunctionWrapper(exec, globalObject, globalObject->prototypeFunctionStructure(), entry->functionLength(), propertyName, exec->globalData().getHostFunction(entry->function(), entry->generator()));
else
#endif
- function = new (exec) NativeFunctionWrapper(exec, exec->lexicalGlobalObject()->prototypeFunctionStructure(), entry->functionLength(), propertyName, entry->function());
+ function = new (exec) NativeFunctionWrapper(exec, globalObject, globalObject->prototypeFunctionStructure(), entry->functionLength(), propertyName, entry->function());
thisObj->putDirectFunction(propertyName, function, entry->attributes());
location = thisObj->getDirectLocation(propertyName);
diff --git a/JavaScriptCore/runtime/MathObject.cpp b/JavaScriptCore/runtime/MathObject.cpp
index 1e28dfa..be249e5 100644
--- a/JavaScriptCore/runtime/MathObject.cpp
+++ b/JavaScriptCore/runtime/MathObject.cpp
@@ -86,8 +86,8 @@ const ClassInfo MathObject::info = { "Math", 0, 0, ExecState::mathTable };
@end
*/
-MathObject::MathObject(ExecState* exec, NonNullPassRefPtr<Structure> structure)
- : JSObject(structure)
+MathObject::MathObject(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure)
+ : JSObjectWithGlobalObject(globalObject, structure)
{
putDirectWithoutTransition(Identifier(exec, "E"), jsNumber(exec, exp(1.0)), DontDelete | DontEnum | ReadOnly);
putDirectWithoutTransition(Identifier(exec, "LN2"), jsNumber(exec, log(2.0)), DontDelete | DontEnum | ReadOnly);
diff --git a/JavaScriptCore/runtime/MathObject.h b/JavaScriptCore/runtime/MathObject.h
index a9f7031..31fa2fe 100644
--- a/JavaScriptCore/runtime/MathObject.h
+++ b/JavaScriptCore/runtime/MathObject.h
@@ -21,13 +21,13 @@
#ifndef MathObject_h
#define MathObject_h
-#include "JSObject.h"
+#include "JSObjectWithGlobalObject.h"
namespace JSC {
- class MathObject : public JSObject {
+ class MathObject : public JSObjectWithGlobalObject {
public:
- MathObject(ExecState*, NonNullPassRefPtr<Structure>);
+ MathObject(ExecState*, JSGlobalObject*, NonNullPassRefPtr<Structure>);
virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
virtual bool getOwnPropertyDescriptor(ExecState*, const Identifier&, PropertyDescriptor&);
diff --git a/JavaScriptCore/runtime/NativeErrorConstructor.cpp b/JavaScriptCore/runtime/NativeErrorConstructor.cpp
index 403fc7e..0fa2218 100644
--- a/JavaScriptCore/runtime/NativeErrorConstructor.cpp
+++ b/JavaScriptCore/runtime/NativeErrorConstructor.cpp
@@ -32,14 +32,17 @@ ASSERT_CLASS_FITS_IN_CELL(NativeErrorConstructor);
const ClassInfo NativeErrorConstructor::info = { "Function", &InternalFunction::info, 0, 0 };
-NativeErrorConstructor::NativeErrorConstructor(ExecState* exec, NonNullPassRefPtr<Structure> structure, NativeErrorPrototype* nativeErrorPrototype)
- : InternalFunction(&exec->globalData(), structure, Identifier(exec, nativeErrorPrototype->getDirect(exec->propertyNames().name).getString(exec)))
- , m_errorStructure(ErrorInstance::createStructure(nativeErrorPrototype))
+NativeErrorConstructor::NativeErrorConstructor(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, NonNullPassRefPtr<Structure> prototypeStructure, const UString& nameAndMessage)
+ : InternalFunction(&exec->globalData(), globalObject, structure, Identifier(exec, nameAndMessage))
{
+ NativeErrorPrototype* prototype = new (exec) NativeErrorPrototype(exec, globalObject, prototypeStructure, nameAndMessage, this);
+
putDirect(exec->propertyNames().length, jsNumber(exec, 1), DontDelete | ReadOnly | DontEnum); // ECMA 15.11.7.5
- putDirect(exec->propertyNames().prototype, nativeErrorPrototype, DontDelete | ReadOnly | DontEnum);
+ putDirect(exec->propertyNames().prototype, prototype, DontDelete | ReadOnly | DontEnum);
+ m_errorStructure = ErrorInstance::createStructure(prototype);
}
+
ErrorInstance* NativeErrorConstructor::construct(ExecState* exec, const ArgList& args)
{
ErrorInstance* object = new (exec) ErrorInstance(m_errorStructure);
diff --git a/JavaScriptCore/runtime/NativeErrorConstructor.h b/JavaScriptCore/runtime/NativeErrorConstructor.h
index 152dbac..0153309 100644
--- a/JavaScriptCore/runtime/NativeErrorConstructor.h
+++ b/JavaScriptCore/runtime/NativeErrorConstructor.h
@@ -31,7 +31,7 @@ namespace JSC {
class NativeErrorConstructor : public InternalFunction {
public:
- NativeErrorConstructor(ExecState*, NonNullPassRefPtr<Structure>, NativeErrorPrototype*);
+ NativeErrorConstructor(ExecState*, JSGlobalObject*, NonNullPassRefPtr<Structure> structure, NonNullPassRefPtr<Structure> prototypeStructure, const UString&);
static const ClassInfo info;
diff --git a/JavaScriptCore/runtime/NativeErrorPrototype.cpp b/JavaScriptCore/runtime/NativeErrorPrototype.cpp
index aa46a6a..540220a 100644
--- a/JavaScriptCore/runtime/NativeErrorPrototype.cpp
+++ b/JavaScriptCore/runtime/NativeErrorPrototype.cpp
@@ -22,18 +22,21 @@
#include "NativeErrorPrototype.h"
#include "ErrorPrototype.h"
+#include "JSGlobalObject.h"
#include "JSString.h"
+#include "NativeErrorConstructor.h"
#include "UString.h"
namespace JSC {
ASSERT_CLASS_FITS_IN_CELL(NativeErrorPrototype);
-NativeErrorPrototype::NativeErrorPrototype(ExecState* exec, NonNullPassRefPtr<Structure> structure, const UString& name, const UString& message)
- : JSObject(structure)
+NativeErrorPrototype::NativeErrorPrototype(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, const UString& nameAndMessage, NativeErrorConstructor* constructor)
+ : JSObjectWithGlobalObject(globalObject, structure)
{
- putDirect(exec->propertyNames().name, jsString(exec, name), 0);
- putDirect(exec->propertyNames().message, jsString(exec, message), 0);
+ putDirect(exec->propertyNames().name, jsString(exec, nameAndMessage), 0);
+ putDirect(exec->propertyNames().message, jsString(exec, nameAndMessage), 0);
+ putDirect(exec->propertyNames().constructor, constructor, DontEnum);
}
} // namespace JSC
diff --git a/JavaScriptCore/runtime/NativeErrorPrototype.h b/JavaScriptCore/runtime/NativeErrorPrototype.h
index 0c65a9c..30690d5 100644
--- a/JavaScriptCore/runtime/NativeErrorPrototype.h
+++ b/JavaScriptCore/runtime/NativeErrorPrototype.h
@@ -21,13 +21,14 @@
#ifndef NativeErrorPrototype_h
#define NativeErrorPrototype_h
-#include "JSObject.h"
+#include "JSObjectWithGlobalObject.h"
namespace JSC {
+ class NativeErrorConstructor;
- class NativeErrorPrototype : public JSObject {
+ class NativeErrorPrototype : public JSObjectWithGlobalObject {
public:
- NativeErrorPrototype(ExecState*, NonNullPassRefPtr<Structure>, const UString& name, const UString& message);
+ NativeErrorPrototype(ExecState*, JSGlobalObject*, NonNullPassRefPtr<Structure>, const UString&, NativeErrorConstructor*);
};
} // namespace JSC
diff --git a/JavaScriptCore/runtime/NumberConstructor.cpp b/JavaScriptCore/runtime/NumberConstructor.cpp
index 0b7e821..482e87b 100644
--- a/JavaScriptCore/runtime/NumberConstructor.cpp
+++ b/JavaScriptCore/runtime/NumberConstructor.cpp
@@ -54,8 +54,8 @@ const ClassInfo NumberConstructor::info = { "Function", &InternalFunction::info,
@end
*/
-NumberConstructor::NumberConstructor(ExecState* exec, NonNullPassRefPtr<Structure> structure, NumberPrototype* numberPrototype)
- : InternalFunction(&exec->globalData(), structure, Identifier(exec, numberPrototype->info.className))
+NumberConstructor::NumberConstructor(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, NumberPrototype* numberPrototype)
+ : InternalFunction(&exec->globalData(), globalObject, structure, Identifier(exec, numberPrototype->info.className))
{
// Number.Prototype
putDirectWithoutTransition(exec->propertyNames().prototype, numberPrototype, DontEnum | DontDelete | ReadOnly);
diff --git a/JavaScriptCore/runtime/NumberConstructor.h b/JavaScriptCore/runtime/NumberConstructor.h
index 723c4b2..d8a2593 100644
--- a/JavaScriptCore/runtime/NumberConstructor.h
+++ b/JavaScriptCore/runtime/NumberConstructor.h
@@ -29,7 +29,7 @@ namespace JSC {
class NumberConstructor : public InternalFunction {
public:
- NumberConstructor(ExecState*, NonNullPassRefPtr<Structure>, NumberPrototype*);
+ NumberConstructor(ExecState*, JSGlobalObject*, NonNullPassRefPtr<Structure>, NumberPrototype*);
virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
virtual bool getOwnPropertyDescriptor(ExecState*, const Identifier&, PropertyDescriptor&);
diff --git a/JavaScriptCore/runtime/NumberPrototype.cpp b/JavaScriptCore/runtime/NumberPrototype.cpp
index 7326b9d..efed90b 100644
--- a/JavaScriptCore/runtime/NumberPrototype.cpp
+++ b/JavaScriptCore/runtime/NumberPrototype.cpp
@@ -47,19 +47,19 @@ static JSValue JSC_HOST_CALL numberProtoFuncToPrecision(ExecState*, JSObject*, J
// ECMA 15.7.4
-NumberPrototype::NumberPrototype(ExecState* exec, NonNullPassRefPtr<Structure> structure, Structure* prototypeFunctionStructure)
+NumberPrototype::NumberPrototype(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, Structure* prototypeFunctionStructure)
: NumberObject(structure)
{
setInternalValue(jsNumber(exec, 0));
// The constructor will be added later, after NumberConstructor has been constructed
- putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 1, exec->propertyNames().toString, numberProtoFuncToString), DontEnum);
- putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 0, exec->propertyNames().toLocaleString, numberProtoFuncToLocaleString), DontEnum);
- putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 0, exec->propertyNames().valueOf, numberProtoFuncValueOf), DontEnum);
- putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 1, exec->propertyNames().toFixed, numberProtoFuncToFixed), DontEnum);
- putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 1, exec->propertyNames().toExponential, numberProtoFuncToExponential), DontEnum);
- putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 1, exec->propertyNames().toPrecision, numberProtoFuncToPrecision), DontEnum);
+ putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 1, exec->propertyNames().toString, numberProtoFuncToString), DontEnum);
+ putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 0, exec->propertyNames().toLocaleString, numberProtoFuncToLocaleString), DontEnum);
+ putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 0, exec->propertyNames().valueOf, numberProtoFuncValueOf), DontEnum);
+ putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 1, exec->propertyNames().toFixed, numberProtoFuncToFixed), DontEnum);
+ putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 1, exec->propertyNames().toExponential, numberProtoFuncToExponential), DontEnum);
+ putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 1, exec->propertyNames().toPrecision, numberProtoFuncToPrecision), DontEnum);
}
// ------------------------------ Functions ---------------------------
diff --git a/JavaScriptCore/runtime/NumberPrototype.h b/JavaScriptCore/runtime/NumberPrototype.h
index 1fb2077..78b690e 100644
--- a/JavaScriptCore/runtime/NumberPrototype.h
+++ b/JavaScriptCore/runtime/NumberPrototype.h
@@ -27,7 +27,7 @@ namespace JSC {
class NumberPrototype : public NumberObject {
public:
- NumberPrototype(ExecState*, NonNullPassRefPtr<Structure>, Structure* prototypeFunctionStructure);
+ NumberPrototype(ExecState*, JSGlobalObject*, NonNullPassRefPtr<Structure>, Structure* prototypeFunctionStructure);
};
} // namespace JSC
diff --git a/JavaScriptCore/runtime/ObjectConstructor.cpp b/JavaScriptCore/runtime/ObjectConstructor.cpp
index 0838eb4..fe98df3 100644
--- a/JavaScriptCore/runtime/ObjectConstructor.cpp
+++ b/JavaScriptCore/runtime/ObjectConstructor.cpp
@@ -42,8 +42,8 @@ static JSValue JSC_HOST_CALL objectConstructorDefineProperty(ExecState*, JSObjec
static JSValue JSC_HOST_CALL objectConstructorDefineProperties(ExecState*, JSObject*, JSValue, const ArgList&);
static JSValue JSC_HOST_CALL objectConstructorCreate(ExecState*, JSObject*, JSValue, const ArgList&);
-ObjectConstructor::ObjectConstructor(ExecState* exec, NonNullPassRefPtr<Structure> structure, ObjectPrototype* objectPrototype, Structure* prototypeFunctionStructure)
-: InternalFunction(&exec->globalData(), structure, Identifier(exec, "Object"))
+ObjectConstructor::ObjectConstructor(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, ObjectPrototype* objectPrototype, Structure* prototypeFunctionStructure)
+: InternalFunction(&exec->globalData(), globalObject, structure, Identifier(exec, "Object"))
{
// ECMA 15.2.3.1
putDirectWithoutTransition(exec->propertyNames().prototype, objectPrototype, DontEnum | DontDelete | ReadOnly);
@@ -51,13 +51,13 @@ ObjectConstructor::ObjectConstructor(ExecState* exec, NonNullPassRefPtr<Structur
// no. of arguments for constructor
putDirectWithoutTransition(exec->propertyNames().length, jsNumber(exec, 1), ReadOnly | DontEnum | DontDelete);
- putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 1, exec->propertyNames().getPrototypeOf, objectConstructorGetPrototypeOf), DontEnum);
- putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 2, exec->propertyNames().getOwnPropertyDescriptor, objectConstructorGetOwnPropertyDescriptor), DontEnum);
- putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 1, exec->propertyNames().getOwnPropertyNames, objectConstructorGetOwnPropertyNames), DontEnum);
- putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 1, exec->propertyNames().keys, objectConstructorKeys), DontEnum);
- putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 3, exec->propertyNames().defineProperty, objectConstructorDefineProperty), DontEnum);
- putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 2, exec->propertyNames().defineProperties, objectConstructorDefineProperties), DontEnum);
- putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 2, exec->propertyNames().create, objectConstructorCreate), DontEnum);
+ putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 1, exec->propertyNames().getPrototypeOf, objectConstructorGetPrototypeOf), DontEnum);
+ putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 2, exec->propertyNames().getOwnPropertyDescriptor, objectConstructorGetOwnPropertyDescriptor), DontEnum);
+ putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 1, exec->propertyNames().getOwnPropertyNames, objectConstructorGetOwnPropertyNames), DontEnum);
+ putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 1, exec->propertyNames().keys, objectConstructorKeys), DontEnum);
+ putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 3, exec->propertyNames().defineProperty, objectConstructorDefineProperty), DontEnum);
+ putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 2, exec->propertyNames().defineProperties, objectConstructorDefineProperties), DontEnum);
+ putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 2, exec->propertyNames().create, objectConstructorCreate), DontEnum);
}
// ECMA 15.2.2
diff --git a/JavaScriptCore/runtime/ObjectConstructor.h b/JavaScriptCore/runtime/ObjectConstructor.h
index 1d2cdde..04a3c1a 100644
--- a/JavaScriptCore/runtime/ObjectConstructor.h
+++ b/JavaScriptCore/runtime/ObjectConstructor.h
@@ -29,7 +29,7 @@ namespace JSC {
class ObjectConstructor : public InternalFunction {
public:
- ObjectConstructor(ExecState*, NonNullPassRefPtr<Structure>, ObjectPrototype*, Structure* prototypeFunctionStructure);
+ ObjectConstructor(ExecState*, JSGlobalObject*, NonNullPassRefPtr<Structure>, ObjectPrototype*, Structure* prototypeFunctionStructure);
private:
virtual ConstructType getConstructData(ConstructData&);
diff --git a/JavaScriptCore/runtime/ObjectPrototype.cpp b/JavaScriptCore/runtime/ObjectPrototype.cpp
index c32a007..97601f3 100644
--- a/JavaScriptCore/runtime/ObjectPrototype.cpp
+++ b/JavaScriptCore/runtime/ObjectPrototype.cpp
@@ -41,22 +41,22 @@ static JSValue JSC_HOST_CALL objectProtoFuncLookupSetter(ExecState*, JSObject*,
static JSValue JSC_HOST_CALL objectProtoFuncPropertyIsEnumerable(ExecState*, JSObject*, JSValue, const ArgList&);
static JSValue JSC_HOST_CALL objectProtoFuncToLocaleString(ExecState*, JSObject*, JSValue, const ArgList&);
-ObjectPrototype::ObjectPrototype(ExecState* exec, NonNullPassRefPtr<Structure> stucture, Structure* prototypeFunctionStructure)
+ObjectPrototype::ObjectPrototype(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> stucture, Structure* prototypeFunctionStructure)
: JSObject(stucture)
, m_hasNoPropertiesWithUInt32Names(true)
{
- putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 0, exec->propertyNames().toString, objectProtoFuncToString), DontEnum);
- putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 0, exec->propertyNames().toLocaleString, objectProtoFuncToLocaleString), DontEnum);
- putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 0, exec->propertyNames().valueOf, objectProtoFuncValueOf), DontEnum);
- putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 1, exec->propertyNames().hasOwnProperty, objectProtoFuncHasOwnProperty), DontEnum);
- putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 1, exec->propertyNames().propertyIsEnumerable, objectProtoFuncPropertyIsEnumerable), DontEnum);
- putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 1, exec->propertyNames().isPrototypeOf, objectProtoFuncIsPrototypeOf), DontEnum);
+ putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 0, exec->propertyNames().toString, objectProtoFuncToString), DontEnum);
+ putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 0, exec->propertyNames().toLocaleString, objectProtoFuncToLocaleString), DontEnum);
+ putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 0, exec->propertyNames().valueOf, objectProtoFuncValueOf), DontEnum);
+ putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 1, exec->propertyNames().hasOwnProperty, objectProtoFuncHasOwnProperty), DontEnum);
+ putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 1, exec->propertyNames().propertyIsEnumerable, objectProtoFuncPropertyIsEnumerable), DontEnum);
+ putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 1, exec->propertyNames().isPrototypeOf, objectProtoFuncIsPrototypeOf), DontEnum);
// Mozilla extensions
- putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 2, exec->propertyNames().__defineGetter__, objectProtoFuncDefineGetter), DontEnum);
- putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 2, exec->propertyNames().__defineSetter__, objectProtoFuncDefineSetter), DontEnum);
- putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 1, exec->propertyNames().__lookupGetter__, objectProtoFuncLookupGetter), DontEnum);
- putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 1, exec->propertyNames().__lookupSetter__, objectProtoFuncLookupSetter), DontEnum);
+ putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 2, exec->propertyNames().__defineGetter__, objectProtoFuncDefineGetter), DontEnum);
+ putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 2, exec->propertyNames().__defineSetter__, objectProtoFuncDefineSetter), DontEnum);
+ putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 1, exec->propertyNames().__lookupGetter__, objectProtoFuncLookupGetter), DontEnum);
+ putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 1, exec->propertyNames().__lookupSetter__, objectProtoFuncLookupSetter), DontEnum);
}
void ObjectPrototype::put(ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot)
diff --git a/JavaScriptCore/runtime/ObjectPrototype.h b/JavaScriptCore/runtime/ObjectPrototype.h
index 489d962..47065d7 100644
--- a/JavaScriptCore/runtime/ObjectPrototype.h
+++ b/JavaScriptCore/runtime/ObjectPrototype.h
@@ -27,7 +27,7 @@ namespace JSC {
class ObjectPrototype : public JSObject {
public:
- ObjectPrototype(ExecState*, NonNullPassRefPtr<Structure>, Structure* prototypeFunctionStructure);
+ ObjectPrototype(ExecState*, JSGlobalObject*, NonNullPassRefPtr<Structure>, Structure* prototypeFunctionStructure);
private:
virtual void put(ExecState*, const Identifier&, JSValue, PutPropertySlot&);
diff --git a/JavaScriptCore/runtime/PrototypeFunction.cpp b/JavaScriptCore/runtime/PrototypeFunction.cpp
index 38f8adb..b0bf2bd 100644
--- a/JavaScriptCore/runtime/PrototypeFunction.cpp
+++ b/JavaScriptCore/runtime/PrototypeFunction.cpp
@@ -32,16 +32,16 @@ namespace JSC {
ASSERT_CLASS_FITS_IN_CELL(PrototypeFunction);
-PrototypeFunction::PrototypeFunction(ExecState* exec, int length, const Identifier& name, NativeFunction function)
- : InternalFunction(&exec->globalData(), exec->lexicalGlobalObject()->prototypeFunctionStructure(), name)
+PrototypeFunction::PrototypeFunction(ExecState* exec, JSGlobalObject* globalObject, int length, const Identifier& name, NativeFunction function)
+ : InternalFunction(&exec->globalData(), globalObject, exec->lexicalGlobalObject()->prototypeFunctionStructure(), name)
, m_function(function)
{
ASSERT_ARG(function, function);
putDirect(exec->propertyNames().length, jsNumber(exec, length), DontDelete | ReadOnly | DontEnum);
}
-PrototypeFunction::PrototypeFunction(ExecState* exec, NonNullPassRefPtr<Structure> prototypeFunctionStructure, int length, const Identifier& name, NativeFunction function)
- : InternalFunction(&exec->globalData(), prototypeFunctionStructure, name)
+PrototypeFunction::PrototypeFunction(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> prototypeFunctionStructure, int length, const Identifier& name, NativeFunction function)
+ : InternalFunction(&exec->globalData(), globalObject, prototypeFunctionStructure, name)
, m_function(function)
{
ASSERT_ARG(function, function);
diff --git a/JavaScriptCore/runtime/PrototypeFunction.h b/JavaScriptCore/runtime/PrototypeFunction.h
index 70ee034..6ca2342 100644
--- a/JavaScriptCore/runtime/PrototypeFunction.h
+++ b/JavaScriptCore/runtime/PrototypeFunction.h
@@ -31,8 +31,8 @@ namespace JSC {
class PrototypeFunction : public InternalFunction {
public:
- PrototypeFunction(ExecState*, int length, const Identifier&, NativeFunction);
- PrototypeFunction(ExecState*, NonNullPassRefPtr<Structure>, int length, const Identifier&, NativeFunction);
+ PrototypeFunction(ExecState*, JSGlobalObject*, int length, const Identifier&, NativeFunction);
+ PrototypeFunction(ExecState*, JSGlobalObject*, NonNullPassRefPtr<Structure>, int length, const Identifier&, NativeFunction);
private:
virtual CallType getCallData(CallData&);
diff --git a/JavaScriptCore/runtime/RegExpConstructor.cpp b/JavaScriptCore/runtime/RegExpConstructor.cpp
index 3a67ae6..e7e6109 100644
--- a/JavaScriptCore/runtime/RegExpConstructor.cpp
+++ b/JavaScriptCore/runtime/RegExpConstructor.cpp
@@ -91,8 +91,8 @@ const ClassInfo RegExpConstructor::info = { "Function", &InternalFunction::info,
@end
*/
-RegExpConstructor::RegExpConstructor(ExecState* exec, NonNullPassRefPtr<Structure> structure, RegExpPrototype* regExpPrototype)
- : InternalFunction(&exec->globalData(), structure, Identifier(exec, "RegExp"))
+RegExpConstructor::RegExpConstructor(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, RegExpPrototype* regExpPrototype)
+ : InternalFunction(&exec->globalData(), globalObject, structure, Identifier(exec, "RegExp"))
, d(new RegExpConstructorPrivate)
{
// ECMA 15.10.5.1 RegExp.prototype
@@ -304,7 +304,7 @@ JSObject* constructRegExp(ExecState* exec, const ArgList& args)
RefPtr<RegExp> regExp = RegExp::create(&exec->globalData(), pattern, flags);
if (!regExp->isValid())
return throwError(exec, SyntaxError, makeString("Invalid regular expression: ", regExp->errorMessage()));
- return new (exec) RegExpObject(exec->lexicalGlobalObject()->regExpStructure(), regExp.release());
+ return new (exec) RegExpObject(exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->regExpStructure(), regExp.release());
}
static JSObject* constructWithRegExpConstructor(ExecState* exec, JSObject*, const ArgList& args)
diff --git a/JavaScriptCore/runtime/RegExpConstructor.h b/JavaScriptCore/runtime/RegExpConstructor.h
index bb0671a..58abde5 100644
--- a/JavaScriptCore/runtime/RegExpConstructor.h
+++ b/JavaScriptCore/runtime/RegExpConstructor.h
@@ -55,7 +55,7 @@ namespace JSC {
class RegExpConstructor : public InternalFunction {
public:
- RegExpConstructor(ExecState*, NonNullPassRefPtr<Structure>, RegExpPrototype*);
+ RegExpConstructor(ExecState*, JSGlobalObject*, NonNullPassRefPtr<Structure>, RegExpPrototype*);
static PassRefPtr<Structure> createStructure(JSValue prototype)
{
diff --git a/JavaScriptCore/runtime/RegExpObject.cpp b/JavaScriptCore/runtime/RegExpObject.cpp
index bc74924..b04b55e 100644
--- a/JavaScriptCore/runtime/RegExpObject.cpp
+++ b/JavaScriptCore/runtime/RegExpObject.cpp
@@ -58,8 +58,8 @@ const ClassInfo RegExpObject::info = { "RegExp", 0, 0, ExecState::regExpTable };
@end
*/
-RegExpObject::RegExpObject(NonNullPassRefPtr<Structure> structure, NonNullPassRefPtr<RegExp> regExp)
- : JSObject(structure)
+RegExpObject::RegExpObject(JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, NonNullPassRefPtr<RegExp> regExp)
+ : JSObjectWithGlobalObject(globalObject, structure)
, d(new RegExpObjectData(regExp, 0))
{
}
diff --git a/JavaScriptCore/runtime/RegExpObject.h b/JavaScriptCore/runtime/RegExpObject.h
index 4ad11ef..3324e53 100644
--- a/JavaScriptCore/runtime/RegExpObject.h
+++ b/JavaScriptCore/runtime/RegExpObject.h
@@ -21,14 +21,14 @@
#ifndef RegExpObject_h
#define RegExpObject_h
-#include "JSObject.h"
+#include "JSObjectWithGlobalObject.h"
#include "RegExp.h"
namespace JSC {
- class RegExpObject : public JSObject {
+ class RegExpObject : public JSObjectWithGlobalObject {
public:
- RegExpObject(NonNullPassRefPtr<Structure>, NonNullPassRefPtr<RegExp>);
+ RegExpObject(JSGlobalObject* globalObject, NonNullPassRefPtr<Structure>, NonNullPassRefPtr<RegExp>);
virtual ~RegExpObject();
void setRegExp(PassRefPtr<RegExp> r) { d->regExp = r; }
@@ -53,8 +53,8 @@ namespace JSC {
}
protected:
- static const unsigned StructureFlags = OverridesGetOwnPropertySlot | JSObject::StructureFlags;
-
+ static const unsigned StructureFlags = OverridesGetOwnPropertySlot | JSObjectWithGlobalObject::StructureFlags;
+
private:
bool match(ExecState*, const ArgList&);
diff --git a/JavaScriptCore/runtime/RegExpPrototype.cpp b/JavaScriptCore/runtime/RegExpPrototype.cpp
index dd5fe02..9ebf105 100644
--- a/JavaScriptCore/runtime/RegExpPrototype.cpp
+++ b/JavaScriptCore/runtime/RegExpPrototype.cpp
@@ -47,13 +47,13 @@ static JSValue JSC_HOST_CALL regExpProtoFuncToString(ExecState*, JSObject*, JSVa
const ClassInfo RegExpPrototype::info = { "RegExpPrototype", 0, 0, 0 };
-RegExpPrototype::RegExpPrototype(ExecState* exec, NonNullPassRefPtr<Structure> structure, Structure* prototypeFunctionStructure)
+RegExpPrototype::RegExpPrototype(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, Structure* prototypeFunctionStructure)
: JSObject(structure)
{
- putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 0, exec->propertyNames().compile, regExpProtoFuncCompile), DontEnum);
- putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 0, exec->propertyNames().exec, regExpProtoFuncExec), DontEnum);
- putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 0, exec->propertyNames().test, regExpProtoFuncTest), DontEnum);
- putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 0, exec->propertyNames().toString, regExpProtoFuncToString), DontEnum);
+ putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 0, exec->propertyNames().compile, regExpProtoFuncCompile), DontEnum);
+ putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 0, exec->propertyNames().exec, regExpProtoFuncExec), DontEnum);
+ putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 0, exec->propertyNames().test, regExpProtoFuncTest), DontEnum);
+ putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 0, exec->propertyNames().toString, regExpProtoFuncToString), DontEnum);
}
// ------------------------------ Functions ---------------------------
diff --git a/JavaScriptCore/runtime/RegExpPrototype.h b/JavaScriptCore/runtime/RegExpPrototype.h
index d3979bd..77c1ea7 100644
--- a/JavaScriptCore/runtime/RegExpPrototype.h
+++ b/JavaScriptCore/runtime/RegExpPrototype.h
@@ -27,7 +27,7 @@ namespace JSC {
class RegExpPrototype : public JSObject {
public:
- RegExpPrototype(ExecState*, NonNullPassRefPtr<Structure>, Structure* prototypeFunctionStructure);
+ RegExpPrototype(ExecState*, JSGlobalObject*, NonNullPassRefPtr<Structure>, Structure* prototypeFunctionStructure);
virtual const ClassInfo* classInfo() const { return &info; }
static const ClassInfo info;
diff --git a/JavaScriptCore/runtime/StringConstructor.cpp b/JavaScriptCore/runtime/StringConstructor.cpp
index 42f98c3..b5c46b6 100644
--- a/JavaScriptCore/runtime/StringConstructor.cpp
+++ b/JavaScriptCore/runtime/StringConstructor.cpp
@@ -21,6 +21,8 @@
#include "config.h"
#include "StringConstructor.h"
+#include "Executable.h"
+#include "JITCode.h"
#include "JSFunction.h"
#include "JSGlobalObject.h"
#include "PrototypeFunction.h"
@@ -47,17 +49,17 @@ static JSValue JSC_HOST_CALL stringFromCharCode(ExecState* exec, JSObject*, JSVa
ASSERT_CLASS_FITS_IN_CELL(StringConstructor);
-StringConstructor::StringConstructor(ExecState* exec, NonNullPassRefPtr<Structure> structure, Structure* prototypeFunctionStructure, StringPrototype* stringPrototype)
- : InternalFunction(&exec->globalData(), structure, Identifier(exec, stringPrototype->classInfo()->className))
+StringConstructor::StringConstructor(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, Structure* prototypeFunctionStructure, StringPrototype* stringPrototype)
+ : InternalFunction(&exec->globalData(), globalObject, structure, Identifier(exec, stringPrototype->classInfo()->className))
{
// ECMA 15.5.3.1 String.prototype
putDirectWithoutTransition(exec->propertyNames().prototype, stringPrototype, ReadOnly | DontEnum | DontDelete);
// ECMA 15.5.3.2 fromCharCode()
#if ENABLE(JIT)
- putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 1, exec->propertyNames().fromCharCode, exec->globalData().getThunk(fromCharCodeThunkGenerator), stringFromCharCode), DontEnum);
+ putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 1, exec->propertyNames().fromCharCode, exec->globalData().getHostFunction(stringFromCharCode, fromCharCodeThunkGenerator)), DontEnum);
#else
- putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 1, exec->propertyNames().fromCharCode, stringFromCharCode), DontEnum);
+ putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 1, exec->propertyNames().fromCharCode, stringFromCharCode), DontEnum);
#endif
// no. of arguments for constructor
putDirectWithoutTransition(exec->propertyNames().length, jsNumber(exec, 1), ReadOnly | DontEnum | DontDelete);
diff --git a/JavaScriptCore/runtime/StringConstructor.h b/JavaScriptCore/runtime/StringConstructor.h
index e511f7b..20f3a52 100644
--- a/JavaScriptCore/runtime/StringConstructor.h
+++ b/JavaScriptCore/runtime/StringConstructor.h
@@ -29,7 +29,7 @@ namespace JSC {
class StringConstructor : public InternalFunction {
public:
- StringConstructor(ExecState*, NonNullPassRefPtr<Structure>, Structure* prototypeFunctionStructure, StringPrototype*);
+ StringConstructor(ExecState*, JSGlobalObject*, NonNullPassRefPtr<Structure>, Structure* prototypeFunctionStructure, StringPrototype*);
virtual ConstructType getConstructData(ConstructData&);
virtual CallType getCallData(CallData&);
diff --git a/JavaScriptCore/runtime/StringPrototype.cpp b/JavaScriptCore/runtime/StringPrototype.cpp
index b385e70..9df3dbb 100644
--- a/JavaScriptCore/runtime/StringPrototype.cpp
+++ b/JavaScriptCore/runtime/StringPrototype.cpp
@@ -132,9 +132,10 @@ const ClassInfo StringPrototype::info = { "String", &StringObject::info, 0, Exec
*/
// ECMA 15.5.4
-StringPrototype::StringPrototype(ExecState* exec, NonNullPassRefPtr<Structure> structure)
+StringPrototype::StringPrototype(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure)
: StringObject(exec, structure)
{
+ putAnonymousValue(0, globalObject);
// The constructor will be added later, after StringConstructor has been built
putDirectWithoutTransition(exec->propertyNames().length, jsNumber(exec, 0), DontDelete | ReadOnly | DontEnum);
}
@@ -301,6 +302,8 @@ JSValue JSC_HOST_CALL stringProtoFuncReplace(ExecState* exec, JSObject*, JSValue
if (pattern.inherits(&RegExpObject::info)) {
const UString& source = sourceVal->value(exec);
+ if (exec->hadException())
+ return JSValue();
RegExp* reg = asRegExpObject(pattern)->regExp();
bool global = reg->global();
diff --git a/JavaScriptCore/runtime/StringPrototype.h b/JavaScriptCore/runtime/StringPrototype.h
index 3a6a2a3..4b0f88f 100644
--- a/JavaScriptCore/runtime/StringPrototype.h
+++ b/JavaScriptCore/runtime/StringPrototype.h
@@ -29,7 +29,7 @@ namespace JSC {
class StringPrototype : public StringObject {
public:
- StringPrototype(ExecState*, NonNullPassRefPtr<Structure>);
+ StringPrototype(ExecState*, JSGlobalObject*, NonNullPassRefPtr<Structure>);
virtual bool getOwnPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&);
virtual bool getOwnPropertyDescriptor(ExecState*, const Identifier&, PropertyDescriptor&);
diff --git a/JavaScriptCore/runtime/UString.cpp b/JavaScriptCore/runtime/UString.cpp
index 6b16274..bdc896d 100644
--- a/JavaScriptCore/runtime/UString.cpp
+++ b/JavaScriptCore/runtime/UString.cpp
@@ -60,6 +60,8 @@ extern const double Inf;
// The null string is immutable, except for refCount.
UString* UString::s_nullUString;
+COMPILE_ASSERT(sizeof(UString) == sizeof(void*), UString_should_stay_small);
+
void initializeUString()
{
// UStringImpl::empty() does not construct its static string in a threadsafe fashion,
diff --git a/JavaScriptCore/wtf/CurrentTime.cpp b/JavaScriptCore/wtf/CurrentTime.cpp
index 08fffa2..56724cb 100644
--- a/JavaScriptCore/wtf/CurrentTime.cpp
+++ b/JavaScriptCore/wtf/CurrentTime.cpp
@@ -163,7 +163,6 @@ double currentTime()
// QueryPerformanceCounter has high resolution, but is only usable to measure time intervals.
// To combine them, we call ftime and QueryPerformanceCounter initially. Later calls will use QueryPerformanceCounter
// by itself, adding the delta to the saved ftime. We periodically re-sync to correct for drift.
- static bool started;
static double syncLowResUTCTime;
static double syncHighResUpTime;
static double lastUTCTime;
diff --git a/JavaScriptCore/wtf/ListHashSet.h b/JavaScriptCore/wtf/ListHashSet.h
index 54ed36b..09355ad 100644
--- a/JavaScriptCore/wtf/ListHashSet.h
+++ b/JavaScriptCore/wtf/ListHashSet.h
@@ -37,27 +37,27 @@ namespace WTF {
// and an append that moves the element to the end even if already present,
// but unclear yet if these are needed.
- template<typename Value, typename HashFunctions> class ListHashSet;
+ template<typename Value, size_t inlineCapacity, typename HashFunctions> class ListHashSet;
template<typename T> struct IdentityExtractor;
- template<typename Value, typename HashFunctions>
- void deleteAllValues(const ListHashSet<Value, HashFunctions>&);
+ template<typename Value, size_t inlineCapacity, typename HashFunctions>
+ void deleteAllValues(const ListHashSet<Value, inlineCapacity, HashFunctions>&);
- template<typename ValueArg, typename HashArg> class ListHashSetIterator;
- template<typename ValueArg, typename HashArg> class ListHashSetConstIterator;
+ template<typename ValueArg, size_t inlineCapacity, typename HashArg> class ListHashSetIterator;
+ template<typename ValueArg, size_t inlineCapacity, typename HashArg> class ListHashSetConstIterator;
- template<typename ValueArg> struct ListHashSetNode;
- template<typename ValueArg> struct ListHashSetNodeAllocator;
- template<typename ValueArg, typename HashArg> struct ListHashSetNodeHashFunctions;
+ template<typename ValueArg, size_t inlineCapacity> struct ListHashSetNode;
+ template<typename ValueArg, size_t inlineCapacity> struct ListHashSetNodeAllocator;
+ template<typename ValueArg, size_t inlineCapacity, typename HashArg> struct ListHashSetNodeHashFunctions;
- template<typename ValueArg, typename HashArg = typename DefaultHash<ValueArg>::Hash> class ListHashSet : public FastAllocBase {
+ template<typename ValueArg, size_t inlineCapacity = 256, typename HashArg = typename DefaultHash<ValueArg>::Hash> class ListHashSet : public FastAllocBase {
private:
- typedef ListHashSetNode<ValueArg> Node;
- typedef ListHashSetNodeAllocator<ValueArg> NodeAllocator;
+ typedef ListHashSetNode<ValueArg, inlineCapacity> Node;
+ typedef ListHashSetNodeAllocator<ValueArg, inlineCapacity> NodeAllocator;
typedef HashTraits<Node*> NodeTraits;
- typedef ListHashSetNodeHashFunctions<ValueArg, HashArg> NodeHash;
+ typedef ListHashSetNodeHashFunctions<ValueArg, inlineCapacity, HashArg> NodeHash;
typedef HashTable<Node*, Node*, IdentityExtractor<Node*>, NodeHash, NodeTraits, NodeTraits> ImplType;
typedef HashTableIterator<Node*, Node*, IdentityExtractor<Node*>, NodeHash, NodeTraits, NodeTraits> ImplTypeIterator;
@@ -67,10 +67,10 @@ namespace WTF {
public:
typedef ValueArg ValueType;
- typedef ListHashSetIterator<ValueType, HashArg> iterator;
- typedef ListHashSetConstIterator<ValueType, HashArg> const_iterator;
+ typedef ListHashSetIterator<ValueType, inlineCapacity, HashArg> iterator;
+ typedef ListHashSetConstIterator<ValueType, inlineCapacity, HashArg> const_iterator;
- friend class ListHashSetConstIterator<ValueType, HashArg>;
+ friend class ListHashSetConstIterator<ValueType, inlineCapacity, HashArg>;
ListHashSet();
ListHashSet(const ListHashSet&);
@@ -119,9 +119,9 @@ namespace WTF {
OwnPtr<NodeAllocator> m_allocator;
};
- template<typename ValueArg> struct ListHashSetNodeAllocator {
- typedef ListHashSetNode<ValueArg> Node;
- typedef ListHashSetNodeAllocator<ValueArg> NodeAllocator;
+ template<typename ValueArg, size_t inlineCapacity> struct ListHashSetNodeAllocator {
+ typedef ListHashSetNode<ValueArg, inlineCapacity> Node;
+ typedef ListHashSetNodeAllocator<ValueArg, inlineCapacity> NodeAllocator;
ListHashSetNodeAllocator()
: m_freeList(pool())
@@ -181,15 +181,15 @@ namespace WTF {
Node* m_freeList;
bool m_isDoneWithInitialFreeList;
- static const size_t m_poolSize = 256;
+ static const size_t m_poolSize = inlineCapacity;
union {
char pool[sizeof(Node) * m_poolSize];
double forAlignment;
} m_pool;
};
- template<typename ValueArg> struct ListHashSetNode {
- typedef ListHashSetNodeAllocator<ValueArg> NodeAllocator;
+ template<typename ValueArg, size_t inlineCapacity> struct ListHashSetNode {
+ typedef ListHashSetNodeAllocator<ValueArg, inlineCapacity> NodeAllocator;
ListHashSetNode(ValueArg value)
: m_value(value)
@@ -220,25 +220,25 @@ namespace WTF {
#endif
};
- template<typename ValueArg, typename HashArg> struct ListHashSetNodeHashFunctions {
- typedef ListHashSetNode<ValueArg> Node;
+ template<typename ValueArg, size_t inlineCapacity, typename HashArg> struct ListHashSetNodeHashFunctions {
+ typedef ListHashSetNode<ValueArg, inlineCapacity> Node;
static unsigned hash(Node* const& key) { return HashArg::hash(key->m_value); }
static bool equal(Node* const& a, Node* const& b) { return HashArg::equal(a->m_value, b->m_value); }
static const bool safeToCompareToEmptyOrDeleted = false;
};
- template<typename ValueArg, typename HashArg> class ListHashSetIterator {
+ template<typename ValueArg, size_t inlineCapacity, typename HashArg> class ListHashSetIterator {
private:
- typedef ListHashSet<ValueArg, HashArg> ListHashSetType;
- typedef ListHashSetIterator<ValueArg, HashArg> iterator;
- typedef ListHashSetConstIterator<ValueArg, HashArg> const_iterator;
- typedef ListHashSetNode<ValueArg> Node;
+ typedef ListHashSet<ValueArg, inlineCapacity, HashArg> ListHashSetType;
+ typedef ListHashSetIterator<ValueArg, inlineCapacity, HashArg> iterator;
+ typedef ListHashSetConstIterator<ValueArg, inlineCapacity, HashArg> const_iterator;
+ typedef ListHashSetNode<ValueArg, inlineCapacity> Node;
typedef ValueArg ValueType;
typedef ValueType& ReferenceType;
typedef ValueType* PointerType;
- friend class ListHashSet<ValueArg, HashArg>;
+ friend class ListHashSet<ValueArg, inlineCapacity, HashArg>;
ListHashSetIterator(const ListHashSetType* set, Node* position) : m_iterator(set, position) { }
@@ -271,18 +271,18 @@ namespace WTF {
const_iterator m_iterator;
};
- template<typename ValueArg, typename HashArg> class ListHashSetConstIterator {
+ template<typename ValueArg, size_t inlineCapacity, typename HashArg> class ListHashSetConstIterator {
private:
- typedef ListHashSet<ValueArg, HashArg> ListHashSetType;
- typedef ListHashSetIterator<ValueArg, HashArg> iterator;
- typedef ListHashSetConstIterator<ValueArg, HashArg> const_iterator;
- typedef ListHashSetNode<ValueArg> Node;
+ typedef ListHashSet<ValueArg, inlineCapacity, HashArg> ListHashSetType;
+ typedef ListHashSetIterator<ValueArg, inlineCapacity, HashArg> iterator;
+ typedef ListHashSetConstIterator<ValueArg, inlineCapacity, HashArg> const_iterator;
+ typedef ListHashSetNode<ValueArg, inlineCapacity> Node;
typedef ValueArg ValueType;
typedef const ValueType& ReferenceType;
typedef const ValueType* PointerType;
- friend class ListHashSet<ValueArg, HashArg>;
- friend class ListHashSetIterator<ValueArg, HashArg>;
+ friend class ListHashSet<ValueArg, inlineCapacity, HashArg>;
+ friend class ListHashSetIterator<ValueArg, inlineCapacity, HashArg>;
ListHashSetConstIterator(const ListHashSetType* set, Node* position)
: m_set(set)
@@ -341,11 +341,11 @@ namespace WTF {
};
- template<typename ValueType, typename HashFunctions>
+ template<typename ValueType, size_t inlineCapacity, typename HashFunctions>
struct ListHashSetTranslator {
private:
- typedef ListHashSetNode<ValueType> Node;
- typedef ListHashSetNodeAllocator<ValueType> NodeAllocator;
+ typedef ListHashSetNode<ValueType, inlineCapacity> Node;
+ typedef ListHashSetNodeAllocator<ValueType, inlineCapacity> NodeAllocator;
public:
static unsigned hash(const ValueType& key) { return HashFunctions::hash(key); }
static bool equal(Node* const& a, const ValueType& b) { return HashFunctions::equal(a->m_value, b); }
@@ -355,16 +355,16 @@ namespace WTF {
}
};
- template<typename T, typename U>
- inline ListHashSet<T, U>::ListHashSet()
+ template<typename T, size_t inlineCapacity, typename U>
+ inline ListHashSet<T, inlineCapacity, U>::ListHashSet()
: m_head(0)
, m_tail(0)
, m_allocator(new NodeAllocator)
{
}
- template<typename T, typename U>
- inline ListHashSet<T, U>::ListHashSet(const ListHashSet& other)
+ template<typename T, size_t inlineCapacity, typename U>
+ inline ListHashSet<T, inlineCapacity, U>::ListHashSet(const ListHashSet& other)
: m_head(0)
, m_tail(0)
, m_allocator(new NodeAllocator)
@@ -374,16 +374,16 @@ namespace WTF {
add(*it);
}
- template<typename T, typename U>
- inline ListHashSet<T, U>& ListHashSet<T, U>::operator=(const ListHashSet& other)
+ template<typename T, size_t inlineCapacity, typename U>
+ inline ListHashSet<T, inlineCapacity, U>& ListHashSet<T, inlineCapacity, U>::operator=(const ListHashSet& other)
{
ListHashSet tmp(other);
swap(tmp);
return *this;
}
- template<typename T, typename U>
- inline void ListHashSet<T, U>::swap(ListHashSet& other)
+ template<typename T, size_t inlineCapacity, typename U>
+ inline void ListHashSet<T, inlineCapacity, U>::swap(ListHashSet& other)
{
m_impl.swap(other.m_impl);
std::swap(m_head, other.m_head);
@@ -391,95 +391,95 @@ namespace WTF {
m_allocator.swap(other.m_allocator);
}
- template<typename T, typename U>
- inline ListHashSet<T, U>::~ListHashSet()
+ template<typename T, size_t inlineCapacity, typename U>
+ inline ListHashSet<T, inlineCapacity, U>::~ListHashSet()
{
deleteAllNodes();
}
- template<typename T, typename U>
- inline int ListHashSet<T, U>::size() const
+ template<typename T, size_t inlineCapacity, typename U>
+ inline int ListHashSet<T, inlineCapacity, U>::size() const
{
return m_impl.size();
}
- template<typename T, typename U>
- inline int ListHashSet<T, U>::capacity() const
+ template<typename T, size_t inlineCapacity, typename U>
+ inline int ListHashSet<T, inlineCapacity, U>::capacity() const
{
return m_impl.capacity();
}
- template<typename T, typename U>
- inline bool ListHashSet<T, U>::isEmpty() const
+ template<typename T, size_t inlineCapacity, typename U>
+ inline bool ListHashSet<T, inlineCapacity, U>::isEmpty() const
{
return m_impl.isEmpty();
}
- template<typename T, typename U>
- inline typename ListHashSet<T, U>::iterator ListHashSet<T, U>::begin()
+ template<typename T, size_t inlineCapacity, typename U>
+ inline typename ListHashSet<T, inlineCapacity, U>::iterator ListHashSet<T, inlineCapacity, U>::begin()
{
return makeIterator(m_head);
}
- template<typename T, typename U>
- inline typename ListHashSet<T, U>::iterator ListHashSet<T, U>::end()
+ template<typename T, size_t inlineCapacity, typename U>
+ inline typename ListHashSet<T, inlineCapacity, U>::iterator ListHashSet<T, inlineCapacity, U>::end()
{
return makeIterator(0);
}
- template<typename T, typename U>
- inline typename ListHashSet<T, U>::const_iterator ListHashSet<T, U>::begin() const
+ template<typename T, size_t inlineCapacity, typename U>
+ inline typename ListHashSet<T, inlineCapacity, U>::const_iterator ListHashSet<T, inlineCapacity, U>::begin() const
{
return makeConstIterator(m_head);
}
- template<typename T, typename U>
- inline typename ListHashSet<T, U>::const_iterator ListHashSet<T, U>::end() const
+ template<typename T, size_t inlineCapacity, typename U>
+ inline typename ListHashSet<T, inlineCapacity, U>::const_iterator ListHashSet<T, inlineCapacity, U>::end() const
{
return makeConstIterator(0);
}
- template<typename T, typename U>
- inline typename ListHashSet<T, U>::iterator ListHashSet<T, U>::find(const ValueType& value)
+ template<typename T, size_t inlineCapacity, typename U>
+ inline typename ListHashSet<T, inlineCapacity, U>::iterator ListHashSet<T, inlineCapacity, U>::find(const ValueType& value)
{
- typedef ListHashSetTranslator<ValueType, HashFunctions> Translator;
+ typedef ListHashSetTranslator<ValueType, inlineCapacity, HashFunctions> Translator;
ImplTypeIterator it = m_impl.template find<ValueType, Translator>(value);
if (it == m_impl.end())
return end();
return makeIterator(*it);
}
- template<typename T, typename U>
- inline typename ListHashSet<T, U>::const_iterator ListHashSet<T, U>::find(const ValueType& value) const
+ template<typename T, size_t inlineCapacity, typename U>
+ inline typename ListHashSet<T, inlineCapacity, U>::const_iterator ListHashSet<T, inlineCapacity, U>::find(const ValueType& value) const
{
- typedef ListHashSetTranslator<ValueType, HashFunctions> Translator;
+ typedef ListHashSetTranslator<ValueType, inlineCapacity, HashFunctions> Translator;
ImplTypeConstIterator it = m_impl.template find<ValueType, Translator>(value);
if (it == m_impl.end())
return end();
return makeConstIterator(*it);
}
- template<typename T, typename U>
- inline bool ListHashSet<T, U>::contains(const ValueType& value) const
+ template<typename T, size_t inlineCapacity, typename U>
+ inline bool ListHashSet<T, inlineCapacity, U>::contains(const ValueType& value) const
{
- typedef ListHashSetTranslator<ValueType, HashFunctions> Translator;
+ typedef ListHashSetTranslator<ValueType, inlineCapacity, HashFunctions> Translator;
return m_impl.template contains<ValueType, Translator>(value);
}
- template<typename T, typename U>
- pair<typename ListHashSet<T, U>::iterator, bool> ListHashSet<T, U>::add(const ValueType &value)
+ template<typename T, size_t inlineCapacity, typename U>
+ pair<typename ListHashSet<T, inlineCapacity, U>::iterator, bool> ListHashSet<T, inlineCapacity, U>::add(const ValueType &value)
{
- typedef ListHashSetTranslator<ValueType, HashFunctions> Translator;
+ typedef ListHashSetTranslator<ValueType, inlineCapacity, HashFunctions> Translator;
pair<typename ImplType::iterator, bool> result = m_impl.template add<ValueType, NodeAllocator*, Translator>(value, m_allocator.get());
if (result.second)
appendNode(*result.first);
return std::make_pair(makeIterator(*result.first), result.second);
}
- template<typename T, typename U>
- pair<typename ListHashSet<T, U>::iterator, bool> ListHashSet<T, U>::insertBefore(iterator it, const ValueType& newValue)
+ template<typename T, size_t inlineCapacity, typename U>
+ pair<typename ListHashSet<T, inlineCapacity, U>::iterator, bool> ListHashSet<T, inlineCapacity, U>::insertBefore(iterator it, const ValueType& newValue)
{
- typedef ListHashSetTranslator<ValueType, HashFunctions> Translator;
+ typedef ListHashSetTranslator<ValueType, inlineCapacity, HashFunctions> Translator;
pair<typename ImplType::iterator, bool> result = m_impl.template add<ValueType, NodeAllocator*, Translator>(newValue, m_allocator.get());
if (result.second)
insertNodeBefore(it.node(), *result.first);
@@ -487,14 +487,14 @@ namespace WTF {
}
- template<typename T, typename U>
- pair<typename ListHashSet<T, U>::iterator, bool> ListHashSet<T, U>::insertBefore(const ValueType& beforeValue, const ValueType& newValue)
+ template<typename T, size_t inlineCapacity, typename U>
+ pair<typename ListHashSet<T, inlineCapacity, U>::iterator, bool> ListHashSet<T, inlineCapacity, U>::insertBefore(const ValueType& beforeValue, const ValueType& newValue)
{
return insertBefore(find(beforeValue), newValue);
}
- template<typename T, typename U>
- inline void ListHashSet<T, U>::remove(iterator it)
+ template<typename T, size_t inlineCapacity, typename U>
+ inline void ListHashSet<T, inlineCapacity, U>::remove(iterator it)
{
if (it == end())
return;
@@ -502,14 +502,14 @@ namespace WTF {
unlinkAndDelete(it.node());
}
- template<typename T, typename U>
- inline void ListHashSet<T, U>::remove(const ValueType& value)
+ template<typename T, size_t inlineCapacity, typename U>
+ inline void ListHashSet<T, inlineCapacity, U>::remove(const ValueType& value)
{
remove(find(value));
}
- template<typename T, typename U>
- inline void ListHashSet<T, U>::clear()
+ template<typename T, size_t inlineCapacity, typename U>
+ inline void ListHashSet<T, inlineCapacity, U>::clear()
{
deleteAllNodes();
m_impl.clear();
@@ -517,8 +517,8 @@ namespace WTF {
m_tail = 0;
}
- template<typename T, typename U>
- void ListHashSet<T, U>::unlinkAndDelete(Node* node)
+ template<typename T, size_t inlineCapacity, typename U>
+ void ListHashSet<T, inlineCapacity, U>::unlinkAndDelete(Node* node)
{
if (!node->m_prev) {
ASSERT(node == m_head);
@@ -539,8 +539,8 @@ namespace WTF {
node->destroy(m_allocator.get());
}
- template<typename T, typename U>
- void ListHashSet<T, U>::appendNode(Node* node)
+ template<typename T, size_t inlineCapacity, typename U>
+ void ListHashSet<T, inlineCapacity, U>::appendNode(Node* node)
{
node->m_prev = m_tail;
node->m_next = 0;
@@ -556,8 +556,8 @@ namespace WTF {
m_tail = node;
}
- template<typename T, typename U>
- void ListHashSet<T, U>::insertNodeBefore(Node* beforeNode, Node* newNode)
+ template<typename T, size_t inlineCapacity, typename U>
+ void ListHashSet<T, inlineCapacity, U>::insertNodeBefore(Node* beforeNode, Node* newNode)
{
if (!beforeNode)
return appendNode(newNode);
@@ -572,8 +572,8 @@ namespace WTF {
m_head = newNode;
}
- template<typename T, typename U>
- void ListHashSet<T, U>::deleteAllNodes()
+ template<typename T, size_t inlineCapacity, typename U>
+ void ListHashSet<T, inlineCapacity, U>::deleteAllNodes()
{
if (!m_head)
return;
@@ -582,16 +582,16 @@ namespace WTF {
node->destroy(m_allocator.get());
}
- template<typename T, typename U>
- inline ListHashSetIterator<T, U> ListHashSet<T, U>::makeIterator(Node* position)
+ template<typename T, size_t inlineCapacity, typename U>
+ inline ListHashSetIterator<T, inlineCapacity, U> ListHashSet<T, inlineCapacity, U>::makeIterator(Node* position)
{
- return ListHashSetIterator<T, U>(this, position);
+ return ListHashSetIterator<T, inlineCapacity, U>(this, position);
}
- template<typename T, typename U>
- inline ListHashSetConstIterator<T, U> ListHashSet<T, U>::makeConstIterator(Node* position) const
+ template<typename T, size_t inlineCapacity, typename U>
+ inline ListHashSetConstIterator<T, inlineCapacity, U> ListHashSet<T, inlineCapacity, U>::makeConstIterator(Node* position) const
{
- return ListHashSetConstIterator<T, U>(this, position);
+ return ListHashSetConstIterator<T, inlineCapacity, U>(this, position);
}
template<bool, typename ValueType, typename HashTableType>
@@ -603,10 +603,10 @@ namespace WTF {
delete (*it)->m_value;
}
- template<typename T, typename U>
- inline void deleteAllValues(const ListHashSet<T, U>& collection)
+ template<typename T, size_t inlineCapacity, typename U>
+ inline void deleteAllValues(const ListHashSet<T, inlineCapacity, U>& collection)
{
- deleteAllValues<true, typename ListHashSet<T, U>::ValueType>(collection.m_impl);
+ deleteAllValues<true, typename ListHashSet<T, inlineCapacity, U>::ValueType>(collection.m_impl);
}
} // namespace WTF
diff --git a/JavaScriptCore/wtf/MainThread.cpp b/JavaScriptCore/wtf/MainThread.cpp
index 1a0682b..6178420 100644
--- a/JavaScriptCore/wtf/MainThread.cpp
+++ b/JavaScriptCore/wtf/MainThread.cpp
@@ -230,7 +230,7 @@ void setMainThreadCallbacksPaused(bool paused)
scheduleDispatchFunctionsOnMainThread();
}
-#if !PLATFORM(MAC) && !PLATFORM(QT)
+#if !PLATFORM(MAC) && !PLATFORM(QT) && !PLATFORM(BREWMP)
bool isMainThread()
{
return currentThread() == mainThreadIdentifier;
diff --git a/JavaScriptCore/wtf/Platform.h b/JavaScriptCore/wtf/Platform.h
index 310eb04..bcf3bbe 100644
--- a/JavaScriptCore/wtf/Platform.h
+++ b/JavaScriptCore/wtf/Platform.h
@@ -522,6 +522,10 @@
#endif
#endif
+#if PLATFORM(BREWMP)
+#define WTF_PLATFORM_SKIA 1
+#endif
+
#if PLATFORM(GTK)
#define WTF_PLATFORM_CAIRO 1
#endif
@@ -1009,12 +1013,6 @@ on MinGW. See https://bugs.webkit.org/show_bug.cgi?id=29268 */
#define HAVE_COMPUTED_GOTO 1
#endif
-#if ENABLE(JIT) && defined(COVERAGE)
- #define WTF_USE_INTERPRETER 0
-#else
- #define WTF_USE_INTERPRETER 1
-#endif
-
/* Yet Another Regex Runtime. */
#if !defined(ENABLE_YARR_JIT)
diff --git a/JavaScriptCore/wtf/SizeLimits.cpp b/JavaScriptCore/wtf/SizeLimits.cpp
new file mode 100644
index 0000000..090c1ed
--- /dev/null
+++ b/JavaScriptCore/wtf/SizeLimits.cpp
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#include <wtf/Assertions.h>
+#include <wtf/CrossThreadRefCounted.h>
+#include <wtf/OwnPtr.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+#include <wtf/RefPtr.h>
+#include <wtf/Vector.h>
+
+namespace WTF {
+
+#ifndef NDEBUG
+static const size_t refCountedExtraDebugSize = sizeof(int);
+#else
+static const size_t refCountedExtraDebugSize = 0;
+#endif
+
+COMPILE_ASSERT(sizeof(OwnPtr<int>) == sizeof(int*), OwnPtr_should_stay_small);
+COMPILE_ASSERT(sizeof(PassRefPtr<RefCounted<int> >) == sizeof(int*), PassRefPtr_should_stay_small);
+COMPILE_ASSERT(sizeof(RefCounted<int>) == sizeof(int) + refCountedExtraDebugSize, RefCounted_should_stay_small);
+COMPILE_ASSERT(sizeof(RefCountedCustomAllocated<int>) == sizeof(int) + refCountedExtraDebugSize, RefCountedCustomAllocated_should_stay_small);
+COMPILE_ASSERT(sizeof(RefPtr<RefCounted<int> >) == sizeof(int*), RefPtr_should_stay_small);
+COMPILE_ASSERT(sizeof(Vector<int>) == 3 * sizeof(int*), Vector_should_stay_small);
+
+}
diff --git a/JavaScriptCore/wtf/StringExtras.h b/JavaScriptCore/wtf/StringExtras.h
index 28e80b8..323de6a 100644
--- a/JavaScriptCore/wtf/StringExtras.h
+++ b/JavaScriptCore/wtf/StringExtras.h
@@ -86,7 +86,7 @@ inline int strcasecmp(const char* s1, const char* s2)
#endif
-#if OS(WINDOWS) || OS(LINUX) || OS(SOLARIS)
+#if COMPILER(MSVC) || OS(WINDOWS) || OS(LINUX) || OS(SOLARIS)
// FIXME: should check HAVE_STRNSTR
inline char* strnstr(const char* buffer, const char* target, size_t bufferLength)
diff --git a/JavaScriptCore/wtf/text/StringImpl.cpp b/JavaScriptCore/wtf/text/StringImpl.cpp
index 68ff456..3606597 100644
--- a/JavaScriptCore/wtf/text/StringImpl.cpp
+++ b/JavaScriptCore/wtf/text/StringImpl.cpp
@@ -38,6 +38,8 @@ namespace WebCore {
static const unsigned minLengthToShare = 20;
+COMPILE_ASSERT(sizeof(StringImpl) == 2 * sizeof(int) + 3 * sizeof(void*), StringImpl_should_stay_small);
+
StringImpl::~StringImpl()
{
ASSERT(!isStatic());
diff --git a/JavaScriptCore/yarr/RegexInterpreter.cpp b/JavaScriptCore/yarr/RegexInterpreter.cpp
index c2cb1c2..34ccc00 100644
--- a/JavaScriptCore/yarr/RegexInterpreter.cpp
+++ b/JavaScriptCore/yarr/RegexInterpreter.cpp
@@ -674,7 +674,7 @@ public:
backTrack->inParentheses = 1;
if (term.capture()) {
unsigned subpatternId = term.atom.subpatternId;
- output[(subpatternId << 1) + 1] = input.getPos() + term.inputPosition;
+ output[subpatternId << 1] = input.getPos() + term.inputPosition;
}
context->term -= term.atom.parenthesesWidth;
return true;