- // a 0 codeBlock indicates a built-in caller
- newCallFrame->init(codeBlock, 0, scopeChain, callFrame->addHostCallFrameFlag(), 0, argc, function);
-#if ENABLE(JIT)
- FunctionExecutable->jitCode(newCallFrame, scopeChain);
-#endif
-
- CallFrameClosure result = { callFrame, newCallFrame, function, FunctionExecutable, scopeChain->globalData, oldEnd, scopeChain, codeBlock->m_numParameters, argc };
- return result;
-}
-
-JSValue Interpreter::execute(CallFrameClosure& closure, JSValue* exception)
-{
- closure.resetCallFrame();
- Profiler** profiler = Profiler::enabledProfilerReference();
- if (*profiler)
- (*profiler)->willExecute(closure.oldCallFrame, closure.function);
-
- JSValue result;
- {
- SamplingTool::CallRecord callRecord(m_sampler.get());
-
- m_reentryDepth++;
-#if ENABLE(JIT)
- result = closure.functionExecutable->generatedJITCode().execute(&m_registerFile, closure.newCallFrame, closure.globalData, exception);
-#else
- result = privateExecute(Normal, &m_registerFile, closure.newCallFrame, exception);
-#endif
- m_reentryDepth--;
- }
-
- if (*profiler)
- (*profiler)->didExecute(closure.oldCallFrame, closure.function);
- return result;
-}
-
-void Interpreter::endRepeatCall(CallFrameClosure& closure)
-{
- m_registerFile.shrink(closure.oldEnd);
-}
-
-JSValue Interpreter::execute(EvalExecutable* eval, CallFrame* callFrame, JSObject* thisObj, ScopeChainNode* scopeChain, JSValue* exception)
-{
- return execute(eval, callFrame, thisObj, m_registerFile.size() + eval->bytecode(callFrame, scopeChain).m_numParameters + RegisterFile::CallFrameHeaderSize, scopeChain, exception);
-}
-
-JSValue Interpreter::execute(EvalExecutable* eval, CallFrame* callFrame, JSObject* thisObj, int globalRegisterOffset, ScopeChainNode* scopeChain, JSValue* exception)
-{
- ASSERT(!scopeChain->globalData->exception);
-
- if (m_reentryDepth >= MaxSecondaryThreadReentryDepth) {
- if (!isMainThread() || m_reentryDepth >= MaxMainThreadReentryDepth) {
- *exception = createStackOverflowError(callFrame);
- return jsNull();
- }
- }
-
- DynamicGlobalObjectScope globalObjectScope(callFrame, scopeChain->globalObject);
-
- EvalCodeBlock* codeBlock = &eval->bytecode(callFrame, scopeChain);
-
- JSVariableObject* variableObject;
- for (ScopeChainNode* node = scopeChain; ; node = node->next) {
- ASSERT(node);
- if (node->object->isVariableObject()) {
- variableObject = static_cast<JSVariableObject*>(node->object);
- break;
- }
- }
-
- { // Scope for BatchedTransitionOptimizer
-
- BatchedTransitionOptimizer optimizer(variableObject);
-
- unsigned numVariables = codeBlock->numVariables();
- for (unsigned i = 0; i < numVariables; ++i) {
- const Identifier& ident = codeBlock->variable(i);
- if (!variableObject->hasProperty(callFrame, ident)) {
- PutPropertySlot slot;
- variableObject->put(callFrame, ident, jsUndefined(), slot);
- }
- }
-
- int numFunctions = codeBlock->numberOfFunctionDecls();
- for (int i = 0; i < numFunctions; ++i) {
- FunctionExecutable* function = codeBlock->functionDecl(i);
- PutPropertySlot slot;
- variableObject->put(callFrame, function->name(), function->make(callFrame, scopeChain), slot);
- }
-
- }
-
- Register* oldEnd = m_registerFile.end();
- Register* newEnd = m_registerFile.start() + globalRegisterOffset + codeBlock->m_numCalleeRegisters;
- if (!m_registerFile.grow(newEnd)) {
- *exception = createStackOverflowError(callFrame);
- return jsNull();
- }
-
- CallFrame* newCallFrame = CallFrame::create(m_registerFile.start() + globalRegisterOffset);
-
- // a 0 codeBlock indicates a built-in caller
- newCallFrame->r(codeBlock->thisRegister()) = JSValue(thisObj);
- newCallFrame->init(codeBlock, 0, scopeChain, callFrame->addHostCallFrameFlag(), 0, 0, 0);
-
- if (codeBlock->needsFullScopeChain())
- scopeChain->ref();
-
- Profiler** profiler = Profiler::enabledProfilerReference();
- if (*profiler)
- (*profiler)->willExecute(newCallFrame, eval->sourceURL(), eval->lineNo());
-
- JSValue result;
- {
- SamplingTool::CallRecord callRecord(m_sampler.get());
-
- m_reentryDepth++;
-#if ENABLE(JIT)
- result = eval->jitCode(newCallFrame, scopeChain).execute(&m_registerFile, newCallFrame, scopeChain->globalData, exception);
-#else
- result = privateExecute(Normal, &m_registerFile, newCallFrame, exception);
-#endif
- m_reentryDepth--;
- }
-
- if (*profiler)
- (*profiler)->didExecute(callFrame, eval->sourceURL(), eval->lineNo());
-
- m_registerFile.shrink(oldEnd);
- return result;
-}
-
-NEVER_INLINE void Interpreter::debug(CallFrame* callFrame, DebugHookID debugHookID, int firstLine, int lastLine)
-{
- Debugger* debugger = callFrame->dynamicGlobalObject()->debugger();
- if (!debugger)
- return;
-
- switch (debugHookID) {
- case DidEnterCallFrame:
- debugger->callEvent(callFrame, callFrame->codeBlock()->ownerExecutable()->sourceID(), firstLine);
- return;
- case WillLeaveCallFrame:
- debugger->returnEvent(callFrame, callFrame->codeBlock()->ownerExecutable()->sourceID(), lastLine);
- return;
- case WillExecuteStatement:
- debugger->atStatement(callFrame, callFrame->codeBlock()->ownerExecutable()->sourceID(), firstLine);
- return;
- case WillExecuteProgram:
- debugger->willExecuteProgram(callFrame, callFrame->codeBlock()->ownerExecutable()->sourceID(), firstLine);
- return;
- case DidExecuteProgram:
- debugger->didExecuteProgram(callFrame, callFrame->codeBlock()->ownerExecutable()->sourceID(), lastLine);
- return;
- case DidReachBreakpoint:
- debugger->didReachBreakpoint(callFrame, callFrame->codeBlock()->ownerExecutable()->sourceID(), lastLine);
- return;
- }
-}
-
-#if USE(INTERPRETER)
-NEVER_INLINE ScopeChainNode* Interpreter::createExceptionScope(CallFrame* callFrame, const Instruction* vPC)
-{
- int dst = vPC[1].u.operand;
- CodeBlock* codeBlock = callFrame->codeBlock();
- Identifier& property = codeBlock->identifier(vPC[2].u.operand);
- JSValue value = callFrame->r(vPC[3].u.operand).jsValue();
- JSObject* scope = new (callFrame) JSStaticScopeObject(callFrame, property, value, DontDelete);
- callFrame->r(dst) = JSValue(scope);
-
- return callFrame->scopeChain()->push(scope);
-}
-
-NEVER_INLINE void Interpreter::tryCachePutByID(CallFrame* callFrame, CodeBlock* codeBlock, Instruction* vPC, JSValue baseValue, const PutPropertySlot& slot)
-{
- // Recursive invocation may already have specialized this instruction.
- if (vPC[0].u.opcode != getOpcode(op_put_by_id))
- return;
-
- if (!baseValue.isCell())
- return;
-
- // Uncacheable: give up.
- if (!slot.isCacheable()) {
- vPC[0] = getOpcode(op_put_by_id_generic);
- return;
- }
-
- JSCell* baseCell = asCell(baseValue);
- Structure* structure = baseCell->structure();
-
- if (structure->isUncacheableDictionary()) {
- vPC[0] = getOpcode(op_put_by_id_generic);
- return;
- }
-
- // Cache miss: record Structure to compare against next time.
- Structure* lastStructure = vPC[4].u.structure;
- if (structure != lastStructure) {
- // First miss: record Structure to compare against next time.
- if (!lastStructure) {
- vPC[4] = structure;
- return;
- }
-
- // Second miss: give up.
- vPC[0] = getOpcode(op_put_by_id_generic);
- return;
- }
-
- // Cache hit: Specialize instruction and ref Structures.
-
- // If baseCell != slot.base(), then baseCell must be a proxy for another object.
- if (baseCell != slot.base()) {
- vPC[0] = getOpcode(op_put_by_id_generic);
- return;
- }
-
- // Structure transition, cache transition info
- if (slot.type() == PutPropertySlot::NewProperty) {
- if (structure->isDictionary()) {
- vPC[0] = getOpcode(op_put_by_id_generic);
- return;
- }
-
- // put_by_id_transition checks the prototype chain for setters.
- normalizePrototypeChain(callFrame, baseCell);
-
- vPC[0] = getOpcode(op_put_by_id_transition);
- vPC[4] = structure->previousID();
- vPC[5] = structure;
- vPC[6] = structure->prototypeChain(callFrame);
- vPC[7] = slot.cachedOffset();
- codeBlock->refStructures(vPC);
- return;
- }
-
- vPC[0] = getOpcode(op_put_by_id_replace);
- vPC[5] = slot.cachedOffset();
- codeBlock->refStructures(vPC);
-}
-
-NEVER_INLINE void Interpreter::uncachePutByID(CodeBlock* codeBlock, Instruction* vPC)
-{
- codeBlock->derefStructures(vPC);
- vPC[0] = getOpcode(op_put_by_id);
- vPC[4] = 0;
-}
-
-NEVER_INLINE void Interpreter::tryCacheGetByID(CallFrame* callFrame, CodeBlock* codeBlock, Instruction* vPC, JSValue baseValue, const Identifier& propertyName, const PropertySlot& slot)
-{
- // Recursive invocation may already have specialized this instruction.
- if (vPC[0].u.opcode != getOpcode(op_get_by_id))
- return;
-
- // FIXME: Cache property access for immediates.
- if (!baseValue.isCell()) {
- vPC[0] = getOpcode(op_get_by_id_generic);
- return;
- }
-
- JSGlobalData* globalData = &callFrame->globalData();
- if (isJSArray(globalData, baseValue) && propertyName == callFrame->propertyNames().length) {
- vPC[0] = getOpcode(op_get_array_length);
- return;
- }
-
- if (isJSString(globalData, baseValue) && propertyName == callFrame->propertyNames().length) {
- vPC[0] = getOpcode(op_get_string_length);
- return;
- }
-
- // Uncacheable: give up.
- if (!slot.isCacheable()) {
- vPC[0] = getOpcode(op_get_by_id_generic);
- return;
- }
-
- Structure* structure = asCell(baseValue)->structure();
-
- if (structure->isUncacheableDictionary()) {
- vPC[0] = getOpcode(op_get_by_id_generic);
- return;
- }
-
- // Cache miss
- Structure* lastStructure = vPC[4].u.structure;
- if (structure != lastStructure) {
- // First miss: record Structure to compare against next time.
- if (!lastStructure) {
- vPC[4] = structure;
- return;
- }
-
- // Second miss: give up.
- vPC[0] = getOpcode(op_get_by_id_generic);
- return;
- }
-
- // Cache hit: Specialize instruction and ref Structures.
-
- if (slot.slotBase() == baseValue) {
- vPC[0] = getOpcode(op_get_by_id_self);
- vPC[5] = slot.cachedOffset();
-
- codeBlock->refStructures(vPC);
- return;
- }
-
- if (structure->isDictionary()) {
- vPC[0] = getOpcode(op_get_by_id_generic);
- return;
- }
-
- if (slot.slotBase() == structure->prototypeForLookup(callFrame)) {
- ASSERT(slot.slotBase().isObject());
-
- JSObject* baseObject = asObject(slot.slotBase());
- size_t offset = slot.cachedOffset();
-
- // Since we're accessing a prototype in a loop, it's a good bet that it
- // should not be treated as a dictionary.
- if (baseObject->structure()->isDictionary()) {
- baseObject->flattenDictionaryObject();
- offset = baseObject->structure()->get(propertyName);
- }
-
- ASSERT(!baseObject->structure()->isUncacheableDictionary());
-
- vPC[0] = getOpcode(op_get_by_id_proto);
- vPC[5] = baseObject->structure();
- vPC[6] = offset;
-
- codeBlock->refStructures(vPC);
- return;
- }
-
- size_t offset = slot.cachedOffset();
- size_t count = normalizePrototypeChain(callFrame, baseValue, slot.slotBase(), propertyName, offset);
- if (!count) {
- vPC[0] = getOpcode(op_get_by_id_generic);
- return;
- }
-
- vPC[0] = getOpcode(op_get_by_id_chain);
- vPC[4] = structure;
- vPC[5] = structure->prototypeChain(callFrame);
- vPC[6] = count;
- vPC[7] = offset;
- codeBlock->refStructures(vPC);
-}
-
-NEVER_INLINE void Interpreter::uncacheGetByID(CodeBlock* codeBlock, Instruction* vPC)
-{
- codeBlock->derefStructures(vPC);
- vPC[0] = getOpcode(op_get_by_id);
- vPC[4] = 0;
-}
-
-#endif // USE(INTERPRETER)
-
-JSValue Interpreter::privateExecute(ExecutionFlag flag, RegisterFile* registerFile, CallFrame* callFrame, JSValue* exception)
-{
- // One-time initialization of our address tables. We have to put this code
- // here because our labels are only in scope inside this function.
- if (UNLIKELY(flag == InitializeAndReturn)) {
- #if HAVE(COMPUTED_GOTO)
- #define LIST_OPCODE_LABEL(id, length) &&id,
- static Opcode labels[] = { FOR_EACH_OPCODE_ID(LIST_OPCODE_LABEL) };
- for (size_t i = 0; i < sizeof(labels) / sizeof(Opcode); ++i)
- m_opcodeTable[i] = labels[i];
- #undef LIST_OPCODE_LABEL
- #endif // HAVE(COMPUTED_GOTO)
- return JSValue();
- }
-
-#if ENABLE(JIT)
- // Mixing Interpreter + JIT is not supported.
- ASSERT_NOT_REACHED();
-#endif
-#if !USE(INTERPRETER)
- UNUSED_PARAM(registerFile);
- UNUSED_PARAM(callFrame);
- UNUSED_PARAM(exception);
- return JSValue();
-#else
-
- JSGlobalData* globalData = &callFrame->globalData();
- JSValue exceptionValue;
- HandlerInfo* handler = 0;
-
- Instruction* vPC = callFrame->codeBlock()->instructions().begin();
- Profiler** enabledProfilerReference = Profiler::enabledProfilerReference();
- unsigned tickCount = globalData->timeoutChecker.ticksUntilNextCheck();
-
-#define CHECK_FOR_EXCEPTION() \
- do { \
- if (UNLIKELY(globalData->exception != JSValue())) { \
- exceptionValue = globalData->exception; \
- goto vm_throw; \
- } \
- } while (0)
-
-#if ENABLE(OPCODE_STATS)
- OpcodeStats::resetLastInstruction();
-#endif
-
-#define CHECK_FOR_TIMEOUT() \
- if (!--tickCount) { \
- if (globalData->timeoutChecker.didTimeOut(callFrame)) { \
- exceptionValue = jsNull(); \
- goto vm_throw; \
- } \
- tickCount = globalData->timeoutChecker.ticksUntilNextCheck(); \
- }
-
-#if ENABLE(OPCODE_SAMPLING)
- #define SAMPLE(codeBlock, vPC) m_sampler->sample(codeBlock, vPC)
-#else
- #define SAMPLE(codeBlock, vPC)
-#endif
-
-#if HAVE(COMPUTED_GOTO)
- #define NEXT_INSTRUCTION() SAMPLE(callFrame->codeBlock(), vPC); goto *vPC->u.opcode
-#if ENABLE(OPCODE_STATS)
- #define DEFINE_OPCODE(opcode) opcode: OpcodeStats::recordInstruction(opcode);
-#else
- #define DEFINE_OPCODE(opcode) opcode:
-#endif
- NEXT_INSTRUCTION();
-#else
- #define NEXT_INSTRUCTION() SAMPLE(callFrame->codeBlock(), vPC); goto interpreterLoopStart
-#if ENABLE(OPCODE_STATS)
- #define DEFINE_OPCODE(opcode) case opcode: OpcodeStats::recordInstruction(opcode);
-#else
- #define DEFINE_OPCODE(opcode) case opcode:
-#endif
- while (1) { // iterator loop begins
- interpreterLoopStart:;
- switch (vPC->u.opcode)
-#endif
- {
- DEFINE_OPCODE(op_new_object) {
- /* new_object dst(r)
-
- Constructs a new empty Object instance using the original
- constructor, and puts the result in register dst.
- */
- int dst = vPC[1].u.operand;
- callFrame->r(dst) = JSValue(constructEmptyObject(callFrame));
-
- vPC += OPCODE_LENGTH(op_new_object);
- NEXT_INSTRUCTION();
- }
- DEFINE_OPCODE(op_new_array) {
- /* new_array dst(r) firstArg(r) argCount(n)
-
- Constructs a new Array instance using the original
- constructor, and puts the result in register dst.
- The array will contain argCount elements with values
- taken from registers starting at register firstArg.
- */
- int dst = vPC[1].u.operand;
- int firstArg = vPC[2].u.operand;
- int argCount = vPC[3].u.operand;
- ArgList args(callFrame->registers() + firstArg, argCount);
- callFrame->r(dst) = JSValue(constructArray(callFrame, args));
-
- vPC += OPCODE_LENGTH(op_new_array);
- NEXT_INSTRUCTION();
- }
- DEFINE_OPCODE(op_new_regexp) {
- /* new_regexp dst(r) regExp(re)
-
- Constructs a new RegExp instance using the original
- constructor from regexp regExp, and puts the result in
- register dst.
- */
- 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)));
-
- vPC += OPCODE_LENGTH(op_new_regexp);
- NEXT_INSTRUCTION();
- }
- DEFINE_OPCODE(op_mov) {
- /* mov dst(r) src(r)
-
- Copies register src to register dst.
- */
- int dst = vPC[1].u.operand;
- int src = vPC[2].u.operand;
- callFrame->r(dst) = callFrame->r(src);
-
- vPC += OPCODE_LENGTH(op_mov);
- NEXT_INSTRUCTION();
- }
- DEFINE_OPCODE(op_eq) {
- /* eq dst(r) src1(r) src2(r)
-
- Checks whether register src1 and register src2 are equal,
- as with the ECMAScript '==' operator, and puts the result
- as a boolean in register dst.
- */
- int dst = vPC[1].u.operand;
- JSValue src1 = callFrame->r(vPC[2].u.operand).jsValue();
- JSValue src2 = callFrame->r(vPC[3].u.operand).jsValue();
- if (src1.isInt32() && src2.isInt32())
- callFrame->r(dst) = jsBoolean(src1.asInt32() == src2.asInt32());
- else {
- JSValue result = jsBoolean(JSValue::equalSlowCase(callFrame, src1, src2));
- CHECK_FOR_EXCEPTION();
- callFrame->r(dst) = result;
- }
-
- vPC += OPCODE_LENGTH(op_eq);
- NEXT_INSTRUCTION();
- }
- DEFINE_OPCODE(op_eq_null) {
- /* eq_null dst(r) src(r)
-
- Checks whether register src is null, as with the ECMAScript '!='
- operator, and puts the result as a boolean in register dst.
- */
- int dst = vPC[1].u.operand;
- JSValue src = callFrame->r(vPC[2].u.operand).jsValue();
-
- if (src.isUndefinedOrNull()) {
- callFrame->r(dst) = jsBoolean(true);
- vPC += OPCODE_LENGTH(op_eq_null);
- NEXT_INSTRUCTION();
- }
-
- callFrame->r(dst) = jsBoolean(src.isCell() && src.asCell()->structure()->typeInfo().masqueradesAsUndefined());
- vPC += OPCODE_LENGTH(op_eq_null);
- NEXT_INSTRUCTION();
- }
- DEFINE_OPCODE(op_neq) {
- /* neq dst(r) src1(r) src2(r)
-
- Checks whether register src1 and register src2 are not
- equal, as with the ECMAScript '!=' operator, and puts the
- result as a boolean in register dst.
- */
- int dst = vPC[1].u.operand;
- JSValue src1 = callFrame->r(vPC[2].u.operand).jsValue();
- JSValue src2 = callFrame->r(vPC[3].u.operand).jsValue();
- if (src1.isInt32() && src2.isInt32())
- callFrame->r(dst) = jsBoolean(src1.asInt32() != src2.asInt32());
- else {
- JSValue result = jsBoolean(!JSValue::equalSlowCase(callFrame, src1, src2));
- CHECK_FOR_EXCEPTION();
- callFrame->r(dst) = result;
- }
-
- vPC += OPCODE_LENGTH(op_neq);
- NEXT_INSTRUCTION();
- }
- DEFINE_OPCODE(op_neq_null) {
- /* neq_null dst(r) src(r)
-
- Checks whether register src is not null, as with the ECMAScript '!='
- operator, and puts the result as a boolean in register dst.
- */
- int dst = vPC[1].u.operand;
- JSValue src = callFrame->r(vPC[2].u.operand).jsValue();
-
- if (src.isUndefinedOrNull()) {
- callFrame->r(dst) = jsBoolean(false);
- vPC += OPCODE_LENGTH(op_neq_null);
- NEXT_INSTRUCTION();
- }
-
- callFrame->r(dst) = jsBoolean(!src.isCell() || !asCell(src)->structure()->typeInfo().masqueradesAsUndefined());
- vPC += OPCODE_LENGTH(op_neq_null);
- NEXT_INSTRUCTION();
- }
- DEFINE_OPCODE(op_stricteq) {
- /* stricteq dst(r) src1(r) src2(r)
-
- Checks whether register src1 and register src2 are strictly
- equal, as with the ECMAScript '===' operator, and puts the
- result as a boolean in register dst.
- */
- 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));
-
- vPC += OPCODE_LENGTH(op_stricteq);
- NEXT_INSTRUCTION();
- }
- DEFINE_OPCODE(op_nstricteq) {
- /* nstricteq dst(r) src1(r) src2(r)
-
- Checks whether register src1 and register src2 are not
- strictly equal, as with the ECMAScript '!==' operator, and
- puts the result as a boolean in register dst.
- */
- 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));
-
- vPC += OPCODE_LENGTH(op_nstricteq);
- NEXT_INSTRUCTION();
- }
- DEFINE_OPCODE(op_less) {
- /* less dst(r) src1(r) src2(r)
-
- Checks whether register src1 is less than register src2, as
- with the ECMAScript '<' operator, and puts the result as
- a boolean in register dst.
- */
- int dst = vPC[1].u.operand;
- JSValue src1 = callFrame->r(vPC[2].u.operand).jsValue();
- JSValue src2 = callFrame->r(vPC[3].u.operand).jsValue();
- JSValue result = jsBoolean(jsLess(callFrame, src1, src2));
- CHECK_FOR_EXCEPTION();
- callFrame->r(dst) = result;
-
- vPC += OPCODE_LENGTH(op_less);
- NEXT_INSTRUCTION();
- }
- DEFINE_OPCODE(op_lesseq) {
- /* lesseq dst(r) src1(r) src2(r)
-
- Checks whether register src1 is less than or equal to
- register src2, as with the ECMAScript '<=' operator, and
- puts the result as a boolean in register dst.
- */
- int dst = vPC[1].u.operand;
- JSValue src1 = callFrame->r(vPC[2].u.operand).jsValue();
- JSValue src2 = callFrame->r(vPC[3].u.operand).jsValue();
- JSValue result = jsBoolean(jsLessEq(callFrame, src1, src2));
- CHECK_FOR_EXCEPTION();
- callFrame->r(dst) = result;
-
- vPC += OPCODE_LENGTH(op_lesseq);
- NEXT_INSTRUCTION();
- }
- DEFINE_OPCODE(op_pre_inc) {
- /* pre_inc srcDst(r)
-
- Converts register srcDst to number, adds one, and puts the result
- back in register srcDst.
- */
- int srcDst = vPC[1].u.operand;
- JSValue v = callFrame->r(srcDst).jsValue();
- if (v.isInt32() && v.asInt32() < INT_MAX)
- callFrame->r(srcDst) = jsNumber(callFrame, v.asInt32() + 1);
- else {
- JSValue result = jsNumber(callFrame, v.toNumber(callFrame) + 1);
- CHECK_FOR_EXCEPTION();
- callFrame->r(srcDst) = result;
- }
-
- vPC += OPCODE_LENGTH(op_pre_inc);
- NEXT_INSTRUCTION();
- }
- DEFINE_OPCODE(op_pre_dec) {
- /* pre_dec srcDst(r)
-
- Converts register srcDst to number, subtracts one, and puts the result
- back in register srcDst.
- */
- int srcDst = vPC[1].u.operand;
- JSValue v = callFrame->r(srcDst).jsValue();
- if (v.isInt32() && v.asInt32() > INT_MIN)
- callFrame->r(srcDst) = jsNumber(callFrame, v.asInt32() - 1);
- else {
- JSValue result = jsNumber(callFrame, v.toNumber(callFrame) - 1);
- CHECK_FOR_EXCEPTION();
- callFrame->r(srcDst) = result;
- }
-
- vPC += OPCODE_LENGTH(op_pre_dec);
- NEXT_INSTRUCTION();
- }
- DEFINE_OPCODE(op_post_inc) {
- /* post_inc dst(r) srcDst(r)
-
- Converts register srcDst to number. The number itself is
- written to register dst, and the number plus one is written
- back to register srcDst.
- */
- int dst = vPC[1].u.operand;
- int srcDst = vPC[2].u.operand;
- JSValue v = callFrame->r(srcDst).jsValue();
- if (v.isInt32() && v.asInt32() < INT_MAX) {
- callFrame->r(srcDst) = jsNumber(callFrame, v.asInt32() + 1);
- callFrame->r(dst) = v;
- } else {
- JSValue number = callFrame->r(srcDst).jsValue().toJSNumber(callFrame);
- CHECK_FOR_EXCEPTION();
- callFrame->r(srcDst) = jsNumber(callFrame, number.uncheckedGetNumber() + 1);
- callFrame->r(dst) = number;
- }
-
- vPC += OPCODE_LENGTH(op_post_inc);
- NEXT_INSTRUCTION();
- }
- DEFINE_OPCODE(op_post_dec) {
- /* post_dec dst(r) srcDst(r)
-
- Converts register srcDst to number. The number itself is
- written to register dst, and the number minus one is written
- back to register srcDst.
- */
- int dst = vPC[1].u.operand;
- int srcDst = vPC[2].u.operand;
- JSValue v = callFrame->r(srcDst).jsValue();
- if (v.isInt32() && v.asInt32() > INT_MIN) {
- callFrame->r(srcDst) = jsNumber(callFrame, v.asInt32() - 1);
- callFrame->r(dst) = v;
- } else {
- JSValue number = callFrame->r(srcDst).jsValue().toJSNumber(callFrame);
- CHECK_FOR_EXCEPTION();
- callFrame->r(srcDst) = jsNumber(callFrame, number.uncheckedGetNumber() - 1);
- callFrame->r(dst) = number;
- }
-
- vPC += OPCODE_LENGTH(op_post_dec);
- NEXT_INSTRUCTION();
- }
- DEFINE_OPCODE(op_to_jsnumber) {
- /* to_jsnumber dst(r) src(r)
-
- Converts register src to number, and puts the result
- in register dst.
- */
- int dst = vPC[1].u.operand;
- int src = vPC[2].u.operand;
-
- JSValue srcVal = callFrame->r(src).jsValue();
-
- if (LIKELY(srcVal.isNumber()))
- callFrame->r(dst) = callFrame->r(src);
- else {
- JSValue result = srcVal.toJSNumber(callFrame);
- CHECK_FOR_EXCEPTION();
- callFrame->r(dst) = result;
- }
-
- vPC += OPCODE_LENGTH(op_to_jsnumber);
- NEXT_INSTRUCTION();
- }
- DEFINE_OPCODE(op_negate) {
- /* negate dst(r) src(r)
-
- Converts register src to number, negates it, and puts the
- result in register dst.
- */
- int dst = vPC[1].u.operand;
- JSValue src = callFrame->r(vPC[2].u.operand).jsValue();
- if (src.isInt32() && src.asInt32())
- callFrame->r(dst) = jsNumber(callFrame, -src.asInt32());
- else {
- JSValue result = jsNumber(callFrame, -src.toNumber(callFrame));
- CHECK_FOR_EXCEPTION();
- callFrame->r(dst) = result;
- }
-
- vPC += OPCODE_LENGTH(op_negate);
- NEXT_INSTRUCTION();
- }
- DEFINE_OPCODE(op_add) {
- /* add dst(r) src1(r) src2(r)
-
- Adds register src1 and register src2, and puts the result
- in register dst. (JS add may be string concatenation or
- numeric add, depending on the types of the operands.)
- */
- int dst = vPC[1].u.operand;
- JSValue src1 = callFrame->r(vPC[2].u.operand).jsValue();
- JSValue src2 = callFrame->r(vPC[3].u.operand).jsValue();
- if (src1.isInt32() && src2.isInt32() && !(src1.asInt32() | (src2.asInt32() & 0xc0000000))) // no overflow
- callFrame->r(dst) = jsNumber(callFrame, src1.asInt32() + src2.asInt32());
- else {
- JSValue result = jsAdd(callFrame, src1, src2);
- CHECK_FOR_EXCEPTION();
- callFrame->r(dst) = result;
- }
- vPC += OPCODE_LENGTH(op_add);
- NEXT_INSTRUCTION();
- }
- DEFINE_OPCODE(op_mul) {
- /* mul dst(r) src1(r) src2(r)
-
- Multiplies register src1 and register src2 (converted to
- numbers), and puts the product in register dst.
- */
- int dst = vPC[1].u.operand;
- JSValue src1 = callFrame->r(vPC[2].u.operand).jsValue();
- JSValue src2 = callFrame->r(vPC[3].u.operand).jsValue();
- if (src1.isInt32() && src2.isInt32() && !(src1.asInt32() | src2.asInt32() >> 15)) // no overflow
- callFrame->r(dst) = jsNumber(callFrame, src1.asInt32() * src2.asInt32());
- else {
- JSValue result = jsNumber(callFrame, src1.toNumber(callFrame) * src2.toNumber(callFrame));
- CHECK_FOR_EXCEPTION();
- callFrame->r(dst) = result;
- }
-
- vPC += OPCODE_LENGTH(op_mul);
- NEXT_INSTRUCTION();
- }
- DEFINE_OPCODE(op_div) {
- /* div dst(r) dividend(r) divisor(r)
-
- Divides register dividend (converted to number) by the
- register divisor (converted to number), and puts the
- quotient in register dst.
- */
- int dst = vPC[1].u.operand;
- JSValue dividend = callFrame->r(vPC[2].u.operand).jsValue();
- JSValue divisor = callFrame->r(vPC[3].u.operand).jsValue();
-
- JSValue result = jsNumber(callFrame, dividend.toNumber(callFrame) / divisor.toNumber(callFrame));
- CHECK_FOR_EXCEPTION();
- callFrame->r(dst) = result;
-
- vPC += OPCODE_LENGTH(op_div);
- NEXT_INSTRUCTION();
- }
- DEFINE_OPCODE(op_mod) {
- /* mod dst(r) dividend(r) divisor(r)
-
- Divides register dividend (converted to number) by
- register divisor (converted to number), and puts the
- remainder in register dst.
- */
- int dst = vPC[1].u.operand;
- JSValue dividend = callFrame->r(vPC[2].u.operand).jsValue();
- JSValue divisor = callFrame->r(vPC[3].u.operand).jsValue();
-
- if (dividend.isInt32() && divisor.isInt32() && divisor.asInt32() != 0) {
- JSValue result = jsNumber(callFrame, dividend.asInt32() % divisor.asInt32());
- ASSERT(result);
- callFrame->r(dst) = result;
- vPC += OPCODE_LENGTH(op_mod);
- NEXT_INSTRUCTION();
- }
-
- // Conversion to double must happen outside the call to fmod since the
- // order of argument evaluation is not guaranteed.
- double d1 = dividend.toNumber(callFrame);
- double d2 = divisor.toNumber(callFrame);
- JSValue result = jsNumber(callFrame, fmod(d1, d2));
- CHECK_FOR_EXCEPTION();
- callFrame->r(dst) = result;
- vPC += OPCODE_LENGTH(op_mod);
- NEXT_INSTRUCTION();
- }
- DEFINE_OPCODE(op_sub) {
- /* sub dst(r) src1(r) src2(r)
-
- Subtracts register src2 (converted to number) from register
- src1 (converted to number), and puts the difference in
- register dst.
- */
- int dst = vPC[1].u.operand;
- JSValue src1 = callFrame->r(vPC[2].u.operand).jsValue();
- JSValue src2 = callFrame->r(vPC[3].u.operand).jsValue();
- if (src1.isInt32() && src2.isInt32() && !(src1.asInt32() | (src2.asInt32() & 0xc0000000))) // no overflow
- callFrame->r(dst) = jsNumber(callFrame, src1.asInt32() - src2.asInt32());
- else {
- JSValue result = jsNumber(callFrame, src1.toNumber(callFrame) - src2.toNumber(callFrame));
- CHECK_FOR_EXCEPTION();
- callFrame->r(dst) = result;
- }
- vPC += OPCODE_LENGTH(op_sub);
- NEXT_INSTRUCTION();
- }
- DEFINE_OPCODE(op_lshift) {
- /* lshift dst(r) val(r) shift(r)
-
- Performs left shift of register val (converted to int32) by
- register shift (converted to uint32), and puts the result
- in register dst.
- */
- int dst = vPC[1].u.operand;
- JSValue val = callFrame->r(vPC[2].u.operand).jsValue();
- JSValue shift = callFrame->r(vPC[3].u.operand).jsValue();
-
- if (val.isInt32() && shift.isInt32())
- callFrame->r(dst) = jsNumber(callFrame, val.asInt32() << (shift.asInt32() & 0x1f));
- else {
- JSValue result = jsNumber(callFrame, (val.toInt32(callFrame)) << (shift.toUInt32(callFrame) & 0x1f));
- CHECK_FOR_EXCEPTION();
- callFrame->r(dst) = result;
- }
-
- vPC += OPCODE_LENGTH(op_lshift);
- NEXT_INSTRUCTION();
- }
- DEFINE_OPCODE(op_rshift) {
- /* rshift dst(r) val(r) shift(r)
-
- Performs arithmetic right shift of register val (converted
- to int32) by register shift (converted to
- uint32), and puts the result in register dst.
- */
- int dst = vPC[1].u.operand;
- JSValue val = callFrame->r(vPC[2].u.operand).jsValue();
- JSValue shift = callFrame->r(vPC[3].u.operand).jsValue();
-
- if (val.isInt32() && shift.isInt32())
- callFrame->r(dst) = jsNumber(callFrame, val.asInt32() >> (shift.asInt32() & 0x1f));
- else {
- JSValue result = jsNumber(callFrame, (val.toInt32(callFrame)) >> (shift.toUInt32(callFrame) & 0x1f));
- CHECK_FOR_EXCEPTION();
- callFrame->r(dst) = result;
- }
-
- vPC += OPCODE_LENGTH(op_rshift);
- NEXT_INSTRUCTION();
- }
- DEFINE_OPCODE(op_urshift) {
- /* rshift dst(r) val(r) shift(r)
-
- Performs logical right shift of register val (converted
- to uint32) by register shift (converted to
- uint32), and puts the result in register dst.
- */
- int dst = vPC[1].u.operand;
- JSValue val = callFrame->r(vPC[2].u.operand).jsValue();
- JSValue shift = callFrame->r(vPC[3].u.operand).jsValue();
- if (val.isUInt32() && shift.isInt32())
- callFrame->r(dst) = jsNumber(callFrame, val.asInt32() >> (shift.asInt32() & 0x1f));
- else {
- JSValue result = jsNumber(callFrame, (val.toUInt32(callFrame)) >> (shift.toUInt32(callFrame) & 0x1f));
- CHECK_FOR_EXCEPTION();
- callFrame->r(dst) = result;
- }
-
- vPC += OPCODE_LENGTH(op_urshift);
- NEXT_INSTRUCTION();
- }
- DEFINE_OPCODE(op_bitand) {
- /* bitand dst(r) src1(r) src2(r)
-
- Computes bitwise AND of register src1 (converted to int32)
- and register src2 (converted to int32), and puts the result
- in register dst.
- */
- int dst = vPC[1].u.operand;
- JSValue src1 = callFrame->r(vPC[2].u.operand).jsValue();
- JSValue src2 = callFrame->r(vPC[3].u.operand).jsValue();
- if (src1.isInt32() && src2.isInt32())
- callFrame->r(dst) = jsNumber(callFrame, src1.asInt32() & src2.asInt32());
- else {
- JSValue result = jsNumber(callFrame, src1.toInt32(callFrame) & src2.toInt32(callFrame));
- CHECK_FOR_EXCEPTION();
- callFrame->r(dst) = result;
- }
-
- vPC += OPCODE_LENGTH(op_bitand);
- NEXT_INSTRUCTION();
- }
- DEFINE_OPCODE(op_bitxor) {
- /* bitxor dst(r) src1(r) src2(r)
-
- Computes bitwise XOR of register src1 (converted to int32)
- and register src2 (converted to int32), and puts the result
- in register dst.
- */
- int dst = vPC[1].u.operand;
- JSValue src1 = callFrame->r(vPC[2].u.operand).jsValue();
- JSValue src2 = callFrame->r(vPC[3].u.operand).jsValue();
- if (src1.isInt32() && src2.isInt32())
- callFrame->r(dst) = jsNumber(callFrame, src1.asInt32() ^ src2.asInt32());
- else {
- JSValue result = jsNumber(callFrame, src1.toInt32(callFrame) ^ src2.toInt32(callFrame));
- CHECK_FOR_EXCEPTION();
- callFrame->r(dst) = result;
- }
-
- vPC += OPCODE_LENGTH(op_bitxor);
- NEXT_INSTRUCTION();
- }
- DEFINE_OPCODE(op_bitor) {
- /* bitor dst(r) src1(r) src2(r)
-
- Computes bitwise OR of register src1 (converted to int32)
- and register src2 (converted to int32), and puts the
- result in register dst.
- */
- int dst = vPC[1].u.operand;
- JSValue src1 = callFrame->r(vPC[2].u.operand).jsValue();
- JSValue src2 = callFrame->r(vPC[3].u.operand).jsValue();
- if (src1.isInt32() && src2.isInt32())
- callFrame->r(dst) = jsNumber(callFrame, src1.asInt32() | src2.asInt32());
- else {
- JSValue result = jsNumber(callFrame, src1.toInt32(callFrame) | src2.toInt32(callFrame));
- CHECK_FOR_EXCEPTION();
- callFrame->r(dst) = result;
- }
-
- vPC += OPCODE_LENGTH(op_bitor);
- NEXT_INSTRUCTION();
- }
- DEFINE_OPCODE(op_bitnot) {
- /* bitnot dst(r) src(r)
-
- Computes bitwise NOT of register src1 (converted to int32),
- and puts the result in register dst.
- */
- int dst = vPC[1].u.operand;
- JSValue src = callFrame->r(vPC[2].u.operand).jsValue();
- if (src.isInt32())
- callFrame->r(dst) = jsNumber(callFrame, ~src.asInt32());
- else {
- JSValue result = jsNumber(callFrame, ~src.toInt32(callFrame));
- CHECK_FOR_EXCEPTION();
- callFrame->r(dst) = result;
- }
- vPC += OPCODE_LENGTH(op_bitnot);
- NEXT_INSTRUCTION();
- }
- DEFINE_OPCODE(op_not) {
- /* not dst(r) src(r)
-
- Computes logical NOT of register src (converted to
- boolean), and puts the result in register dst.
- */
- int dst = vPC[1].u.operand;
- int src = vPC[2].u.operand;
- JSValue result = jsBoolean(!callFrame->r(src).jsValue().toBoolean(callFrame));
- CHECK_FOR_EXCEPTION();
- callFrame->r(dst) = result;
-
- vPC += OPCODE_LENGTH(op_not);
- NEXT_INSTRUCTION();
- }
- DEFINE_OPCODE(op_instanceof) {
- /* instanceof dst(r) value(r) constructor(r) constructorProto(r)
-
- Tests whether register value is an instance of register
- constructor, and puts the boolean result in register
- dst. Register constructorProto must contain the "prototype"
- property (not the actual prototype) of the object in
- register constructor. This lookup is separated so that
- polymorphic inline caching can apply.
-
- Raises an exception if register constructor is not an
- object.
- */
- int dst = vPC[1].u.operand;
- int value = vPC[2].u.operand;
- int base = vPC[3].u.operand;
- int baseProto = vPC[4].u.operand;
-
- JSValue baseVal = callFrame->r(base).jsValue();
-
- if (isInvalidParamForInstanceOf(callFrame, callFrame->codeBlock(), vPC, baseVal, exceptionValue))
- goto vm_throw;
-
- bool result = asObject(baseVal)->hasInstance(callFrame, callFrame->r(value).jsValue(), callFrame->r(baseProto).jsValue());
- CHECK_FOR_EXCEPTION();
- callFrame->r(dst) = jsBoolean(result);
-
- vPC += OPCODE_LENGTH(op_instanceof);
- NEXT_INSTRUCTION();
- }
- DEFINE_OPCODE(op_typeof) {
- /* typeof dst(r) src(r)
-
- Determines the type string for src according to ECMAScript
- rules, and puts the result in register dst.
- */
- int dst = vPC[1].u.operand;
- int src = vPC[2].u.operand;
- callFrame->r(dst) = JSValue(jsTypeStringForValue(callFrame, callFrame->r(src).jsValue()));
-
- vPC += OPCODE_LENGTH(op_typeof);
- NEXT_INSTRUCTION();
- }
- DEFINE_OPCODE(op_is_undefined) {
- /* is_undefined dst(r) src(r)
-
- Determines whether the type string for src according to
- the ECMAScript rules is "undefined", and puts the result
- in register dst.
- */
- int dst = vPC[1].u.operand;
- int src = vPC[2].u.operand;
- JSValue v = callFrame->r(src).jsValue();
- callFrame->r(dst) = jsBoolean(v.isCell() ? v.asCell()->structure()->typeInfo().masqueradesAsUndefined() : v.isUndefined());
-
- vPC += OPCODE_LENGTH(op_is_undefined);
- NEXT_INSTRUCTION();
- }
- DEFINE_OPCODE(op_is_boolean) {
- /* is_boolean dst(r) src(r)
-
- Determines whether the type string for src according to
- the ECMAScript rules is "boolean", and puts the result
- in register dst.
- */
- int dst = vPC[1].u.operand;
- int src = vPC[2].u.operand;
- callFrame->r(dst) = jsBoolean(callFrame->r(src).jsValue().isBoolean());
-
- vPC += OPCODE_LENGTH(op_is_boolean);
- NEXT_INSTRUCTION();
- }
- DEFINE_OPCODE(op_is_number) {
- /* is_number dst(r) src(r)
-
- Determines whether the type string for src according to
- the ECMAScript rules is "number", and puts the result
- in register dst.
- */
- int dst = vPC[1].u.operand;
- int src = vPC[2].u.operand;
- callFrame->r(dst) = jsBoolean(callFrame->r(src).jsValue().isNumber());
-
- vPC += OPCODE_LENGTH(op_is_number);
- NEXT_INSTRUCTION();
- }
- DEFINE_OPCODE(op_is_string) {
- /* is_string dst(r) src(r)
-
- Determines whether the type string for src according to
- the ECMAScript rules is "string", and puts the result
- in register dst.
- */
- int dst = vPC[1].u.operand;
- int src = vPC[2].u.operand;
- callFrame->r(dst) = jsBoolean(callFrame->r(src).jsValue().isString());
-
- vPC += OPCODE_LENGTH(op_is_string);
- NEXT_INSTRUCTION();
- }
- DEFINE_OPCODE(op_is_object) {
- /* is_object dst(r) src(r)
-
- Determines whether the type string for src according to
- the ECMAScript rules is "object", and puts the result
- in register dst.
- */
- int dst = vPC[1].u.operand;
- int src = vPC[2].u.operand;
- callFrame->r(dst) = jsBoolean(jsIsObjectType(callFrame->r(src).jsValue()));
-
- vPC += OPCODE_LENGTH(op_is_object);
- NEXT_INSTRUCTION();
- }
- DEFINE_OPCODE(op_is_function) {
- /* is_function dst(r) src(r)
-
- Determines whether the type string for src according to
- the ECMAScript rules is "function", and puts the result
- in register dst.
- */
- int dst = vPC[1].u.operand;
- int src = vPC[2].u.operand;
- callFrame->r(dst) = jsBoolean(jsIsFunctionType(callFrame->r(src).jsValue()));
-
- vPC += OPCODE_LENGTH(op_is_function);
- NEXT_INSTRUCTION();
- }
- DEFINE_OPCODE(op_in) {
- /* in dst(r) property(r) base(r)
-
- Tests whether register base has a property named register
- property, and puts the boolean result in register dst.
-
- Raises an exception if register constructor is not an
- object.
- */
- int dst = vPC[1].u.operand;
- int property = vPC[2].u.operand;
- int base = vPC[3].u.operand;
-
- JSValue baseVal = callFrame->r(base).jsValue();
- if (isInvalidParamForIn(callFrame, callFrame->codeBlock(), vPC, baseVal, exceptionValue))
- goto vm_throw;
-
- JSObject* baseObj = asObject(baseVal);
-
- JSValue propName = callFrame->r(property).jsValue();
-
- uint32_t i;
- if (propName.getUInt32(i))
- callFrame->r(dst) = jsBoolean(baseObj->hasProperty(callFrame, i));
- else {
- Identifier property(callFrame, propName.toString(callFrame));
- CHECK_FOR_EXCEPTION();
- callFrame->r(dst) = jsBoolean(baseObj->hasProperty(callFrame, property));
- }
-
- vPC += OPCODE_LENGTH(op_in);
- NEXT_INSTRUCTION();
- }
- DEFINE_OPCODE(op_resolve) {
- /* resolve dst(r) property(id)
-
- Looks up the property named by identifier property in the
- scope chain, and writes the resulting value to register
- dst. If the property is not found, raises an exception.
- */
- if (UNLIKELY(!resolve(callFrame, vPC, exceptionValue)))
- goto vm_throw;
-
- vPC += OPCODE_LENGTH(op_resolve);
- NEXT_INSTRUCTION();
- }
- DEFINE_OPCODE(op_resolve_skip) {
- /* resolve_skip dst(r) property(id) skip(n)
-
- Looks up the property named by identifier property in the
- scope chain skipping the top 'skip' levels, and writes the resulting
- value to register dst. If the property is not found, raises an exception.
- */
- if (UNLIKELY(!resolveSkip(callFrame, vPC, exceptionValue)))
- goto vm_throw;
-
- vPC += OPCODE_LENGTH(op_resolve_skip);
-
- NEXT_INSTRUCTION();
- }
- DEFINE_OPCODE(op_resolve_global) {
- /* resolve_skip dst(r) globalObject(c) property(id) structure(sID) offset(n)
-
- Performs a dynamic property lookup for the given property, on the provided
- global object. If structure matches the Structure of the global then perform
- a fast lookup using the case offset, otherwise fall back to a full resolve and
- cache the new structure and offset
- */
- if (UNLIKELY(!resolveGlobal(callFrame, vPC, exceptionValue)))
- goto vm_throw;
-
- vPC += OPCODE_LENGTH(op_resolve_global);
-
- NEXT_INSTRUCTION();
- }
- DEFINE_OPCODE(op_get_global_var) {
- /* get_global_var dst(r) globalObject(c) index(n)
-
- Gets the global var at global slot index and places it in register dst.
- */
- int dst = vPC[1].u.operand;
- JSGlobalObject* scope = static_cast<JSGlobalObject*>(vPC[2].u.jsCell);
- ASSERT(scope->isGlobalObject());
- int index = vPC[3].u.operand;
-
- callFrame->r(dst) = scope->registerAt(index);
- vPC += OPCODE_LENGTH(op_get_global_var);
- NEXT_INSTRUCTION();
- }
- DEFINE_OPCODE(op_put_global_var) {
- /* put_global_var globalObject(c) index(n) value(r)
-
- Puts value into global slot index.
- */
- JSGlobalObject* scope = static_cast<JSGlobalObject*>(vPC[1].u.jsCell);
- ASSERT(scope->isGlobalObject());
- int index = vPC[2].u.operand;
- int value = vPC[3].u.operand;
-
- scope->registerAt(index) = JSValue(callFrame->r(value).jsValue());
- vPC += OPCODE_LENGTH(op_put_global_var);
- NEXT_INSTRUCTION();
- }
- DEFINE_OPCODE(op_get_scoped_var) {
- /* 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
- */
- int dst = vPC[1].u.operand;
- int index = vPC[2].u.operand;
- int skip = vPC[3].u.operand + callFrame->codeBlock()->needsFullScopeChain();
-
- ScopeChainNode* scopeChain = callFrame->scopeChain();
- ScopeChainIterator iter = scopeChain->begin();
- ScopeChainIterator end = scopeChain->end();
- ASSERT(iter != end);
- while (skip--) {
- ++iter;
- ASSERT(iter != end);
- }
-
- ASSERT((*iter)->isVariableObject());
- JSVariableObject* scope = static_cast<JSVariableObject*>(*iter);
- callFrame->r(dst) = scope->registerAt(index);
- vPC += OPCODE_LENGTH(op_get_scoped_var);
- NEXT_INSTRUCTION();
- }
- DEFINE_OPCODE(op_put_scoped_var) {
- /* put_scoped_var index(n) skip(n) value(r)
-
- */
- int index = vPC[1].u.operand;
- int skip = vPC[2].u.operand + callFrame->codeBlock()->needsFullScopeChain();
- int value = vPC[3].u.operand;
-
- ScopeChainNode* scopeChain = callFrame->scopeChain();
- ScopeChainIterator iter = scopeChain->begin();
- ScopeChainIterator end = scopeChain->end();
- ASSERT(iter != end);
- while (skip--) {
- ++iter;
- ASSERT(iter != end);
- }
-
- ASSERT((*iter)->isVariableObject());
- JSVariableObject* scope = static_cast<JSVariableObject*>(*iter);
- scope->registerAt(index) = JSValue(callFrame->r(value).jsValue());
- vPC += OPCODE_LENGTH(op_put_scoped_var);
- NEXT_INSTRUCTION();
- }
- DEFINE_OPCODE(op_resolve_base) {
- /* resolve_base dst(r) property(id)
-
- Searches the scope chain for an object containing
- identifier property, and if one is found, writes it to
- register dst. If none is found, the outermost scope (which
- will be the global object) is stored in register dst.
- */
- resolveBase(callFrame, vPC);
-
- vPC += OPCODE_LENGTH(op_resolve_base);
- NEXT_INSTRUCTION();
- }
- DEFINE_OPCODE(op_resolve_with_base) {
- /* resolve_with_base baseDst(r) propDst(r) property(id)
-
- Searches the scope chain for an object containing
- identifier property, and if one is found, writes it to
- register srcDst, and the retrieved property value to register
- propDst. If the property is not found, raises an exception.
-
- This is more efficient than doing resolve_base followed by
- resolve, or resolve_base followed by get_by_id, as it
- avoids duplicate hash lookups.
- */
- if (UNLIKELY(!resolveBaseAndProperty(callFrame, vPC, exceptionValue)))
- goto vm_throw;
-
- vPC += OPCODE_LENGTH(op_resolve_with_base);
- NEXT_INSTRUCTION();
- }
- DEFINE_OPCODE(op_get_by_id) {
- /* get_by_id dst(r) base(r) property(id) structure(sID) nop(n) nop(n) nop(n)
-
- Generic property access: Gets the property named by identifier
- property from the value base, and puts the result in register dst.
- */
- int dst = vPC[1].u.operand;
- 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);
- JSValue result = baseValue.get(callFrame, ident, slot);
- CHECK_FOR_EXCEPTION();
-
- tryCacheGetByID(callFrame, codeBlock, vPC, baseValue, ident, slot);
-
- callFrame->r(dst) = result;
- vPC += OPCODE_LENGTH(op_get_by_id);
- NEXT_INSTRUCTION();
- }
- DEFINE_OPCODE(op_get_by_id_self) {
- /* op_get_by_id_self dst(r) base(r) property(id) structure(sID) offset(n) nop(n) nop(n)
-
- Cached property access: Attempts to get a cached property from the
- value base. If the cache misses, op_get_by_id_self reverts to
- op_get_by_id.
- */
- int base = vPC[2].u.operand;
- JSValue baseValue = callFrame->r(base).jsValue();
-
- if (LIKELY(baseValue.isCell())) {
- JSCell* baseCell = asCell(baseValue);
- Structure* structure = vPC[4].u.structure;
-
- if (LIKELY(baseCell->structure() == structure)) {
- ASSERT(baseCell->isObject());
- JSObject* baseObject = asObject(baseCell);
- 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));
- callFrame->r(dst) = JSValue(baseObject->getDirectOffset(offset));
-
- vPC += OPCODE_LENGTH(op_get_by_id_self);
- NEXT_INSTRUCTION();
- }
- }
-
- uncacheGetByID(callFrame->codeBlock(), vPC);
- NEXT_INSTRUCTION();
- }
- DEFINE_OPCODE(op_get_by_id_proto) {
- /* op_get_by_id_proto dst(r) base(r) property(id) structure(sID) prototypeStructure(sID) offset(n) nop(n)
-
- Cached property access: Attempts to get a cached property from the
- value base's prototype. If the cache misses, op_get_by_id_proto
- reverts to op_get_by_id.
- */
- int base = vPC[2].u.operand;
- JSValue baseValue = callFrame->r(base).jsValue();
-
- if (LIKELY(baseValue.isCell())) {
- JSCell* baseCell = asCell(baseValue);
- Structure* structure = vPC[4].u.structure;
-
- if (LIKELY(baseCell->structure() == structure)) {
- ASSERT(structure->prototypeForLookup(callFrame).isObject());
- JSObject* protoObject = asObject(structure->prototypeForLookup(callFrame));
- Structure* prototypeStructure = vPC[5].u.structure;
-
- if (LIKELY(protoObject->structure() == prototypeStructure)) {
- 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));
- callFrame->r(dst) = JSValue(protoObject->getDirectOffset(offset));
-
- vPC += OPCODE_LENGTH(op_get_by_id_proto);
- NEXT_INSTRUCTION();
- }
- }
- }
-
- uncacheGetByID(callFrame->codeBlock(), vPC);
- NEXT_INSTRUCTION();
- }
- DEFINE_OPCODE(op_get_by_id_self_list) {
- // Polymorphic self access caching currently only supported when JITting.
- ASSERT_NOT_REACHED();
- // This case of the switch must not be empty, else (op_get_by_id_self_list == op_get_by_id_chain)!
- vPC += OPCODE_LENGTH(op_get_by_id_self_list);
- NEXT_INSTRUCTION();
- }
- DEFINE_OPCODE(op_get_by_id_proto_list) {
- // Polymorphic prototype access caching currently only supported when JITting.
- ASSERT_NOT_REACHED();
- // This case of the switch must not be empty, else (op_get_by_id_proto_list == op_get_by_id_chain)!
- vPC += OPCODE_LENGTH(op_get_by_id_proto_list);
- NEXT_INSTRUCTION();
- }
- DEFINE_OPCODE(op_get_by_id_chain) {
- /* op_get_by_id_chain dst(r) base(r) property(id) structure(sID) structureChain(chain) count(n) offset(n)
-
- Cached property access: Attempts to get a cached property from the
- value base's prototype chain. If the cache misses, op_get_by_id_chain
- reverts to op_get_by_id.
- */
- int base = vPC[2].u.operand;
- JSValue baseValue = callFrame->r(base).jsValue();
-
- if (LIKELY(baseValue.isCell())) {
- JSCell* baseCell = asCell(baseValue);
- Structure* structure = vPC[4].u.structure;
-
- if (LIKELY(baseCell->structure() == structure)) {
- RefPtr<Structure>* it = vPC[5].u.structureChain->head();
- size_t count = vPC[6].u.operand;
- RefPtr<Structure>* end = it + count;
-
- while (true) {
- JSObject* baseObject = asObject(baseCell->structure()->prototypeForLookup(callFrame));
-
- if (UNLIKELY(baseObject->structure() != (*it).get()))
- break;
-
- if (++it == end) {
- 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));
- callFrame->r(dst) = JSValue(baseObject->getDirectOffset(offset));
-
- vPC += OPCODE_LENGTH(op_get_by_id_chain);
- NEXT_INSTRUCTION();
- }
-
- // Update baseCell, so that next time around the loop we'll pick up the prototype's prototype.
- baseCell = baseObject;
- }
- }
- }
-
- uncacheGetByID(callFrame->codeBlock(), vPC);
- NEXT_INSTRUCTION();
- }
- DEFINE_OPCODE(op_get_by_id_generic) {
- /* op_get_by_id_generic dst(r) base(r) property(id) nop(sID) nop(n) nop(n) nop(n)
-
- Generic property access: Gets the property named by identifier
- property from the value base, and puts the result in register dst.
- */
- int dst = vPC[1].u.operand;
- int base = vPC[2].u.operand;
- int property = vPC[3].u.operand;
-
- Identifier& ident = callFrame->codeBlock()->identifier(property);
- JSValue baseValue = callFrame->r(base).jsValue();
- PropertySlot slot(baseValue);
- JSValue result = baseValue.get(callFrame, ident, slot);
- CHECK_FOR_EXCEPTION();
-
- callFrame->r(dst) = result;
- vPC += OPCODE_LENGTH(op_get_by_id_generic);
- NEXT_INSTRUCTION();
- }
- DEFINE_OPCODE(op_get_array_length) {
- /* op_get_array_length dst(r) base(r) property(id) nop(sID) nop(n) nop(n) nop(n)
-
- Cached property access: Gets the length of the array in register base,
- and puts the result in register dst. If register base does not hold
- an array, op_get_array_length reverts to op_get_by_id.
- */
-
- int base = vPC[2].u.operand;
- JSValue baseValue = callFrame->r(base).jsValue();
- if (LIKELY(isJSArray(globalData, baseValue))) {
- int dst = vPC[1].u.operand;
- callFrame->r(dst) = jsNumber(callFrame, asArray(baseValue)->length());
- vPC += OPCODE_LENGTH(op_get_array_length);
- NEXT_INSTRUCTION();
- }
-
- uncacheGetByID(callFrame->codeBlock(), vPC);
- NEXT_INSTRUCTION();
- }
- DEFINE_OPCODE(op_get_string_length) {
- /* op_get_string_length dst(r) base(r) property(id) nop(sID) nop(n) nop(n) nop(n)
-
- Cached property access: Gets the length of the string in register base,
- and puts the result in register dst. If register base does not hold
- a string, op_get_string_length reverts to op_get_by_id.
- */
-
- int base = vPC[2].u.operand;
- JSValue baseValue = callFrame->r(base).jsValue();
- if (LIKELY(isJSString(globalData, baseValue))) {
- int dst = vPC[1].u.operand;
- callFrame->r(dst) = jsNumber(callFrame, asString(baseValue)->length());
- vPC += OPCODE_LENGTH(op_get_string_length);
- NEXT_INSTRUCTION();
- }
-
- uncacheGetByID(callFrame->codeBlock(), vPC);
- NEXT_INSTRUCTION();
- }
- DEFINE_OPCODE(op_put_by_id) {
- /* put_by_id base(r) property(id) value(r) nop(n) nop(n) nop(n) nop(n)
-
- Generic property access: Sets the property named by identifier
- property, belonging to register base, to register value.
-
- 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 value = vPC[3].u.operand;
-
- CodeBlock* codeBlock = callFrame->codeBlock();
- JSValue baseValue = callFrame->r(base).jsValue();
- Identifier& ident = codeBlock->identifier(property);
- PutPropertySlot slot;
- baseValue.put(callFrame, ident, callFrame->r(value).jsValue(), slot);
- CHECK_FOR_EXCEPTION();
-
- tryCachePutByID(callFrame, codeBlock, vPC, baseValue, slot);
-
- vPC += OPCODE_LENGTH(op_put_by_id);
- NEXT_INSTRUCTION();
- }
- DEFINE_OPCODE(op_put_by_id_transition) {
- /* op_put_by_id_transition base(r) property(id) value(r) oldStructure(sID) newStructure(sID) structureChain(chain) offset(n)
-
- Cached property access: Attempts to set a new property with a cached transition
- property named by identifier property, belonging to register base,
- to register value. If the cache misses, op_put_by_id_transition
- reverts to op_put_by_id_generic.
-
- Unlike many opcodes, this one does not write any output to
- the register file.
- */
- int base = vPC[1].u.operand;
- JSValue baseValue = callFrame->r(base).jsValue();
-
- if (LIKELY(baseValue.isCell())) {
- JSCell* baseCell = asCell(baseValue);
- Structure* oldStructure = vPC[4].u.structure;
- Structure* newStructure = vPC[5].u.structure;
-
- if (LIKELY(baseCell->structure() == oldStructure)) {
- ASSERT(baseCell->isObject());
- JSObject* baseObject = asObject(baseCell);
-
- RefPtr<Structure>* it = vPC[6].u.structureChain->head();
-
- JSValue proto = baseObject->structure()->prototypeForLookup(callFrame);
- while (!proto.isNull()) {
- if (UNLIKELY(asObject(proto)->structure() != (*it).get())) {
- uncachePutByID(callFrame->codeBlock(), vPC);
- NEXT_INSTRUCTION();
- }
- ++it;
- proto = asObject(proto)->structure()->prototypeForLookup(callFrame);
- }
-
- baseObject->transitionTo(newStructure);
-
- 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);
- baseObject->putDirectOffset(offset, callFrame->r(value).jsValue());
-
- vPC += OPCODE_LENGTH(op_put_by_id_transition);
- NEXT_INSTRUCTION();
- }
- }
-
- uncachePutByID(callFrame->codeBlock(), vPC);
- NEXT_INSTRUCTION();
- }
- DEFINE_OPCODE(op_put_by_id_replace) {
- /* op_put_by_id_replace base(r) property(id) value(r) structure(sID) offset(n) nop(n) nop(n)
-
- Cached property access: Attempts to set a pre-existing, cached
- property named by identifier property, belonging to register base,
- to register value. If the cache misses, op_put_by_id_replace
- reverts to op_put_by_id.
-
- Unlike many opcodes, this one does not write any output to
- the register file.
- */
- int base = vPC[1].u.operand;
- JSValue baseValue = callFrame->r(base).jsValue();
-
- if (LIKELY(baseValue.isCell())) {
- JSCell* baseCell = asCell(baseValue);
- Structure* structure = vPC[4].u.structure;
-
- if (LIKELY(baseCell->structure() == structure)) {
- ASSERT(baseCell->isObject());
- JSObject* baseObject = asObject(baseCell);
- 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);
- baseObject->putDirectOffset(offset, callFrame->r(value).jsValue());
-
- vPC += OPCODE_LENGTH(op_put_by_id_replace);
- NEXT_INSTRUCTION();
- }
- }
-
- uncachePutByID(callFrame->codeBlock(), vPC);
- NEXT_INSTRUCTION();
- }
- DEFINE_OPCODE(op_put_by_id_generic) {
- /* op_put_by_id_generic base(r) property(id) value(r) nop(n) nop(n) nop(n) nop(n)
-
- Generic property access: Sets the property named by identifier
- property, belonging to register base, to register value.
-
- 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 value = vPC[3].u.operand;
-
- JSValue baseValue = callFrame->r(base).jsValue();
- Identifier& ident = callFrame->codeBlock()->identifier(property);
- PutPropertySlot slot;
- baseValue.put(callFrame, ident, callFrame->r(value).jsValue(), slot);
- CHECK_FOR_EXCEPTION();
-
- vPC += OPCODE_LENGTH(op_put_by_id_generic);
- NEXT_INSTRUCTION();
- }
- DEFINE_OPCODE(op_del_by_id) {
- /* del_by_id dst(r) base(r) property(id)
-
- Converts register base to Object, deletes the property
- named by identifier property from the object, and writes a
- boolean indicating success (if true) or failure (if false)
- to register dst.
- */
- int dst = vPC[1].u.operand;
- int base = vPC[2].u.operand;
- int property = vPC[3].u.operand;
-
- JSObject* baseObj = callFrame->r(base).jsValue().toObject(callFrame);
- Identifier& ident = callFrame->codeBlock()->identifier(property);
- JSValue result = jsBoolean(baseObj->deleteProperty(callFrame, ident));
- CHECK_FOR_EXCEPTION();
- callFrame->r(dst) = result;
- vPC += OPCODE_LENGTH(op_del_by_id);
- NEXT_INSTRUCTION();
- }
- DEFINE_OPCODE(op_get_by_pname) {
- int dst = vPC[1].u.operand;
- int base = vPC[2].u.operand;
- int property = vPC[3].u.operand;
- int expected = vPC[4].u.operand;
- int iter = vPC[5].u.operand;
- int i = vPC[6].u.operand;
-
- JSValue baseValue = callFrame->r(base).jsValue();
- JSPropertyNameIterator* it = callFrame->r(iter).propertyNameIterator();
- JSValue subscript = callFrame->r(property).jsValue();
- JSValue expectedSubscript = callFrame->r(expected).jsValue();
- int index = callFrame->r(i).i() - 1;
- JSValue result;
- int offset = 0;
- if (subscript == expectedSubscript && baseValue.isCell() && (baseValue.asCell()->structure() == it->cachedStructure()) && it->getOffset(index, offset)) {
- callFrame->r(dst) = asObject(baseValue)->getDirectOffset(offset);
- vPC += OPCODE_LENGTH(op_get_by_pname);
- NEXT_INSTRUCTION();
- }
- Identifier propertyName(callFrame, subscript.toString(callFrame));
- result = baseValue.get(callFrame, propertyName);
- CHECK_FOR_EXCEPTION();
- callFrame->r(dst) = result;
- vPC += OPCODE_LENGTH(op_get_by_pname);
- NEXT_INSTRUCTION();
- }
- DEFINE_OPCODE(op_get_by_val) {
- /* get_by_val dst(r) base(r) property(r)
-
- Converts register base to Object, gets the property named
- by register property from the object, and puts the result
- in register dst. property is nominally converted to string
- but numbers are treated more efficiently.
- */
- int dst = vPC[1].u.operand;
- int base = vPC[2].u.operand;
- int property = vPC[3].u.operand;
-
- JSValue baseValue = callFrame->r(base).jsValue();
- JSValue subscript = callFrame->r(property).jsValue();
-
- JSValue result;
-
- if (LIKELY(subscript.isUInt32())) {
- uint32_t i = subscript.asUInt32();
- if (isJSArray(globalData, baseValue)) {
- JSArray* jsArray = asArray(baseValue);
- if (jsArray->canGetIndex(i))
- result = jsArray->getIndex(i);
- else
- result = jsArray->JSArray::get(callFrame, i);
- } else if (isJSString(globalData, baseValue) && asString(baseValue)->canGetIndex(i))
- result = asString(baseValue)->getIndex(callFrame, i);
- else if (isJSByteArray(globalData, baseValue) && asByteArray(baseValue)->canAccessIndex(i))
- result = asByteArray(baseValue)->getIndex(callFrame, i);
- else
- result = baseValue.get(callFrame, i);
- } else {
- Identifier property(callFrame, subscript.toString(callFrame));
- result = baseValue.get(callFrame, property);
- }
-
- CHECK_FOR_EXCEPTION();
- callFrame->r(dst) = result;
- vPC += OPCODE_LENGTH(op_get_by_val);
- NEXT_INSTRUCTION();
- }
- DEFINE_OPCODE(op_put_by_val) {
- /* put_by_val base(r) property(r) value(r)
-
- Sets register value on register base as the property named
- by register property. Base is converted to object
- first. register property is nominally converted to string
- but numbers are treated more efficiently.
-
- 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 value = vPC[3].u.operand;
-
- JSValue baseValue = callFrame->r(base).jsValue();
- JSValue subscript = callFrame->r(property).jsValue();
-
- if (LIKELY(subscript.isUInt32())) {
- uint32_t i = subscript.asUInt32();
- if (isJSArray(globalData, baseValue)) {
- JSArray* jsArray = asArray(baseValue);
- if (jsArray->canSetIndex(i))
- jsArray->setIndex(i, callFrame->r(value).jsValue());
- else
- jsArray->JSArray::put(callFrame, i, callFrame->r(value).jsValue());
- } else if (isJSByteArray(globalData, baseValue) && asByteArray(baseValue)->canAccessIndex(i)) {
- JSByteArray* jsByteArray = asByteArray(baseValue);
- double dValue = 0;
- JSValue jsValue = callFrame->r(value).jsValue();
- if (jsValue.isInt32())
- jsByteArray->setIndex(i, jsValue.asInt32());
- else if (jsValue.getNumber(dValue))
- jsByteArray->setIndex(i, dValue);
- else
- baseValue.put(callFrame, i, jsValue);
- } else
- baseValue.put(callFrame, i, callFrame->r(value).jsValue());
- } else {
- Identifier property(callFrame, subscript.toString(callFrame));
- if (!globalData->exception) { // Don't put to an object if toString threw an exception.
- PutPropertySlot slot;
- baseValue.put(callFrame, property, callFrame->r(value).jsValue(), slot);
- }
- }
-
- CHECK_FOR_EXCEPTION();
- vPC += OPCODE_LENGTH(op_put_by_val);
- NEXT_INSTRUCTION();
- }
- DEFINE_OPCODE(op_del_by_val) {
- /* del_by_val dst(r) base(r) property(r)
-
- Converts register base to Object, deletes the property
- named by register property from the object, and writes a
- boolean indicating success (if true) or failure (if false)
- to register dst.
- */
- int dst = vPC[1].u.operand;
- int base = vPC[2].u.operand;
- int property = vPC[3].u.operand;
-
- JSObject* baseObj = callFrame->r(base).jsValue().toObject(callFrame); // may throw
-
- JSValue subscript = callFrame->r(property).jsValue();
- JSValue result;
- uint32_t i;
- if (subscript.getUInt32(i))
- result = jsBoolean(baseObj->deleteProperty(callFrame, i));
- else {
- CHECK_FOR_EXCEPTION();
- Identifier property(callFrame, subscript.toString(callFrame));
- CHECK_FOR_EXCEPTION();
- result = jsBoolean(baseObj->deleteProperty(callFrame, property));
- }
-
- CHECK_FOR_EXCEPTION();
- callFrame->r(dst) = result;
- vPC += OPCODE_LENGTH(op_del_by_val);
- NEXT_INSTRUCTION();
- }
- DEFINE_OPCODE(op_put_by_index) {
- /* put_by_index base(r) property(n) value(r)
-
- Sets register value on register base as the property named
- by the immediate number property. Base is converted to
- object first.
-
- Unlike many opcodes, this one does not write any output to
- the register file.
-
- This opcode is mainly used to initialize array literals.
- */
- int base = vPC[1].u.operand;
- unsigned property = vPC[2].u.operand;
- int value = vPC[3].u.operand;
-
- callFrame->r(base).jsValue().put(callFrame, property, callFrame->r(value).jsValue());
-
- vPC += OPCODE_LENGTH(op_put_by_index);
- NEXT_INSTRUCTION();
- }
- DEFINE_OPCODE(op_loop) {
- /* loop target(offset)
-
- Jumps unconditionally to offset target from the current
- instruction.
-
- Additionally this loop instruction may terminate JS execution is
- the JS timeout is reached.
- */
-#if ENABLE(OPCODE_STATS)
- OpcodeStats::resetLastInstruction();
-#endif
- int target = vPC[1].u.operand;
- CHECK_FOR_TIMEOUT();
- vPC += target;
- NEXT_INSTRUCTION();
- }
- DEFINE_OPCODE(op_jmp) {
- /* jmp target(offset)
-
- Jumps unconditionally to offset target from the current
- instruction.
- */
-#if ENABLE(OPCODE_STATS)
- OpcodeStats::resetLastInstruction();
-#endif
- int target = vPC[1].u.operand;
-
- vPC += target;
- NEXT_INSTRUCTION();
- }
- DEFINE_OPCODE(op_loop_if_true) {
- /* loop_if_true cond(r) target(offset)
-
- Jumps to offset target from the current instruction, if and
- only if register cond converts to boolean as true.
-
- Additionally this loop instruction may terminate JS execution is
- the JS timeout is reached.
- */
- int cond = vPC[1].u.operand;
- int target = vPC[2].u.operand;
- if (callFrame->r(cond).jsValue().toBoolean(callFrame)) {
- vPC += target;
- CHECK_FOR_TIMEOUT();
- NEXT_INSTRUCTION();
- }
-
- vPC += OPCODE_LENGTH(op_loop_if_true);
- NEXT_INSTRUCTION();
- }
- DEFINE_OPCODE(op_loop_if_false) {
- /* loop_if_true cond(r) target(offset)
-
- Jumps to offset target from the current instruction, if and
- only if register cond converts to boolean as false.
-
- Additionally this loop instruction may terminate JS execution is
- the JS timeout is reached.
- */
- int cond = vPC[1].u.operand;
- int target = vPC[2].u.operand;
- if (!callFrame->r(cond).jsValue().toBoolean(callFrame)) {
- vPC += target;
- CHECK_FOR_TIMEOUT();
- NEXT_INSTRUCTION();
- }
-
- vPC += OPCODE_LENGTH(op_loop_if_true);
- NEXT_INSTRUCTION();
- }
- DEFINE_OPCODE(op_jtrue) {
- /* jtrue cond(r) target(offset)
-
- Jumps to offset target from the current instruction, if and
- only if register cond converts to boolean as true.
- */
- int cond = vPC[1].u.operand;
- int target = vPC[2].u.operand;
- if (callFrame->r(cond).jsValue().toBoolean(callFrame)) {
- vPC += target;
- NEXT_INSTRUCTION();
- }
-
- vPC += OPCODE_LENGTH(op_jtrue);
- NEXT_INSTRUCTION();
- }
- DEFINE_OPCODE(op_jfalse) {
- /* jfalse cond(r) target(offset)
-
- Jumps to offset target from the current instruction, if and
- only if register cond converts to boolean as false.
- */
- int cond = vPC[1].u.operand;
- int target = vPC[2].u.operand;
- if (!callFrame->r(cond).jsValue().toBoolean(callFrame)) {
- vPC += target;
- NEXT_INSTRUCTION();
- }