summaryrefslogtreecommitdiff
path: root/Source/JavaScriptCore/dfg/DFGOperations.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/JavaScriptCore/dfg/DFGOperations.cpp')
-rw-r--r--Source/JavaScriptCore/dfg/DFGOperations.cpp92
1 files changed, 37 insertions, 55 deletions
diff --git a/Source/JavaScriptCore/dfg/DFGOperations.cpp b/Source/JavaScriptCore/dfg/DFGOperations.cpp
index b5c3b961b..824a0a37a 100644
--- a/Source/JavaScriptCore/dfg/DFGOperations.cpp
+++ b/Source/JavaScriptCore/dfg/DFGOperations.cpp
@@ -39,11 +39,13 @@
#include "JITExceptions.h"
#include "JSActivation.h"
#include "JSGlobalData.h"
-#include "JSStaticScopeObject.h"
+#include "JSNameScope.h"
#include "NameInstance.h"
#include "Operations.h"
#include <wtf/InlineASM.h>
+#if ENABLE(JIT)
+
#if ENABLE(DFG_JIT)
#if CPU(X86_64)
@@ -407,6 +409,20 @@ EncodedJSValue DFG_OPERATION operationGetByValCell(ExecState* exec, JSCell* base
return JSValue::encode(JSValue(base).get(exec, ident));
}
+EncodedJSValue DFG_OPERATION operationGetByValArrayInt(ExecState* exec, JSArray* base, int32_t index)
+{
+ JSGlobalData* globalData = &exec->globalData();
+ NativeCallFrameTracer tracer(globalData, exec);
+
+ if (index < 0) {
+ // Go the slowest way possible becase negative indices don't use indexed storage.
+ return JSValue::encode(JSValue(base).get(exec, Identifier::from(exec, index)));
+ }
+
+ // Use this since we know that the value is out of bounds.
+ return JSValue::encode(JSValue(base).get(exec, index));
+}
+
EncodedJSValue DFG_OPERATION operationGetById(ExecState* exec, EncodedJSValue base, Identifier* propertyName)
{
JSGlobalData* globalData = &exec->globalData();
@@ -575,6 +591,14 @@ EncodedJSValue DFG_OPERATION operationArrayPush(ExecState* exec, EncodedJSValue
return JSValue::encode(jsNumber(array->length()));
}
+EncodedJSValue DFG_OPERATION operationArrayPop(ExecState* exec, JSArray* array)
+{
+ JSGlobalData* globalData = &exec->globalData();
+ NativeCallFrameTracer tracer(globalData, exec);
+
+ return JSValue::encode(array->pop(exec));
+}
+
EncodedJSValue DFG_OPERATION operationRegExpExec(ExecState* exec, JSCell* base, JSCell* argument)
{
JSGlobalData& globalData = exec->globalData();
@@ -603,14 +627,6 @@ size_t DFG_OPERATION operationRegExpTest(ExecState* exec, JSCell* base, JSCell*
return asRegExpObject(base)->test(exec, input);
}
-EncodedJSValue DFG_OPERATION operationArrayPop(ExecState* exec, JSArray* array)
-{
- JSGlobalData* globalData = &exec->globalData();
- NativeCallFrameTracer tracer(globalData, exec);
-
- return JSValue::encode(array->pop(exec));
-}
-
void DFG_OPERATION operationPutByIdStrict(ExecState* exec, EncodedJSValue encodedValue, JSCell* base, Identifier* propertyName)
{
JSGlobalData* globalData = &exec->globalData();
@@ -899,7 +915,7 @@ static void* handleHostCall(ExecState* execCallee, JSValue callee, CodeSpecializ
ExecState* exec = execCallee->callerFrame();
JSGlobalData* globalData = &exec->globalData();
- execCallee->setScopeChain(exec->scopeChain());
+ execCallee->setScope(exec->scope());
execCallee->setCodeBlock(0);
if (kind == CodeForCall) {
@@ -957,7 +973,7 @@ inline char* linkFor(ExecState* execCallee, CodeSpecializationKind kind)
return reinterpret_cast<char*>(handleHostCall(execCallee, calleeAsValue, kind));
JSFunction* callee = jsCast<JSFunction*>(calleeAsFunctionCell);
- execCallee->setScopeChain(callee->scopeUnchecked());
+ execCallee->setScope(callee->scopeUnchecked());
ExecutableBase* executable = callee->executable();
MacroAssemblerCodePtr codePtr;
@@ -1007,7 +1023,7 @@ inline char* virtualFor(ExecState* execCallee, CodeSpecializationKind kind)
return reinterpret_cast<char*>(handleHostCall(execCallee, calleeAsValue, kind));
JSFunction* function = jsCast<JSFunction*>(calleeAsFunctionCell);
- execCallee->setScopeChain(function->scopeUnchecked());
+ execCallee->setScope(function->scopeUnchecked());
ExecutableBase* executable = function->executable();
if (UNLIKELY(!executable->hasJITCodeFor(kind))) {
FunctionExecutable* functionExecutable = static_cast<FunctionExecutable*>(executable);
@@ -1039,20 +1055,7 @@ EncodedJSValue DFG_OPERATION operationResolve(ExecState* exec, Identifier* prope
{
JSGlobalData* globalData = &exec->globalData();
NativeCallFrameTracer tracer(globalData, exec);
-
- ScopeChainNode* scopeChain = exec->scopeChain();
- ScopeChainIterator iter = scopeChain->begin();
- ScopeChainIterator end = scopeChain->end();
- ASSERT(iter != end);
-
- do {
- JSObject* record = iter->get();
- PropertySlot slot(record);
- if (record->getPropertySlot(exec, *propertyName, slot))
- return JSValue::encode(slot.getValue(exec, *propertyName));
- } while (++iter != end);
-
- return throwVMError(exec, createUndefinedVariableError(exec, *propertyName));
+ return JSValue::encode(JSScope::resolve(exec, *propertyName));
}
EncodedJSValue DFG_OPERATION operationResolveBase(ExecState* exec, Identifier* propertyName)
@@ -1060,7 +1063,7 @@ EncodedJSValue DFG_OPERATION operationResolveBase(ExecState* exec, Identifier* p
JSGlobalData* globalData = &exec->globalData();
NativeCallFrameTracer tracer(globalData, exec);
- return JSValue::encode(resolveBase(exec, *propertyName, exec->scopeChain(), false));
+ return JSValue::encode(JSScope::resolveBase(exec, *propertyName, false));
}
EncodedJSValue DFG_OPERATION operationResolveBaseStrictPut(ExecState* exec, Identifier* propertyName)
@@ -1068,30 +1071,15 @@ EncodedJSValue DFG_OPERATION operationResolveBaseStrictPut(ExecState* exec, Iden
JSGlobalData* globalData = &exec->globalData();
NativeCallFrameTracer tracer(globalData, exec);
- JSValue base = resolveBase(exec, *propertyName, exec->scopeChain(), true);
- if (!base)
- throwError(exec, createErrorForInvalidGlobalAssignment(exec, propertyName->ustring()));
- return JSValue::encode(base);
+ return JSValue::encode(JSScope::resolveBase(exec, *propertyName, true));
}
EncodedJSValue DFG_OPERATION operationResolveGlobal(ExecState* exec, GlobalResolveInfo* resolveInfo, JSGlobalObject* globalObject, Identifier* propertyName)
{
JSGlobalData* globalData = &exec->globalData();
NativeCallFrameTracer tracer(globalData, exec);
-
- PropertySlot slot(globalObject);
- if (globalObject->getPropertySlot(exec, *propertyName, slot)) {
- JSValue result = slot.getValue(exec, *propertyName);
-
- if (slot.isCacheableValue() && !globalObject->structure()->isUncacheableDictionary() && slot.slotBase() == globalObject) {
- resolveInfo->structure.set(exec->globalData(), exec->codeBlock()->ownerExecutable(), globalObject->structure());
- resolveInfo->offset = slot.cachedOffset();
- }
- return JSValue::encode(result);
- }
-
- return throwVMError(exec, createUndefinedVariableError(exec, *propertyName));
+ return JSValue::encode(JSScope::resolveGlobal(exec, *propertyName, globalObject, &resolveInfo->structure, &resolveInfo->offset));
}
EncodedJSValue DFG_OPERATION operationToPrimitive(ExecState* exec, EncodedJSValue value)
@@ -1154,7 +1142,7 @@ JSCell* DFG_OPERATION operationCreateActivation(ExecState* exec)
NativeCallFrameTracer tracer(&globalData, exec);
JSActivation* activation = JSActivation::create(
globalData, exec, static_cast<FunctionExecutable*>(exec->codeBlock()->ownerExecutable()));
- exec->setScopeChain(exec->scopeChain()->push(activation));
+ exec->setScope(activation);
return activation;
}
@@ -1255,7 +1243,7 @@ JSCell* DFG_OPERATION operationNewFunction(ExecState* exec, JSCell* functionExec
ASSERT(functionExecutable->inherits(&FunctionExecutable::s_info));
JSGlobalData& globalData = exec->globalData();
NativeCallFrameTracer tracer(&globalData, exec);
- return static_cast<FunctionExecutable*>(functionExecutable)->make(exec, exec->scopeChain());
+ return JSFunction::create(exec, static_cast<FunctionExecutable*>(functionExecutable), exec->scope());
}
JSCell* DFG_OPERATION operationNewFunctionExpression(ExecState* exec, JSCell* functionExecutableAsCell)
@@ -1263,14 +1251,7 @@ JSCell* DFG_OPERATION operationNewFunctionExpression(ExecState* exec, JSCell* fu
ASSERT(functionExecutableAsCell->inherits(&FunctionExecutable::s_info));
FunctionExecutable* functionExecutable =
static_cast<FunctionExecutable*>(functionExecutableAsCell);
- JSFunction *function = functionExecutable->make(exec, exec->scopeChain());
- if (!functionExecutable->name().isNull()) {
- JSStaticScopeObject* functionScopeObject =
- JSStaticScopeObject::create(
- exec, functionExecutable->name(), function, ReadOnly | DontDelete);
- function->setScope(exec->globalData(), function->scope()->push(functionScopeObject));
- }
- return function;
+ return JSFunction::create(exec, functionExecutable, exec->scope());
}
size_t DFG_OPERATION operationIsObject(ExecState* exec, EncodedJSValue value)
@@ -1416,7 +1397,7 @@ extern "C" void DFG_OPERATION triggerReoptimizationNow(CodeBlock* codeBlock)
} // extern "C"
} } // namespace JSC::DFG
-#endif
+#endif // ENABLE(DFG_JIT)
#if COMPILER(GCC)
@@ -1478,3 +1459,4 @@ extern "C" EncodedJSValue HOST_CALL_RETURN_VALUE_OPTION getHostCallReturnValueWi
#endif // COMPILER(GCC)
+#endif // ENABLE(JIT)