summaryrefslogtreecommitdiff
path: root/Source/JavaScriptCore/interpreter/Interpreter.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2012-02-03 09:55:33 +0100
committerSimon Hausmann <simon.hausmann@nokia.com>2012-02-03 09:55:33 +0100
commitcd44dc59cdfc39534aef4d417e9f3c412e3be139 (patch)
tree8d89889ba95ed6ec9322e733846cc9cce9d7dff1 /Source/JavaScriptCore/interpreter/Interpreter.cpp
parentd11f84f5b5cdc0d92a08af01b13472fdd5f9acb9 (diff)
downloadqtwebkit-cd44dc59cdfc39534aef4d417e9f3c412e3be139.tar.gz
Imported WebKit commit fce473cb4d55aa9fe9d0b0322a2fffecb731b961 (http://svn.webkit.org/repository/webkit/trunk@106560)
Diffstat (limited to 'Source/JavaScriptCore/interpreter/Interpreter.cpp')
-rw-r--r--Source/JavaScriptCore/interpreter/Interpreter.cpp93
1 files changed, 42 insertions, 51 deletions
diff --git a/Source/JavaScriptCore/interpreter/Interpreter.cpp b/Source/JavaScriptCore/interpreter/Interpreter.cpp
index 980bf8a1a..51843f2d2 100644
--- a/Source/JavaScriptCore/interpreter/Interpreter.cpp
+++ b/Source/JavaScriptCore/interpreter/Interpreter.cpp
@@ -905,7 +905,7 @@ JSValue Interpreter::execute(ProgramExecutable* program, CallFrame* callFrame, S
PutPropertySlot slot;
globalObject->methodTable()->put(globalObject, callFrame, JSONPPath[0].m_pathEntryName, JSONPValue, slot);
} else
- globalObject->methodTable()->putWithAttributes(globalObject, callFrame, JSONPPath[0].m_pathEntryName, JSONPValue, DontEnum | DontDelete);
+ globalObject->methodTable()->putDirectVirtual(globalObject, callFrame, JSONPPath[0].m_pathEntryName, JSONPValue, DontEnum | DontDelete);
// var declarations return undefined
result = jsUndefined();
continue;
@@ -1324,7 +1324,7 @@ JSValue Interpreter::execute(EvalExecutable* eval, CallFrame* callFrame, JSValue
JSObject* variableObject;
for (ScopeChainNode* node = scopeChain; ; node = node->next.get()) {
ASSERT(node);
- if (node->object->isVariableObject()) {
+ if (node->object->isVariableObject() && !node->object->isStaticScopeObject()) {
variableObject = static_cast<JSVariableObject*>(node->object.get());
break;
}
@@ -2579,7 +2579,7 @@ JSValue Interpreter::privateExecute(ExecutionFlag flag, RegisterFile* registerFi
if (propName.getUInt32(i))
callFrame->uncheckedR(dst) = jsBoolean(baseObj->hasProperty(callFrame, i));
else {
- Identifier property(callFrame, propName.toString(callFrame));
+ Identifier property(callFrame, propName.toString(callFrame)->value(callFrame));
CHECK_FOR_EXCEPTION();
callFrame->uncheckedR(dst) = jsBoolean(baseObj->hasProperty(callFrame, property));
}
@@ -3310,9 +3310,10 @@ skip_id_custom_self:
JSValue baseValue = callFrame->r(base).jsValue();
Identifier& ident = codeBlock->identifier(property);
PutPropertySlot slot(codeBlock->isStrictMode());
- if (direct)
- baseValue.putDirect(callFrame, ident, callFrame->r(value).jsValue(), slot);
- else
+ if (direct) {
+ ASSERT(baseValue.isObject());
+ asObject(baseValue)->putDirect(*globalData, ident, callFrame->r(value).jsValue(), slot);
+ } else
baseValue.put(callFrame, ident, callFrame->r(value).jsValue(), slot);
CHECK_FOR_EXCEPTION();
@@ -3428,9 +3429,10 @@ skip_id_custom_self:
JSValue baseValue = callFrame->r(base).jsValue();
Identifier& ident = codeBlock->identifier(property);
PutPropertySlot slot(codeBlock->isStrictMode());
- if (direct)
- baseValue.putDirect(callFrame, ident, callFrame->r(value).jsValue(), slot);
- else
+ if (direct) {
+ ASSERT(baseValue.isObject());
+ asObject(baseValue)->putDirect(*globalData, ident, callFrame->r(value).jsValue(), slot);
+ } else
baseValue.put(callFrame, ident, callFrame->r(value).jsValue(), slot);
CHECK_FOR_EXCEPTION();
@@ -3482,7 +3484,7 @@ skip_id_custom_self:
NEXT_INSTRUCTION();
}
{
- Identifier propertyName(callFrame, subscript.toString(callFrame));
+ Identifier propertyName(callFrame, subscript.toString(callFrame)->value(callFrame));
result = baseValue.get(callFrame, propertyName);
}
CHECK_FOR_EXCEPTION();
@@ -3557,7 +3559,7 @@ skip_id_custom_self:
else
result = baseValue.get(callFrame, i);
} else {
- Identifier property(callFrame, subscript.toString(callFrame));
+ Identifier property(callFrame, subscript.toString(callFrame)->value(callFrame));
result = baseValue.get(callFrame, property);
}
@@ -3604,7 +3606,7 @@ skip_id_custom_self:
} else
baseValue.put(callFrame, i, callFrame->r(value).jsValue());
} else {
- Identifier property(callFrame, subscript.toString(callFrame));
+ Identifier property(callFrame, subscript.toString(callFrame)->value(callFrame));
if (!globalData->exception) { // Don't put to an object if toString threw an exception.
PutPropertySlot slot(codeBlock->isStrictMode());
baseValue.put(callFrame, property, callFrame->r(value).jsValue(), slot);
@@ -3636,7 +3638,7 @@ skip_id_custom_self:
result = baseObj->methodTable()->deletePropertyByIndex(baseObj, callFrame, i);
else {
CHECK_FOR_EXCEPTION();
- Identifier property(callFrame, subscript.toString(callFrame));
+ Identifier property(callFrame, subscript.toString(callFrame)->value(callFrame));
CHECK_FOR_EXCEPTION();
result = baseObj->methodTable()->deleteProperty(baseObj, callFrame, property);
}
@@ -4943,7 +4945,7 @@ skip_id_custom_self:
original constructor, using constant message as the
message string. The result is thrown.
*/
- UString message = callFrame->r(vPC[1].u.operand).jsValue().toString(callFrame);
+ UString message = callFrame->r(vPC[1].u.operand).jsValue().toString(callFrame)->value(callFrame);
exceptionValue = JSValue(createReferenceError(callFrame, message));
goto vm_throw;
}
@@ -4957,52 +4959,41 @@ skip_id_custom_self:
int result = vPC[1].u.operand;
return callFrame->r(result).jsValue();
}
- DEFINE_OPCODE(op_put_getter) {
- /* put_getter base(r) property(id) function(r)
+ DEFINE_OPCODE(op_put_getter_setter) {
+ /* put_getter_setter base(r) property(id) getter(r) setter(r)
- Sets register function on register base as the getter named
- by identifier property. Base and function are assumed to be
- objects as this op should only be used for getters defined
- in object literal form.
+ Puts accessor descriptor to register base as the named
+ identifier property. Base and function may be objects
+ or undefined, this op should only be used for accessors
+ defined in object literal form.
Unlike many opcodes, this one does not write any output to
the register file.
*/
int base = vPC[1].u.operand;
int property = vPC[2].u.operand;
- int function = vPC[3].u.operand;
+ int getterReg = vPC[3].u.operand;
+ int setterReg = vPC[4].u.operand;
ASSERT(callFrame->r(base).jsValue().isObject());
JSObject* baseObj = asObject(callFrame->r(base).jsValue());
Identifier& ident = codeBlock->identifier(property);
- ASSERT(callFrame->r(function).jsValue().isObject());
- baseObj->methodTable()->defineGetter(baseObj, callFrame, ident, asObject(callFrame->r(function).jsValue()), 0);
- vPC += OPCODE_LENGTH(op_put_getter);
- NEXT_INSTRUCTION();
- }
- DEFINE_OPCODE(op_put_setter) {
- /* put_setter base(r) property(id) function(r)
+ GetterSetter* accessor = GetterSetter::create(callFrame);
- Sets register function on register base as the setter named
- by identifier property. Base and function are assumed to be
- objects as this op should only be used for setters defined
- in object literal form.
+ JSValue getter = callFrame->r(getterReg).jsValue();
+ JSValue setter = callFrame->r(setterReg).jsValue();
+ ASSERT(getter.isObject() || getter.isUndefined());
+ ASSERT(setter.isObject() || setter.isUndefined());
+ ASSERT(getter.isObject() || setter.isObject());
- Unlike many opcodes, this one does not write any output to
- the register file.
- */
- int base = vPC[1].u.operand;
- int property = vPC[2].u.operand;
- int function = vPC[3].u.operand;
-
- ASSERT(callFrame->r(base).jsValue().isObject());
- JSObject* baseObj = asObject(callFrame->r(base).jsValue());
- Identifier& ident = codeBlock->identifier(property);
- ASSERT(callFrame->r(function).jsValue().isObject());
- baseObj->methodTable()->defineSetter(baseObj, callFrame, ident, asObject(callFrame->r(function).jsValue()), 0);
+ if (!getter.isUndefined())
+ accessor->setGetter(callFrame->globalData(), asObject(getter));
+ if (!setter.isUndefined())
+ accessor->setSetter(callFrame->globalData(), asObject(setter));
+ baseObj->putDirectAccessor(callFrame->globalData(), ident, accessor, Accessor);
- vPC += OPCODE_LENGTH(op_put_setter);
+ vPC += OPCODE_LENGTH(op_put_getter_setter);
NEXT_INSTRUCTION();
}
DEFINE_OPCODE(op_method_check) {
@@ -5106,9 +5097,9 @@ skip_id_custom_self:
#endif // ENABLE(INTERPRETER)
}
-JSValue Interpreter::retrieveArguments(CallFrame* callFrame, JSFunction* function) const
+JSValue Interpreter::retrieveArgumentsFromVMCode(CallFrame* callFrame, JSFunction* function) const
{
- CallFrame* functionCallFrame = findFunctionCallFrame(callFrame, function);
+ CallFrame* functionCallFrame = findFunctionCallFrameFromVMCode(callFrame, function);
if (!functionCallFrame)
return jsNull();
@@ -5130,9 +5121,9 @@ JSValue Interpreter::retrieveArguments(CallFrame* callFrame, JSFunction* functio
return JSValue(arguments);
}
-JSValue Interpreter::retrieveCaller(CallFrame* callFrame, JSFunction* function) const
+JSValue Interpreter::retrieveCallerFromVMCode(CallFrame* callFrame, JSFunction* function) const
{
- CallFrame* functionCallFrame = findFunctionCallFrame(callFrame, function);
+ CallFrame* functionCallFrame = findFunctionCallFrameFromVMCode(callFrame, function);
if (!functionCallFrame)
return jsNull();
@@ -5177,9 +5168,9 @@ void Interpreter::retrieveLastCaller(CallFrame* callFrame, int& lineNumber, intp
function = callerFrame->callee();
}
-CallFrame* Interpreter::findFunctionCallFrame(CallFrame* callFrame, JSFunction* function)
+CallFrame* Interpreter::findFunctionCallFrameFromVMCode(CallFrame* callFrame, JSFunction* function)
{
- for (CallFrame* candidate = callFrame; candidate; candidate = candidate->trueCallerFrame()) {
+ for (CallFrame* candidate = callFrame->trueCallFrameFromVMCode(); candidate; candidate = candidate->trueCallerFrame()) {
if (candidate->callee() == function)
return candidate;
}