📄 jitstubs.cpp
字号:
JSValuePtr result = jsNumber(ARG_globalData, src1.toInt32(callFrame) & src2.toInt32(callFrame)); CHECK_FOR_EXCEPTION_AT_END(); return JSValuePtr::encode(result);}JSValueEncodedAsPointer* JITStubs::cti_op_rshift(STUB_ARGS){ BEGIN_STUB_FUNCTION(); JSValuePtr val = ARG_src1; JSValuePtr shift = ARG_src2; int32_t left; uint32_t right; if (JSFastMath::canDoFastRshift(val, shift)) return JSValuePtr::encode(JSFastMath::rightShiftImmediateNumbers(val, shift)); if (val.numberToInt32(left) && shift.numberToUInt32(right)) return JSValuePtr::encode(jsNumber(ARG_globalData, left >> (right & 0x1f))); CallFrame* callFrame = ARG_callFrame; JSValuePtr result = jsNumber(ARG_globalData, (val.toInt32(callFrame)) >> (shift.toUInt32(callFrame) & 0x1f)); CHECK_FOR_EXCEPTION_AT_END(); return JSValuePtr::encode(result);}JSValueEncodedAsPointer* JITStubs::cti_op_bitnot(STUB_ARGS){ BEGIN_STUB_FUNCTION(); JSValuePtr src = ARG_src1; int value; if (src.numberToInt32(value)) return JSValuePtr::encode(jsNumber(ARG_globalData, ~value)); CallFrame* callFrame = ARG_callFrame; JSValuePtr result = jsNumber(ARG_globalData, ~src.toInt32(callFrame)); CHECK_FOR_EXCEPTION_AT_END(); return JSValuePtr::encode(result);}VoidPtrPair JITStubs::cti_op_resolve_with_base(STUB_ARGS){ BEGIN_STUB_FUNCTION(); CallFrame* callFrame = ARG_callFrame; ScopeChainNode* scopeChain = callFrame->scopeChain(); ScopeChainIterator iter = scopeChain->begin(); ScopeChainIterator end = scopeChain->end(); // FIXME: add scopeDepthIsZero optimization ASSERT(iter != end); Identifier& ident = *ARG_id1; JSObject* base; do { base = *iter; PropertySlot slot(base); if (base->getPropertySlot(callFrame, ident, slot)) { JSValuePtr result = slot.getValue(callFrame, ident); CHECK_FOR_EXCEPTION_AT_END(); RETURN_PAIR(base, JSValuePtr::encode(result)); } ++iter; } while (iter != end); CodeBlock* codeBlock = callFrame->codeBlock(); unsigned vPCIndex = codeBlock->getBytecodeIndex(callFrame, STUB_RETURN_ADDRESS); ARG_globalData->exception = createUndefinedVariableError(callFrame, ident, vPCIndex, codeBlock); VM_THROW_EXCEPTION_2();}JSObject* JITStubs::cti_op_new_func_exp(STUB_ARGS){ BEGIN_STUB_FUNCTION(); return ARG_funcexp1->makeFunction(ARG_callFrame, ARG_callFrame->scopeChain());}JSValueEncodedAsPointer* JITStubs::cti_op_mod(STUB_ARGS){ BEGIN_STUB_FUNCTION(); JSValuePtr dividendValue = ARG_src1; JSValuePtr divisorValue = ARG_src2; CallFrame* callFrame = ARG_callFrame; double d = dividendValue.toNumber(callFrame); JSValuePtr result = jsNumber(ARG_globalData, fmod(d, divisorValue.toNumber(callFrame))); CHECK_FOR_EXCEPTION_AT_END(); return JSValuePtr::encode(result);}JSValueEncodedAsPointer* JITStubs::cti_op_less(STUB_ARGS){ BEGIN_STUB_FUNCTION(); CallFrame* callFrame = ARG_callFrame; JSValuePtr result = jsBoolean(jsLess(callFrame, ARG_src1, ARG_src2)); CHECK_FOR_EXCEPTION_AT_END(); return JSValuePtr::encode(result);}JSValueEncodedAsPointer* JITStubs::cti_op_neq(STUB_ARGS){ BEGIN_STUB_FUNCTION(); JSValuePtr src1 = ARG_src1; JSValuePtr src2 = ARG_src2; ASSERT(!JSValuePtr::areBothInt32Fast(src1, src2)); CallFrame* callFrame = ARG_callFrame; JSValuePtr result = jsBoolean(!JSValuePtr::equalSlowCaseInline(callFrame, src1, src2)); CHECK_FOR_EXCEPTION_AT_END(); return JSValuePtr::encode(result);}VoidPtrPair JITStubs::cti_op_post_dec(STUB_ARGS){ BEGIN_STUB_FUNCTION(); JSValuePtr v = ARG_src1; CallFrame* callFrame = ARG_callFrame; JSValuePtr number = v.toJSNumber(callFrame); CHECK_FOR_EXCEPTION_AT_END(); RETURN_PAIR(JSValuePtr::encode(number), JSValuePtr::encode(jsNumber(ARG_globalData, number.uncheckedGetNumber() - 1)));}JSValueEncodedAsPointer* JITStubs::cti_op_urshift(STUB_ARGS){ BEGIN_STUB_FUNCTION(); JSValuePtr val = ARG_src1; JSValuePtr shift = ARG_src2; CallFrame* callFrame = ARG_callFrame; if (JSFastMath::canDoFastUrshift(val, shift)) return JSValuePtr::encode(JSFastMath::rightShiftImmediateNumbers(val, shift)); else { JSValuePtr result = jsNumber(ARG_globalData, (val.toUInt32(callFrame)) >> (shift.toUInt32(callFrame) & 0x1f)); CHECK_FOR_EXCEPTION_AT_END(); return JSValuePtr::encode(result); }}JSValueEncodedAsPointer* JITStubs::cti_op_bitxor(STUB_ARGS){ BEGIN_STUB_FUNCTION(); JSValuePtr src1 = ARG_src1; JSValuePtr src2 = ARG_src2; CallFrame* callFrame = ARG_callFrame; JSValuePtr result = jsNumber(ARG_globalData, src1.toInt32(callFrame) ^ src2.toInt32(callFrame)); CHECK_FOR_EXCEPTION_AT_END(); return JSValuePtr::encode(result);}JSObject* JITStubs::cti_op_new_regexp(STUB_ARGS){ BEGIN_STUB_FUNCTION(); return new (ARG_globalData) RegExpObject(ARG_callFrame->lexicalGlobalObject()->regExpStructure(), ARG_regexp1);}JSValueEncodedAsPointer* JITStubs::cti_op_bitor(STUB_ARGS){ BEGIN_STUB_FUNCTION(); JSValuePtr src1 = ARG_src1; JSValuePtr src2 = ARG_src2; CallFrame* callFrame = ARG_callFrame; JSValuePtr result = jsNumber(ARG_globalData, src1.toInt32(callFrame) | src2.toInt32(callFrame)); CHECK_FOR_EXCEPTION_AT_END(); return JSValuePtr::encode(result);}JSValueEncodedAsPointer* JITStubs::cti_op_call_eval(STUB_ARGS){ BEGIN_STUB_FUNCTION(); CallFrame* callFrame = ARG_callFrame; RegisterFile* registerFile = ARG_registerFile; Interpreter* interpreter = ARG_globalData->interpreter; JSValuePtr funcVal = ARG_src1; int registerOffset = ARG_int2; int argCount = ARG_int3; Register* newCallFrame = callFrame->registers() + registerOffset; Register* argv = newCallFrame - RegisterFile::CallFrameHeaderSize - argCount; JSValuePtr thisValue = argv[0].jsValue(callFrame); JSGlobalObject* globalObject = callFrame->scopeChain()->globalObject(); if (thisValue == globalObject && funcVal == globalObject->evalFunction()) { JSValuePtr exceptionValue = noValue(); JSValuePtr result = interpreter->callEval(callFrame, registerFile, argv, argCount, registerOffset, exceptionValue); if (UNLIKELY(exceptionValue != noValue())) { ARG_globalData->exception = exceptionValue; VM_THROW_EXCEPTION_AT_END(); } return JSValuePtr::encode(result); } return JSValuePtr::encode(jsImpossibleValue());}JSValueEncodedAsPointer* JITStubs::cti_op_throw(STUB_ARGS){ BEGIN_STUB_FUNCTION(); CallFrame* callFrame = ARG_callFrame; CodeBlock* codeBlock = callFrame->codeBlock(); unsigned vPCIndex = codeBlock->getBytecodeIndex(callFrame, STUB_RETURN_ADDRESS); JSValuePtr exceptionValue = ARG_src1; ASSERT(exceptionValue); HandlerInfo* handler = ARG_globalData->interpreter->throwException(callFrame, exceptionValue, vPCIndex, true); if (!handler) { *ARG_exception = exceptionValue; return JSValuePtr::encode(jsNull()); } ARG_setCallFrame(callFrame); void* catchRoutine = handler->nativeCode.addressForExceptionHandler(); ASSERT(catchRoutine); STUB_SET_RETURN_ADDRESS(catchRoutine); return JSValuePtr::encode(exceptionValue);}JSPropertyNameIterator* JITStubs::cti_op_get_pnames(STUB_ARGS){ BEGIN_STUB_FUNCTION(); return JSPropertyNameIterator::create(ARG_callFrame, ARG_src1);}JSValueEncodedAsPointer* JITStubs::cti_op_next_pname(STUB_ARGS){ BEGIN_STUB_FUNCTION(); JSPropertyNameIterator* it = ARG_pni1; JSValuePtr temp = it->next(ARG_callFrame); if (!temp) it->invalidate(); return JSValuePtr::encode(temp);}JSObject* JITStubs::cti_op_push_scope(STUB_ARGS){ BEGIN_STUB_FUNCTION(); JSObject* o = ARG_src1.toObject(ARG_callFrame); CHECK_FOR_EXCEPTION(); ARG_callFrame->setScopeChain(ARG_callFrame->scopeChain()->push(o)); return o;}void JITStubs::cti_op_pop_scope(STUB_ARGS){ BEGIN_STUB_FUNCTION(); ARG_callFrame->setScopeChain(ARG_callFrame->scopeChain()->pop());}JSValueEncodedAsPointer* JITStubs::cti_op_typeof(STUB_ARGS){ BEGIN_STUB_FUNCTION(); return JSValuePtr::encode(jsTypeStringForValue(ARG_callFrame, ARG_src1));}JSValueEncodedAsPointer* JITStubs::cti_op_is_undefined(STUB_ARGS){ BEGIN_STUB_FUNCTION(); JSValuePtr v = ARG_src1; return JSValuePtr::encode(jsBoolean(v.isCell() ? v.asCell()->structure()->typeInfo().masqueradesAsUndefined() : v.isUndefined()));}JSValueEncodedAsPointer* JITStubs::cti_op_is_boolean(STUB_ARGS){ BEGIN_STUB_FUNCTION(); return JSValuePtr::encode(jsBoolean(ARG_src1.isBoolean()));}JSValueEncodedAsPointer* JITStubs::cti_op_is_number(STUB_ARGS){ BEGIN_STUB_FUNCTION(); return JSValuePtr::encode(jsBoolean(ARG_src1.isNumber()));}JSValueEncodedAsPointer* JITStubs::cti_op_is_string(STUB_ARGS){ BEGIN_STUB_FUNCTION(); return JSValuePtr::encode(jsBoolean(isJSString(ARG_globalData, ARG_src1)));}JSValueEncodedAsPointer* JITStubs::cti_op_is_object(STUB_ARGS){ BEGIN_STUB_FUNCTION(); return JSValuePtr::encode(jsBoolean(jsIsObjectType(ARG_src1)));}JSValueEncodedAsPointer* JITStubs::cti_op_is_function(STUB_ARGS){ BEGIN_STUB_FUNCTION(); return JSValuePtr::encode(jsBoolean(jsIsFunctionType(ARG_src1)));}JSValueEncodedAsPointer* JITStubs::cti_op_stricteq(STUB_ARGS){ BEGIN_STUB_FUNCTION(); JSValuePtr src1 = ARG_src1; JSValuePtr src2 = ARG_src2; return JSValuePtr::encode(jsBoolean(JSValuePtr::strictEqual(src1, src2)));}JSValueEncodedAsPointer* JITStubs::cti_op_nstricteq(STUB_ARGS){ BEGIN_STUB_FUNCTION(); JSValuePtr src1 = ARG_src1; JSValuePtr src2 = ARG_src2; return JSValuePtr::encode(jsBoolean(!JSValuePtr::strictEqual(src1, src2)));}JSValueEncodedAsPointer* JITStubs::cti_op_to_jsnumber(STUB_ARGS){ BEGIN_STUB_FUNCTION(); JSValuePtr src = ARG_src1; CallFrame* callFrame = ARG_callFrame; JSValuePtr result = src.toJSNumber(callFrame); CHECK_FOR_EXCEPTION_AT_END(); return JSValuePtr::encode(result);}JSValueEncodedAsPointer* JITStubs::cti_op_in(STUB_ARGS){ BEGIN_STUB_FUNCTION(); CallFrame* callFrame = ARG_callFrame; JSValuePtr baseVal = ARG_src2; if (!baseVal.isObject()) { CallFrame* callFrame = ARG_callFrame; CodeBlock* codeBlock = callFrame->codeBlock(); unsigned vPCIndex = codeBlock->getBytecodeIndex(callFrame, STUB_RETURN_ADDRESS); ARG_globalData->exception = createInvalidParamError(callFrame, "in", baseVal, vPCIndex, codeBlock); VM_THROW_EXCEPTION(); } JSValuePtr propName = ARG_src1; JSObject* baseObj = asObject(baseVal); uint32_t i; if (propName.getUInt32(i)) return JSValuePtr::encode(jsBoolean(baseObj->hasProperty(callFrame, i))); Identifier property(callFrame, propName.toString(callFrame)); CHECK_FOR_EXCEPTION(); return JSValuePtr::encode(jsBoolean(baseObj->hasProperty(callFrame, property)));}JSObject* JITStubs::cti_op_push_new_scope(STUB_ARGS){ BEGIN_STUB_FUNCTION(); JSObject* scope = new (ARG_globalData) JSStati
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -