- Structure* structure;
- JSValue proto = stackFrame.args[0].jsValue();
- if (proto.isObject())
- structure = asObject(proto)->inheritorID(*stackFrame.globalData);
- else
- structure = constructor->scope()->globalObject->emptyObjectStructure();
- JSValue result = constructEmptyObject(callFrame, structure);
-
- return JSValue::encode(result);
-}
-
-DEFINE_STUB_FUNCTION(EncodedJSValue, op_convert_this)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- JSValue v1 = stackFrame.args[0].jsValue();
- CallFrame* callFrame = stackFrame.callFrame;
-
- JSObject* result = v1.toThisObject(callFrame);
- CHECK_FOR_EXCEPTION_AT_END();
- return JSValue::encode(result);
-}
-
-DEFINE_STUB_FUNCTION(EncodedJSValue, op_convert_this_strict)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- JSValue v1 = stackFrame.args[0].jsValue();
- CallFrame* callFrame = stackFrame.callFrame;
- ASSERT(v1.asCell()->structure()->typeInfo().needsThisConversion());
- JSValue result = v1.toStrictThisObject(callFrame);
- CHECK_FOR_EXCEPTION_AT_END();
- return JSValue::encode(result);
-}
-
-DEFINE_STUB_FUNCTION(EncodedJSValue, op_add)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- JSValue v1 = stackFrame.args[0].jsValue();
- JSValue v2 = stackFrame.args[1].jsValue();
- CallFrame* callFrame = stackFrame.callFrame;
-
- if (v1.isString()) {
- JSValue result = v2.isString()
- ? jsString(callFrame, asString(v1), asString(v2))
- : jsString(callFrame, asString(v1), v2.toPrimitiveString(callFrame));
- CHECK_FOR_EXCEPTION_AT_END();
- return JSValue::encode(result);
- }
-
- double left = 0.0, right;
- if (v1.getNumber(left) && v2.getNumber(right))
- return JSValue::encode(jsNumber(left + right));
-
- // All other cases are pretty uncommon
- JSValue result = jsAddSlowCase(callFrame, v1, v2);
- CHECK_FOR_EXCEPTION_AT_END();
- return JSValue::encode(result);
-}
-
-DEFINE_STUB_FUNCTION(EncodedJSValue, op_pre_inc)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- JSValue v = stackFrame.args[0].jsValue();
-
- CallFrame* callFrame = stackFrame.callFrame;
- JSValue result = jsNumber(v.toNumber(callFrame) + 1);
- CHECK_FOR_EXCEPTION_AT_END();
- return JSValue::encode(result);
-}
-
-DEFINE_STUB_FUNCTION(int, timeout_check)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- JSGlobalData* globalData = stackFrame.globalData;
- TimeoutChecker& timeoutChecker = globalData->timeoutChecker;
-
- if (globalData->terminator.shouldTerminate()) {
- globalData->exception = createTerminatedExecutionException(globalData);
- VM_THROW_EXCEPTION_AT_END();
- } else if (timeoutChecker.didTimeOut(stackFrame.callFrame)) {
- globalData->exception = createInterruptedExecutionException(globalData);
- VM_THROW_EXCEPTION_AT_END();
- }
-
- return timeoutChecker.ticksUntilNextCheck();
-}
-
-DEFINE_STUB_FUNCTION(void*, register_file_check)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
- CallFrame* callFrame = stackFrame.callFrame;
-
- if (UNLIKELY(!stackFrame.registerFile->grow(&callFrame->registers()[callFrame->codeBlock()->m_numCalleeRegisters]))) {
- // Rewind to the previous call frame because op_call already optimistically
- // moved the call frame forward.
- CallFrame* oldCallFrame = callFrame->callerFrame();
- ExceptionHandler handler = jitThrow(stackFrame.globalData, oldCallFrame, createStackOverflowError(oldCallFrame), ReturnAddressPtr(callFrame->returnPC()));
- STUB_SET_RETURN_ADDRESS(handler.catchRoutine);
- callFrame = handler.callFrame;
- }
-
- return callFrame;
-}
-
-DEFINE_STUB_FUNCTION(int, op_loop_if_lesseq)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- JSValue src1 = stackFrame.args[0].jsValue();
- JSValue src2 = stackFrame.args[1].jsValue();
- CallFrame* callFrame = stackFrame.callFrame;
-
- bool result = jsLessEq(callFrame, src1, src2);
- CHECK_FOR_EXCEPTION_AT_END();
- return result;
-}
-
-DEFINE_STUB_FUNCTION(JSObject*, op_new_object)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- return constructEmptyObject(stackFrame.callFrame);
-}
-
-DEFINE_STUB_FUNCTION(void, op_put_by_id_generic)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- PutPropertySlot slot(stackFrame.callFrame->codeBlock()->isStrictMode());
- stackFrame.args[0].jsValue().put(stackFrame.callFrame, stackFrame.args[1].identifier(), stackFrame.args[2].jsValue(), slot);
- CHECK_FOR_EXCEPTION_AT_END();
-}
-
-DEFINE_STUB_FUNCTION(void, op_put_by_id_direct_generic)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- PutPropertySlot slot(stackFrame.callFrame->codeBlock()->isStrictMode());
- stackFrame.args[0].jsValue().putDirect(stackFrame.callFrame, stackFrame.args[1].identifier(), stackFrame.args[2].jsValue(), slot);
- CHECK_FOR_EXCEPTION_AT_END();
-}
-
-DEFINE_STUB_FUNCTION(EncodedJSValue, op_get_by_id_generic)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- CallFrame* callFrame = stackFrame.callFrame;
- Identifier& ident = stackFrame.args[1].identifier();
-
- JSValue baseValue = stackFrame.args[0].jsValue();
- PropertySlot slot(baseValue);
- JSValue result = baseValue.get(callFrame, ident, slot);
-
- CHECK_FOR_EXCEPTION_AT_END();
- return JSValue::encode(result);
-}
-
-#if ENABLE(JIT_OPTIMIZE_PROPERTY_ACCESS)
-
-DEFINE_STUB_FUNCTION(void, op_put_by_id)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
- CallFrame* callFrame = stackFrame.callFrame;
- Identifier& ident = stackFrame.args[1].identifier();
-
- PutPropertySlot slot(callFrame->codeBlock()->isStrictMode());
- stackFrame.args[0].jsValue().put(callFrame, ident, stackFrame.args[2].jsValue(), slot);
-
- CodeBlock* codeBlock = stackFrame.callFrame->codeBlock();
- StructureStubInfo* stubInfo = &codeBlock->getStubInfo(STUB_RETURN_ADDRESS);
- if (!stubInfo->seenOnce())
- stubInfo->setSeen();
- else
- JITThunks::tryCachePutByID(callFrame, codeBlock, STUB_RETURN_ADDRESS, stackFrame.args[0].jsValue(), slot, stubInfo, false);
-
- CHECK_FOR_EXCEPTION_AT_END();
-}
-
-DEFINE_STUB_FUNCTION(void, op_put_by_id_direct)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
- CallFrame* callFrame = stackFrame.callFrame;
- Identifier& ident = stackFrame.args[1].identifier();
-
- PutPropertySlot slot(callFrame->codeBlock()->isStrictMode());
- stackFrame.args[0].jsValue().putDirect(callFrame, ident, stackFrame.args[2].jsValue(), slot);
-
- CodeBlock* codeBlock = stackFrame.callFrame->codeBlock();
- StructureStubInfo* stubInfo = &codeBlock->getStubInfo(STUB_RETURN_ADDRESS);
- if (!stubInfo->seenOnce())
- stubInfo->setSeen();
- else
- JITThunks::tryCachePutByID(callFrame, codeBlock, STUB_RETURN_ADDRESS, stackFrame.args[0].jsValue(), slot, stubInfo, true);
-
- CHECK_FOR_EXCEPTION_AT_END();
-}
-
-DEFINE_STUB_FUNCTION(void, op_put_by_id_fail)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- CallFrame* callFrame = stackFrame.callFrame;
- Identifier& ident = stackFrame.args[1].identifier();
-
- PutPropertySlot slot(callFrame->codeBlock()->isStrictMode());
- stackFrame.args[0].jsValue().put(callFrame, ident, stackFrame.args[2].jsValue(), slot);
-
- CHECK_FOR_EXCEPTION_AT_END();
-}
-
-DEFINE_STUB_FUNCTION(void, op_put_by_id_direct_fail)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- CallFrame* callFrame = stackFrame.callFrame;
- Identifier& ident = stackFrame.args[1].identifier();
-
- PutPropertySlot slot(callFrame->codeBlock()->isStrictMode());
- stackFrame.args[0].jsValue().putDirect(callFrame, ident, stackFrame.args[2].jsValue(), slot);
-
- CHECK_FOR_EXCEPTION_AT_END();
-}
-
-DEFINE_STUB_FUNCTION(JSObject*, op_put_by_id_transition_realloc)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- JSValue baseValue = stackFrame.args[0].jsValue();
- int32_t oldSize = stackFrame.args[3].int32();
- int32_t newSize = stackFrame.args[4].int32();
-
- ASSERT(baseValue.isObject());
- JSObject* base = asObject(baseValue);
- base->allocatePropertyStorage(oldSize, newSize);
-
- return base;
-}
-
-DEFINE_STUB_FUNCTION(EncodedJSValue, op_get_by_id_method_check)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- CallFrame* callFrame = stackFrame.callFrame;
- Identifier& ident = stackFrame.args[1].identifier();
-
- JSValue baseValue = stackFrame.args[0].jsValue();
- PropertySlot slot(baseValue);
- JSValue result = baseValue.get(callFrame, ident, slot);
- CHECK_FOR_EXCEPTION();
-
- CodeBlock* codeBlock = stackFrame.callFrame->codeBlock();
- MethodCallLinkInfo& methodCallLinkInfo = codeBlock->getMethodCallLinkInfo(STUB_RETURN_ADDRESS);
-
- if (!methodCallLinkInfo.seenOnce()) {
- methodCallLinkInfo.setSeen();
- return JSValue::encode(result);
- }
-
- // If we successfully got something, then the base from which it is being accessed must
- // be an object. (Assertion to ensure asObject() call below is safe, which comes after
- // an isCacheable() chceck.
- ASSERT(!slot.isCacheableValue() || slot.slotBase().isObject());
-
- // Check that:
- // * We're dealing with a JSCell,
- // * the property is cachable,
- // * it's not a dictionary
- // * there is a function cached.
- Structure* structure;
- JSCell* specific;
- JSObject* slotBaseObject;
- if (baseValue.isCell()
- && slot.isCacheableValue()
- && !(structure = baseValue.asCell()->structure())->isUncacheableDictionary()
- && (slotBaseObject = asObject(slot.slotBase()))->getPropertySpecificValue(callFrame, ident, specific)
- && specific
- ) {
-
- JSObjectWithGlobalObject* callee = (JSObjectWithGlobalObject*)specific;
-
- // Since we're accessing a prototype in a loop, it's a good bet that it
- // should not be treated as a dictionary.
- if (slotBaseObject->structure()->isDictionary())
- slotBaseObject->flattenDictionaryObject(callFrame->globalData());
-
- // The result fetched should always be the callee!
- ASSERT(result == JSValue(callee));
-
- // Check to see if the function is on the object's prototype. Patch up the code to optimize.
- if (slot.slotBase() == structure->prototypeForLookup(callFrame)) {
- JIT::patchMethodCallProto(callFrame->globalData(), codeBlock, methodCallLinkInfo, callee, structure, slotBaseObject, STUB_RETURN_ADDRESS);
- return JSValue::encode(result);
- }
-
- // Check to see if the function is on the object itself.
- // Since we generate the method-check to check both the structure and a prototype-structure (since this
- // is the common case) we have a problem - we need to patch the prototype structure check to do something
- // useful. We could try to nop it out altogether, but that's a little messy, so lets do something simpler
- // for now. For now it performs a check on a special object on the global object only used for this
- // purpose. The object is in no way exposed, and as such the check will always pass.
- if (slot.slotBase() == baseValue) {
- JIT::patchMethodCallProto(callFrame->globalData(), codeBlock, methodCallLinkInfo, callee, structure, callFrame->scopeChain()->globalObject->methodCallDummy(), STUB_RETURN_ADDRESS);
- return JSValue::encode(result);
- }
- }
-
- // Revert the get_by_id op back to being a regular get_by_id - allow it to cache like normal, if it needs to.
- ctiPatchCallByReturnAddress(codeBlock, STUB_RETURN_ADDRESS, FunctionPtr(cti_op_get_by_id));
- return JSValue::encode(result);
-}
-
-DEFINE_STUB_FUNCTION(EncodedJSValue, op_get_by_id)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
- CallFrame* callFrame = stackFrame.callFrame;
- Identifier& ident = stackFrame.args[1].identifier();
-
- JSValue baseValue = stackFrame.args[0].jsValue();
- PropertySlot slot(baseValue);
- JSValue result = baseValue.get(callFrame, ident, slot);
-
- CodeBlock* codeBlock = stackFrame.callFrame->codeBlock();
- StructureStubInfo* stubInfo = &codeBlock->getStubInfo(STUB_RETURN_ADDRESS);
- if (!stubInfo->seenOnce())
- stubInfo->setSeen();
- else
- JITThunks::tryCacheGetByID(callFrame, codeBlock, STUB_RETURN_ADDRESS, baseValue, ident, slot, stubInfo);
-
- CHECK_FOR_EXCEPTION_AT_END();
- return JSValue::encode(result);
-}
-
-DEFINE_STUB_FUNCTION(EncodedJSValue, op_get_by_id_self_fail)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- CallFrame* callFrame = stackFrame.callFrame;
- Identifier& ident = stackFrame.args[1].identifier();
-
- JSValue baseValue = stackFrame.args[0].jsValue();
- PropertySlot slot(baseValue);
- JSValue result = baseValue.get(callFrame, ident, slot);
-
- CHECK_FOR_EXCEPTION();
-
- if (baseValue.isCell()
- && slot.isCacheable()
- && !baseValue.asCell()->structure()->isUncacheableDictionary()
- && slot.slotBase() == baseValue) {
-
- CodeBlock* codeBlock = callFrame->codeBlock();
- StructureStubInfo* stubInfo = &codeBlock->getStubInfo(STUB_RETURN_ADDRESS);
-
- ASSERT(slot.slotBase().isObject());
-
- PolymorphicAccessStructureList* polymorphicStructureList;
- int listIndex = 1;
-
- if (stubInfo->accessType == access_get_by_id_self) {
- ASSERT(!stubInfo->stubRoutine);
- polymorphicStructureList = new PolymorphicAccessStructureList(callFrame->globalData(), codeBlock->ownerExecutable(), CodeLocationLabel(), stubInfo->u.getByIdSelf.baseObjectStructure.get());
- stubInfo->initGetByIdSelfList(polymorphicStructureList, 1);
- } else {
- polymorphicStructureList = stubInfo->u.getByIdSelfList.structureList;
- listIndex = stubInfo->u.getByIdSelfList.listSize;
- }
- if (listIndex < POLYMORPHIC_LIST_CACHE_SIZE) {
- stubInfo->u.getByIdSelfList.listSize++;
- JIT::compileGetByIdSelfList(callFrame->scopeChain()->globalData, codeBlock, stubInfo, polymorphicStructureList, listIndex, baseValue.asCell()->structure(), ident, slot, slot.cachedOffset());
-
- if (listIndex == (POLYMORPHIC_LIST_CACHE_SIZE - 1))
- ctiPatchCallByReturnAddress(codeBlock, STUB_RETURN_ADDRESS, FunctionPtr(cti_op_get_by_id_generic));
- }
- } else
- ctiPatchCallByReturnAddress(callFrame->codeBlock(), STUB_RETURN_ADDRESS, FunctionPtr(cti_op_get_by_id_generic));
- return JSValue::encode(result);
-}
-
-static PolymorphicAccessStructureList* getPolymorphicAccessStructureListSlot(JSGlobalData& globalData, ScriptExecutable* owner, StructureStubInfo* stubInfo, int& listIndex)
-{
- PolymorphicAccessStructureList* prototypeStructureList = 0;
- listIndex = 1;
-
- switch (stubInfo->accessType) {
- case access_get_by_id_proto:
- prototypeStructureList = new PolymorphicAccessStructureList(globalData, owner, stubInfo->stubRoutine, stubInfo->u.getByIdProto.baseObjectStructure.get(), stubInfo->u.getByIdProto.prototypeStructure.get());
- stubInfo->stubRoutine = CodeLocationLabel();
- stubInfo->initGetByIdProtoList(prototypeStructureList, 2);
- break;
- case access_get_by_id_chain:
- prototypeStructureList = new PolymorphicAccessStructureList(globalData, owner, stubInfo->stubRoutine, stubInfo->u.getByIdChain.baseObjectStructure.get(), stubInfo->u.getByIdChain.chain.get());
- stubInfo->stubRoutine = CodeLocationLabel();
- stubInfo->initGetByIdProtoList(prototypeStructureList, 2);
- break;
- case access_get_by_id_proto_list:
- prototypeStructureList = stubInfo->u.getByIdProtoList.structureList;
- listIndex = stubInfo->u.getByIdProtoList.listSize;
- if (listIndex < POLYMORPHIC_LIST_CACHE_SIZE)
- stubInfo->u.getByIdProtoList.listSize++;
- break;
- default:
- ASSERT_NOT_REACHED();
- }
-
- ASSERT(listIndex <= POLYMORPHIC_LIST_CACHE_SIZE);
- return prototypeStructureList;
-}
-
-DEFINE_STUB_FUNCTION(EncodedJSValue, op_get_by_id_getter_stub)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
- CallFrame* callFrame = stackFrame.callFrame;
- GetterSetter* getterSetter = asGetterSetter(stackFrame.args[0].jsObject());
- if (!getterSetter->getter())
- return JSValue::encode(jsUndefined());
- JSObject* getter = asObject(getterSetter->getter());
- CallData callData;
- CallType callType = getter->getCallData(callData);
- JSValue result = call(callFrame, getter, callType, callData, stackFrame.args[1].jsObject(), ArgList());
- if (callFrame->hadException())
- returnToThrowTrampoline(&callFrame->globalData(), stackFrame.args[2].returnAddress(), STUB_RETURN_ADDRESS);
-
- return JSValue::encode(result);
-}
-
-DEFINE_STUB_FUNCTION(EncodedJSValue, op_get_by_id_custom_stub)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
- CallFrame* callFrame = stackFrame.callFrame;
- JSObject* slotBase = stackFrame.args[0].jsObject();
- PropertySlot::GetValueFunc getter = reinterpret_cast<PropertySlot::GetValueFunc>(stackFrame.args[1].asPointer);
- const Identifier& ident = stackFrame.args[2].identifier();
- JSValue result = getter(callFrame, slotBase, ident);
- if (callFrame->hadException())
- returnToThrowTrampoline(&callFrame->globalData(), stackFrame.args[3].returnAddress(), STUB_RETURN_ADDRESS);
-
- return JSValue::encode(result);
-}
-
-DEFINE_STUB_FUNCTION(EncodedJSValue, op_get_by_id_proto_list)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- CallFrame* callFrame = stackFrame.callFrame;
- const Identifier& propertyName = stackFrame.args[1].identifier();
-
- JSValue baseValue = stackFrame.args[0].jsValue();
- PropertySlot slot(baseValue);
- JSValue result = baseValue.get(callFrame, propertyName, slot);
-
- CHECK_FOR_EXCEPTION();
-
- if (!baseValue.isCell() || !slot.isCacheable() || baseValue.asCell()->structure()->isDictionary() || baseValue.asCell()->structure()->typeInfo().prohibitsPropertyCaching()) {
- ctiPatchCallByReturnAddress(callFrame->codeBlock(), STUB_RETURN_ADDRESS, FunctionPtr(cti_op_get_by_id_proto_fail));
- return JSValue::encode(result);
- }
-
- Structure* structure = baseValue.asCell()->structure();
- CodeBlock* codeBlock = callFrame->codeBlock();
- StructureStubInfo* stubInfo = &codeBlock->getStubInfo(STUB_RETURN_ADDRESS);
-
- ASSERT(slot.slotBase().isObject());
- JSObject* slotBaseObject = asObject(slot.slotBase());
-
- size_t offset = slot.cachedOffset();
-
- if (slot.slotBase() == baseValue)
- ctiPatchCallByReturnAddress(codeBlock, STUB_RETURN_ADDRESS, FunctionPtr(cti_op_get_by_id_proto_fail));
- else if (slot.slotBase() == baseValue.asCell()->structure()->prototypeForLookup(callFrame)) {
- ASSERT(!baseValue.asCell()->structure()->isDictionary());
- // Since we're accessing a prototype in a loop, it's a good bet that it
- // should not be treated as a dictionary.
- if (slotBaseObject->structure()->isDictionary()) {
- slotBaseObject->flattenDictionaryObject(callFrame->globalData());
- offset = slotBaseObject->structure()->get(callFrame->globalData(), propertyName);
- }
-
- int listIndex;
- PolymorphicAccessStructureList* prototypeStructureList = getPolymorphicAccessStructureListSlot(callFrame->globalData(), codeBlock->ownerExecutable(), stubInfo, listIndex);
- if (listIndex < POLYMORPHIC_LIST_CACHE_SIZE) {
- JIT::compileGetByIdProtoList(callFrame->scopeChain()->globalData, callFrame, codeBlock, stubInfo, prototypeStructureList, listIndex, structure, slotBaseObject->structure(), propertyName, slot, offset);
-
- if (listIndex == (POLYMORPHIC_LIST_CACHE_SIZE - 1))
- ctiPatchCallByReturnAddress(codeBlock, STUB_RETURN_ADDRESS, FunctionPtr(cti_op_get_by_id_proto_list_full));
- }
- } else if (size_t count = normalizePrototypeChain(callFrame, baseValue, slot.slotBase(), propertyName, offset)) {
- ASSERT(!baseValue.asCell()->structure()->isDictionary());
- int listIndex;
- PolymorphicAccessStructureList* prototypeStructureList = getPolymorphicAccessStructureListSlot(callFrame->globalData(), codeBlock->ownerExecutable(), stubInfo, listIndex);
-
- if (listIndex < POLYMORPHIC_LIST_CACHE_SIZE) {
- StructureChain* protoChain = structure->prototypeChain(callFrame);
- JIT::compileGetByIdChainList(callFrame->scopeChain()->globalData, callFrame, codeBlock, stubInfo, prototypeStructureList, listIndex, structure, protoChain, count, propertyName, slot, offset);
-
- if (listIndex == (POLYMORPHIC_LIST_CACHE_SIZE - 1))
- ctiPatchCallByReturnAddress(codeBlock, STUB_RETURN_ADDRESS, FunctionPtr(cti_op_get_by_id_proto_list_full));
- }
- } else
- ctiPatchCallByReturnAddress(codeBlock, STUB_RETURN_ADDRESS, FunctionPtr(cti_op_get_by_id_proto_fail));
-
- return JSValue::encode(result);
-}
-
-DEFINE_STUB_FUNCTION(EncodedJSValue, op_get_by_id_proto_list_full)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- JSValue baseValue = stackFrame.args[0].jsValue();
- PropertySlot slot(baseValue);
- JSValue result = baseValue.get(stackFrame.callFrame, stackFrame.args[1].identifier(), slot);
-
- CHECK_FOR_EXCEPTION_AT_END();
- return JSValue::encode(result);
-}
-
-DEFINE_STUB_FUNCTION(EncodedJSValue, op_get_by_id_proto_fail)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- JSValue baseValue = stackFrame.args[0].jsValue();
- PropertySlot slot(baseValue);
- JSValue result = baseValue.get(stackFrame.callFrame, stackFrame.args[1].identifier(), slot);
-
- CHECK_FOR_EXCEPTION_AT_END();
- return JSValue::encode(result);
-}
-
-DEFINE_STUB_FUNCTION(EncodedJSValue, op_get_by_id_array_fail)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- JSValue baseValue = stackFrame.args[0].jsValue();
- PropertySlot slot(baseValue);
- JSValue result = baseValue.get(stackFrame.callFrame, stackFrame.args[1].identifier(), slot);
-
- CHECK_FOR_EXCEPTION_AT_END();
- return JSValue::encode(result);
-}
-
-DEFINE_STUB_FUNCTION(EncodedJSValue, op_get_by_id_string_fail)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- JSValue baseValue = stackFrame.args[0].jsValue();
- PropertySlot slot(baseValue);
- JSValue result = baseValue.get(stackFrame.callFrame, stackFrame.args[1].identifier(), slot);
-
- CHECK_FOR_EXCEPTION_AT_END();
- return JSValue::encode(result);
-}
-
-#endif // ENABLE(JIT_OPTIMIZE_PROPERTY_ACCESS)
-
-DEFINE_STUB_FUNCTION(void, op_check_has_instance)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- CallFrame* callFrame = stackFrame.callFrame;
- JSValue baseVal = stackFrame.args[0].jsValue();
-
- // ECMA-262 15.3.5.3:
- // Throw an exception either if baseVal is not an object, or if it does not implement 'HasInstance' (i.e. is a function).
-#ifndef NDEBUG
- TypeInfo typeInfo(UnspecifiedType);
- ASSERT(!baseVal.isObject() || !(typeInfo = asObject(baseVal)->structure()->typeInfo()).implementsHasInstance());
-#endif
- stackFrame.globalData->exception = createInvalidParamError(callFrame, "instanceof", baseVal);
- VM_THROW_EXCEPTION_AT_END();
-}
-
-DEFINE_STUB_FUNCTION(EncodedJSValue, op_instanceof)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- CallFrame* callFrame = stackFrame.callFrame;
- JSValue value = stackFrame.args[0].jsValue();
- JSValue baseVal = stackFrame.args[1].jsValue();
- JSValue proto = stackFrame.args[2].jsValue();
-
- // At least one of these checks must have failed to get to the slow case.
- ASSERT(!value.isCell() || !baseVal.isCell() || !proto.isCell()
- || !value.isObject() || !baseVal.isObject() || !proto.isObject()
- || (asObject(baseVal)->structure()->typeInfo().flags() & (ImplementsHasInstance | OverridesHasInstance)) != ImplementsHasInstance);
-
-
- // ECMA-262 15.3.5.3:
- // Throw an exception either if baseVal is not an object, or if it does not implement 'HasInstance' (i.e. is a function).
- TypeInfo typeInfo(UnspecifiedType);
- if (!baseVal.isObject() || !(typeInfo = asObject(baseVal)->structure()->typeInfo()).implementsHasInstance()) {
- stackFrame.globalData->exception = createInvalidParamError(stackFrame.callFrame, "instanceof", baseVal);
- VM_THROW_EXCEPTION();
- }
- ASSERT(typeInfo.type() != UnspecifiedType);
-
- if (!typeInfo.overridesHasInstance()) {
- if (!value.isObject())
- return JSValue::encode(jsBoolean(false));
-
- if (!proto.isObject()) {
- throwError(callFrame, createTypeError(callFrame, "instanceof called on an object with an invalid prototype property."));
- VM_THROW_EXCEPTION();
- }
- }
-
- JSValue result = jsBoolean(asObject(baseVal)->hasInstance(callFrame, value, proto));
- CHECK_FOR_EXCEPTION_AT_END();
-
- return JSValue::encode(result);
-}
-
-DEFINE_STUB_FUNCTION(EncodedJSValue, op_del_by_id)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- CallFrame* callFrame = stackFrame.callFrame;
-
- JSObject* baseObj = stackFrame.args[0].jsValue().toObject(callFrame);
-
- bool couldDelete = baseObj->deleteProperty(callFrame, stackFrame.args[1].identifier());
- JSValue result = jsBoolean(couldDelete);
- if (!couldDelete && callFrame->codeBlock()->isStrictMode())
- stackFrame.globalData->exception = createTypeError(stackFrame.callFrame, "Unable to delete property.");
-
- CHECK_FOR_EXCEPTION_AT_END();
- return JSValue::encode(result);
-}
-
-DEFINE_STUB_FUNCTION(EncodedJSValue, op_mul)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- JSValue src1 = stackFrame.args[0].jsValue();
- JSValue src2 = stackFrame.args[1].jsValue();
-
- double left;
- double right;
- if (src1.getNumber(left) && src2.getNumber(right))
- return JSValue::encode(jsNumber(left * right));
-
- CallFrame* callFrame = stackFrame.callFrame;
- JSValue result = jsNumber(src1.toNumber(callFrame) * src2.toNumber(callFrame));
- CHECK_FOR_EXCEPTION_AT_END();
- return JSValue::encode(result);
-}
-
-DEFINE_STUB_FUNCTION(JSObject*, op_new_func)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- ASSERT(stackFrame.callFrame->codeBlock()->codeType() != FunctionCode || !stackFrame.callFrame->codeBlock()->needsFullScopeChain() || stackFrame.callFrame->uncheckedR(stackFrame.callFrame->codeBlock()->activationRegister()).jsValue());
- return stackFrame.args[0].function()->make(stackFrame.callFrame, stackFrame.callFrame->scopeChain());
-}
-
-DEFINE_STUB_FUNCTION(void*, op_call_jitCompile)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
-#if !ASSERT_DISABLED
- CallData callData;
- ASSERT(stackFrame.callFrame->callee()->getCallData(callData) == CallTypeJS);
-#endif
-
- JSFunction* function = asFunction(stackFrame.callFrame->callee());
- ASSERT(!function->isHostFunction());
- FunctionExecutable* executable = function->jsExecutable();
- ScopeChainNode* callDataScopeChain = function->scope();
- JSObject* error = executable->compileForCall(stackFrame.callFrame, callDataScopeChain);
- if (error) {
- stackFrame.callFrame->globalData().exception = error;
- return 0;
- }
- return function;
-}
-
-DEFINE_STUB_FUNCTION(void*, op_construct_jitCompile)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
-#if !ASSERT_DISABLED
- ConstructData constructData;
- ASSERT(asFunction(stackFrame.callFrame->callee())->getConstructData(constructData) == ConstructTypeJS);
-#endif
-
- JSFunction* function = asFunction(stackFrame.callFrame->callee());
- ASSERT(!function->isHostFunction());
- FunctionExecutable* executable = function->jsExecutable();
- ScopeChainNode* callDataScopeChain = function->scope();
- JSObject* error = executable->compileForConstruct(stackFrame.callFrame, callDataScopeChain);
- if (error) {
- stackFrame.callFrame->globalData().exception = error;
- return 0;
- }
- return function;
-}
-
-DEFINE_STUB_FUNCTION(void*, op_call_arityCheck)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- CallFrame* callFrame = stackFrame.callFrame;
- JSFunction* callee = asFunction(callFrame->callee());
- ASSERT(!callee->isHostFunction());
- CodeBlock* newCodeBlock = &callee->jsExecutable()->generatedBytecodeForCall();
- int argCount = callFrame->argumentCountIncludingThis();
- ReturnAddressPtr pc = callFrame->returnPC();
-
- ASSERT(argCount != newCodeBlock->m_numParameters);
-
- CallFrame* oldCallFrame = callFrame->callerFrame();
-
- Register* r;
- if (argCount > newCodeBlock->m_numParameters) {
- size_t numParameters = newCodeBlock->m_numParameters;
- r = callFrame->registers() + numParameters;
- Register* newEnd = r + newCodeBlock->m_numCalleeRegisters;
- if (!stackFrame.registerFile->grow(newEnd)) {
- // Rewind to the previous call frame because op_call already optimistically
- // moved the call frame forward.
- ExceptionHandler handler = jitThrow(stackFrame.globalData, oldCallFrame, createStackOverflowError(oldCallFrame), pc);
- STUB_SET_RETURN_ADDRESS(handler.catchRoutine);
- return handler.callFrame;
- }
-
- Register* argv = r - RegisterFile::CallFrameHeaderSize - numParameters - argCount;
- for (size_t i = 0; i < numParameters; ++i)
- argv[i + argCount] = argv[i];
- } else {
- size_t omittedArgCount = newCodeBlock->m_numParameters - argCount;
- r = callFrame->registers() + omittedArgCount;
- Register* newEnd = r + newCodeBlock->m_numCalleeRegisters;
- if (!stackFrame.registerFile->grow(newEnd)) {
- // Rewind to the previous call frame because op_call already optimistically
- // moved the call frame forward.
- ExceptionHandler handler = jitThrow(stackFrame.globalData, oldCallFrame, createStackOverflowError(oldCallFrame), pc);
- STUB_SET_RETURN_ADDRESS(handler.catchRoutine);
- return handler.callFrame;
- }
-
- Register* argv = r - RegisterFile::CallFrameHeaderSize - omittedArgCount;
- for (size_t i = 0; i < omittedArgCount; ++i)
- argv[i] = jsUndefined();
- }
-
- callFrame = CallFrame::create(r);
- callFrame->setCallerFrame(oldCallFrame);
- callFrame->setArgumentCountIncludingThis(argCount);
- callFrame->setCallee(callee);
- callFrame->setScopeChain(callee->scope());
- callFrame->setReturnPC(pc.value());
-
- ASSERT((void*)callFrame <= stackFrame.registerFile->end());
- return callFrame;
-}
-
-DEFINE_STUB_FUNCTION(void*, op_construct_arityCheck)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- CallFrame* callFrame = stackFrame.callFrame;
- JSFunction* callee = asFunction(callFrame->callee());
- ASSERT(!callee->isHostFunction());
- CodeBlock* newCodeBlock = &callee->jsExecutable()->generatedBytecodeForConstruct();
- int argCount = callFrame->argumentCountIncludingThis();
- ReturnAddressPtr pc = callFrame->returnPC();
-
- ASSERT(argCount != newCodeBlock->m_numParameters);
-
- CallFrame* oldCallFrame = callFrame->callerFrame();
-
- Register* r;
- if (argCount > newCodeBlock->m_numParameters) {
- size_t numParameters = newCodeBlock->m_numParameters;
- r = callFrame->registers() + numParameters;
- Register* newEnd = r + newCodeBlock->m_numCalleeRegisters;
- if (!stackFrame.registerFile->grow(newEnd)) {
- // Rewind to the previous call frame because op_call already optimistically
- // moved the call frame forward.
- ExceptionHandler handler = jitThrow(stackFrame.globalData, oldCallFrame, createStackOverflowError(oldCallFrame), pc);
- STUB_SET_RETURN_ADDRESS(handler.catchRoutine);
- return handler.callFrame;
- }
-
- Register* argv = r - RegisterFile::CallFrameHeaderSize - numParameters - argCount;
- for (size_t i = 0; i < numParameters; ++i)
- argv[i + argCount] = argv[i];
- } else {
- size_t omittedArgCount = newCodeBlock->m_numParameters - argCount;
- r = callFrame->registers() + omittedArgCount;
- Register* newEnd = r + newCodeBlock->m_numCalleeRegisters;
- if (!stackFrame.registerFile->grow(newEnd)) {
- // Rewind to the previous call frame because op_call already optimistically
- // moved the call frame forward.
- ExceptionHandler handler = jitThrow(stackFrame.globalData, oldCallFrame, createStackOverflowError(oldCallFrame), pc);
- STUB_SET_RETURN_ADDRESS(handler.catchRoutine);
- return handler.callFrame;
- }
-
- Register* argv = r - RegisterFile::CallFrameHeaderSize - omittedArgCount;
- for (size_t i = 0; i < omittedArgCount; ++i)
- argv[i] = jsUndefined();
- }
-
- ASSERT((void*)callFrame <= stackFrame.registerFile->end());
- callFrame = CallFrame::create(r);
- callFrame->setCallerFrame(oldCallFrame);
- callFrame->setArgumentCountIncludingThis(argCount);
- callFrame->setCallee(callee);
- callFrame->setScopeChain(callee->scope());
- callFrame->setReturnPC(pc.value());
-
- ASSERT((void*)callFrame <= stackFrame.registerFile->end());
- return callFrame;
-}
-
-#if ENABLE(JIT_OPTIMIZE_CALL)
-DEFINE_STUB_FUNCTION(void*, vm_lazyLinkCall)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
- CallFrame* callFrame = stackFrame.callFrame;
- JSFunction* callee = asFunction(callFrame->callee());
- ExecutableBase* executable = callee->executable();
-
- MacroAssemblerCodePtr codePtr;
- CodeBlock* codeBlock = 0;
- if (executable->isHostFunction())
- codePtr = executable->generatedJITCodeForCall().addressForCall();
- else {
- FunctionExecutable* functionExecutable = static_cast<FunctionExecutable*>(executable);
- JSObject* error = functionExecutable->compileForCall(callFrame, callee->scope());
- if (error) {
- callFrame->globalData().exception = createStackOverflowError(callFrame);
- return 0;
- }
- codeBlock = &functionExecutable->generatedBytecodeForCall();
- if (callFrame->argumentCountIncludingThis() == static_cast<size_t>(codeBlock->m_numParameters))
- codePtr = functionExecutable->generatedJITCodeForCall().addressForCall();
- else
- codePtr = functionExecutable->generatedJITCodeForCallWithArityCheck();
- }
- CallLinkInfo* callLinkInfo = &stackFrame.callFrame->callerFrame()->codeBlock()->getCallLinkInfo(callFrame->returnPC());
-
- if (!callLinkInfo->seenOnce())
- callLinkInfo->setSeen();
- else
- JIT::linkCall(callee, stackFrame.callFrame->callerFrame()->codeBlock(), codeBlock, codePtr, callLinkInfo, callFrame->argumentCountIncludingThis(), stackFrame.globalData);
-
- return codePtr.executableAddress();
-}
-
-DEFINE_STUB_FUNCTION(void*, vm_lazyLinkConstruct)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
- CallFrame* callFrame = stackFrame.callFrame;
- JSFunction* callee = asFunction(callFrame->callee());
- ExecutableBase* executable = callee->executable();
-
- MacroAssemblerCodePtr codePtr;
- CodeBlock* codeBlock = 0;
- if (executable->isHostFunction())
- codePtr = executable->generatedJITCodeForConstruct().addressForCall();
- else {
- FunctionExecutable* functionExecutable = static_cast<FunctionExecutable*>(executable);
- JSObject* error = functionExecutable->compileForConstruct(callFrame, callee->scope());
- if (error) {
- throwStackOverflowError(callFrame, stackFrame.globalData, ReturnAddressPtr(callFrame->returnPC()), STUB_RETURN_ADDRESS);
- return 0;
- }
- codeBlock = &functionExecutable->generatedBytecodeForConstruct();
- if (callFrame->argumentCountIncludingThis() == static_cast<size_t>(codeBlock->m_numParameters))
- codePtr = functionExecutable->generatedJITCodeForConstruct().addressForCall();
- else
- codePtr = functionExecutable->generatedJITCodeForConstructWithArityCheck();
- }
- CallLinkInfo* callLinkInfo = &stackFrame.callFrame->callerFrame()->codeBlock()->getCallLinkInfo(callFrame->returnPC());
-
- if (!callLinkInfo->seenOnce())
- callLinkInfo->setSeen();
- else
- JIT::linkConstruct(callee, stackFrame.callFrame->callerFrame()->codeBlock(), codeBlock, codePtr, callLinkInfo, callFrame->argumentCountIncludingThis(), stackFrame.globalData);
-
- return codePtr.executableAddress();
-}
-#endif // !ENABLE(JIT_OPTIMIZE_CALL)
-
-DEFINE_STUB_FUNCTION(JSObject*, op_push_activation)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- JSActivation* activation = new (stackFrame.globalData) JSActivation(stackFrame.callFrame, static_cast<FunctionExecutable*>(stackFrame.callFrame->codeBlock()->ownerExecutable()));
- stackFrame.callFrame->setScopeChain(stackFrame.callFrame->scopeChain()->push(activation));
- return activation;
-}
-
-DEFINE_STUB_FUNCTION(EncodedJSValue, op_call_NotJSFunction)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- JSValue funcVal = stackFrame.args[0].jsValue();
-
- CallData callData;
- CallType callType = getCallData(funcVal, callData);
-
- ASSERT(callType != CallTypeJS);
-
- if (callType == CallTypeHost) {
- int registerOffset = stackFrame.args[1].int32();
- int argCount = stackFrame.args[2].int32();
- CallFrame* previousCallFrame = stackFrame.callFrame;
- CallFrame* callFrame = CallFrame::create(previousCallFrame->registers() + registerOffset);
- if (!stackFrame.registerFile->grow(callFrame->registers())) {
- throwStackOverflowError(previousCallFrame, stackFrame.globalData, callFrame->returnPC(), STUB_RETURN_ADDRESS);
- VM_THROW_EXCEPTION();
- }
-
- callFrame->init(0, static_cast<Instruction*>((STUB_RETURN_ADDRESS).value()), previousCallFrame->scopeChain(), previousCallFrame, argCount, asObject(funcVal));
-
- EncodedJSValue returnValue;
- {
- SamplingTool::HostCallRecord callRecord(CTI_SAMPLER);
- returnValue = callData.native.function(callFrame);
- }
-
- CHECK_FOR_EXCEPTION_AT_END();
- return returnValue;
- }
-
- ASSERT(callType == CallTypeNone);
-
- stackFrame.globalData->exception = createNotAFunctionError(stackFrame.callFrame, funcVal);
- VM_THROW_EXCEPTION();
-}
-
-DEFINE_STUB_FUNCTION(EncodedJSValue, op_create_arguments)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- Arguments* arguments = new (stackFrame.globalData) Arguments(stackFrame.callFrame);
- return JSValue::encode(JSValue(arguments));
-}
-
-DEFINE_STUB_FUNCTION(EncodedJSValue, op_create_arguments_no_params)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- Arguments* arguments = new (stackFrame.globalData) Arguments(stackFrame.callFrame, Arguments::NoParameters);
- return JSValue::encode(JSValue(arguments));
-}
-
-DEFINE_STUB_FUNCTION(void, op_tear_off_activation)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- ASSERT(stackFrame.callFrame->codeBlock()->needsFullScopeChain());
- JSValue activationValue = stackFrame.args[0].jsValue();
- if (!activationValue) {
- if (JSValue v = stackFrame.args[1].jsValue()) {
- if (!stackFrame.callFrame->codeBlock()->isStrictMode())
- asArguments(v)->copyRegisters(*stackFrame.globalData);
- }
- return;
- }
- JSActivation* activation = asActivation(stackFrame.args[0].jsValue());
- activation->copyRegisters(*stackFrame.globalData);
- if (JSValue v = stackFrame.args[1].jsValue()) {
- if (!stackFrame.callFrame->codeBlock()->isStrictMode())
- asArguments(v)->setActivation(*stackFrame.globalData, activation);
- }
-}
-
-DEFINE_STUB_FUNCTION(void, op_tear_off_arguments)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- ASSERT(stackFrame.callFrame->codeBlock()->usesArguments() && !stackFrame.callFrame->codeBlock()->needsFullScopeChain());
- asArguments(stackFrame.args[0].jsValue())->copyRegisters(*stackFrame.globalData);
-}
-
-DEFINE_STUB_FUNCTION(void, op_profile_will_call)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- ASSERT(*stackFrame.enabledProfilerReference);
- (*stackFrame.enabledProfilerReference)->willExecute(stackFrame.callFrame, stackFrame.args[0].jsValue());
-}
-
-DEFINE_STUB_FUNCTION(void, op_profile_did_call)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- ASSERT(*stackFrame.enabledProfilerReference);
- (*stackFrame.enabledProfilerReference)->didExecute(stackFrame.callFrame, stackFrame.args[0].jsValue());
-}
-
-DEFINE_STUB_FUNCTION(JSObject*, op_new_array)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- ArgList argList(&stackFrame.callFrame->registers()[stackFrame.args[0].int32()], stackFrame.args[1].int32());
- return constructArray(stackFrame.callFrame, argList);
-}
-
-DEFINE_STUB_FUNCTION(JSObject*, op_new_array_buffer)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- ArgList argList(stackFrame.callFrame->codeBlock()->constantBuffer(stackFrame.args[0].int32()), stackFrame.args[1].int32());
- return constructArray(stackFrame.callFrame, argList);
-}
-
-DEFINE_STUB_FUNCTION(EncodedJSValue, op_resolve)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- CallFrame* callFrame = stackFrame.callFrame;
- ScopeChainNode* scopeChain = callFrame->scopeChain();
-
- ScopeChainIterator iter = scopeChain->begin();
- ScopeChainIterator end = scopeChain->end();
- ASSERT(iter != end);
-
- Identifier& ident = stackFrame.args[0].identifier();
- do {
- JSObject* o = iter->get();
- PropertySlot slot(o);
- if (o->getPropertySlot(callFrame, ident, slot)) {
- JSValue result = slot.getValue(callFrame, ident);
- CHECK_FOR_EXCEPTION_AT_END();
- return JSValue::encode(result);
- }
- } while (++iter != end);
-
- stackFrame.globalData->exception = createUndefinedVariableError(callFrame, ident);
- VM_THROW_EXCEPTION();
-}
-
-DEFINE_STUB_FUNCTION(EncodedJSValue, op_construct_NotJSConstruct)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- JSValue constrVal = stackFrame.args[0].jsValue();
-
- ConstructData constructData;
- ConstructType constructType = getConstructData(constrVal, constructData);
-
- ASSERT(constructType != ConstructTypeJS);
-
- if (constructType == ConstructTypeHost) {
- int registerOffset = stackFrame.args[1].int32();
- int argCount = stackFrame.args[2].int32();
- CallFrame* previousCallFrame = stackFrame.callFrame;
- CallFrame* callFrame = CallFrame::create(previousCallFrame->registers() + registerOffset);
- if (!stackFrame.registerFile->grow(callFrame->registers())) {
- throwStackOverflowError(previousCallFrame, stackFrame.globalData, callFrame->returnPC(), STUB_RETURN_ADDRESS);
- VM_THROW_EXCEPTION();
- }
-
- callFrame->init(0, static_cast<Instruction*>((STUB_RETURN_ADDRESS).value()), previousCallFrame->scopeChain(), previousCallFrame, argCount, asObject(constrVal));
-
- EncodedJSValue returnValue;
- {
- SamplingTool::HostCallRecord callRecord(CTI_SAMPLER);
- returnValue = constructData.native.function(callFrame);
- }
-
- CHECK_FOR_EXCEPTION_AT_END();
- return returnValue;
- }
-
- ASSERT(constructType == ConstructTypeNone);
-
- stackFrame.globalData->exception = createNotAConstructorError(stackFrame.callFrame, constrVal);
- VM_THROW_EXCEPTION();
-}
-
-DEFINE_STUB_FUNCTION(EncodedJSValue, op_get_by_val)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- CallFrame* callFrame = stackFrame.callFrame;
- JSGlobalData* globalData = stackFrame.globalData;
-
- JSValue baseValue = stackFrame.args[0].jsValue();
- JSValue subscript = stackFrame.args[1].jsValue();
-
- if (LIKELY(baseValue.isCell() && subscript.isString())) {
- Identifier propertyName(callFrame, asString(subscript)->value(callFrame));
- PropertySlot slot(baseValue.asCell());
- // JSString::value may have thrown, but we shouldn't find a property with a null identifier,
- // so we should miss this case and wind up in the CHECK_FOR_EXCEPTION_AT_END, below.
- if (baseValue.asCell()->fastGetOwnPropertySlot(callFrame, propertyName, slot)) {
- JSValue result = slot.getValue(callFrame, propertyName);
- CHECK_FOR_EXCEPTION();
- return JSValue::encode(result);
- }
- }
-
- if (subscript.isUInt32()) {
- uint32_t i = subscript.asUInt32();
- if (isJSString(globalData, baseValue) && asString(baseValue)->canGetIndex(i)) {
- ctiPatchCallByReturnAddress(callFrame->codeBlock(), STUB_RETURN_ADDRESS, FunctionPtr(cti_op_get_by_val_string));
- JSValue result = asString(baseValue)->getIndex(callFrame, i);
- CHECK_FOR_EXCEPTION();
- return JSValue::encode(result);
- }
- if (isJSByteArray(globalData, baseValue) && asByteArray(baseValue)->canAccessIndex(i)) {
- // All fast byte array accesses are safe from exceptions so return immediately to avoid exception checks.
- ctiPatchCallByReturnAddress(callFrame->codeBlock(), STUB_RETURN_ADDRESS, FunctionPtr(cti_op_get_by_val_byte_array));
- return JSValue::encode(asByteArray(baseValue)->getIndex(callFrame, i));
- }
- JSValue result = baseValue.get(callFrame, i);
- CHECK_FOR_EXCEPTION();
- return JSValue::encode(result);
- }
-
- Identifier property(callFrame, subscript.toString(callFrame));
- JSValue result = baseValue.get(callFrame, property);
- CHECK_FOR_EXCEPTION_AT_END();
- return JSValue::encode(result);
-}
-
-DEFINE_STUB_FUNCTION(EncodedJSValue, op_get_by_val_string)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- CallFrame* callFrame = stackFrame.callFrame;
- JSGlobalData* globalData = stackFrame.globalData;
-
- JSValue baseValue = stackFrame.args[0].jsValue();
- JSValue subscript = stackFrame.args[1].jsValue();
-
- JSValue result;
-
- if (LIKELY(subscript.isUInt32())) {
- uint32_t i = subscript.asUInt32();
- if (isJSString(globalData, baseValue) && asString(baseValue)->canGetIndex(i))
- result = asString(baseValue)->getIndex(callFrame, i);
- else {
- result = baseValue.get(callFrame, i);
- if (!isJSString(globalData, baseValue))
- ctiPatchCallByReturnAddress(callFrame->codeBlock(), STUB_RETURN_ADDRESS, FunctionPtr(cti_op_get_by_val));
- }
- } else {
- Identifier property(callFrame, subscript.toString(callFrame));
- result = baseValue.get(callFrame, property);
- }
-
- CHECK_FOR_EXCEPTION_AT_END();
- return JSValue::encode(result);
-}
-
-DEFINE_STUB_FUNCTION(EncodedJSValue, op_get_by_val_byte_array)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- CallFrame* callFrame = stackFrame.callFrame;
- JSGlobalData* globalData = stackFrame.globalData;
-
- JSValue baseValue = stackFrame.args[0].jsValue();
- JSValue subscript = stackFrame.args[1].jsValue();
-
- JSValue result;
-
- if (LIKELY(subscript.isUInt32())) {
- uint32_t i = subscript.asUInt32();
- if (isJSByteArray(globalData, baseValue) && asByteArray(baseValue)->canAccessIndex(i)) {
- // All fast byte array accesses are safe from exceptions so return immediately to avoid exception checks.
- return JSValue::encode(asByteArray(baseValue)->getIndex(callFrame, i));
- }
-
- result = baseValue.get(callFrame, i);
- if (!isJSByteArray(globalData, baseValue))
- ctiPatchCallByReturnAddress(callFrame->codeBlock(), STUB_RETURN_ADDRESS, FunctionPtr(cti_op_get_by_val));
- } else {
- Identifier property(callFrame, subscript.toString(callFrame));
- result = baseValue.get(callFrame, property);
- }
-
- CHECK_FOR_EXCEPTION_AT_END();
- return JSValue::encode(result);
-}
-
-DEFINE_STUB_FUNCTION(EncodedJSValue, op_sub)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- JSValue src1 = stackFrame.args[0].jsValue();
- JSValue src2 = stackFrame.args[1].jsValue();
-
- double left;
- double right;
- if (src1.getNumber(left) && src2.getNumber(right))
- return JSValue::encode(jsNumber(left - right));
-
- CallFrame* callFrame = stackFrame.callFrame;
- JSValue result = jsNumber(src1.toNumber(callFrame) - src2.toNumber(callFrame));
- CHECK_FOR_EXCEPTION_AT_END();
- return JSValue::encode(result);
-}
-
-DEFINE_STUB_FUNCTION(void, op_put_by_val)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- CallFrame* callFrame = stackFrame.callFrame;
- JSGlobalData* globalData = stackFrame.globalData;
-
- JSValue baseValue = stackFrame.args[0].jsValue();
- JSValue subscript = stackFrame.args[1].jsValue();
- JSValue value = stackFrame.args[2].jsValue();
-
- if (LIKELY(subscript.isUInt32())) {
- uint32_t i = subscript.asUInt32();
- if (isJSArray(globalData, baseValue)) {
- JSArray* jsArray = asArray(baseValue);
- if (jsArray->canSetIndex(i))
- jsArray->setIndex(*globalData, i, value);
- else
- jsArray->JSArray::put(callFrame, i, value);
- } else if (isJSByteArray(globalData, baseValue) && asByteArray(baseValue)->canAccessIndex(i)) {
- JSByteArray* jsByteArray = asByteArray(baseValue);
- ctiPatchCallByReturnAddress(callFrame->codeBlock(), STUB_RETURN_ADDRESS, FunctionPtr(cti_op_put_by_val_byte_array));
- // All fast byte array accesses are safe from exceptions so return immediately to avoid exception checks.
- if (value.isInt32()) {
- jsByteArray->setIndex(i, value.asInt32());
- return;
- } else {
- double dValue = 0;
- if (value.getNumber(dValue)) {
- jsByteArray->setIndex(i, dValue);
- return;
- }
- }
-
- baseValue.put(callFrame, i, value);
- } else
- baseValue.put(callFrame, i, value);
- } else {
- Identifier property(callFrame, subscript.toString(callFrame));
- if (!stackFrame.globalData->exception) { // Don't put to an object if toString threw an exception.
- PutPropertySlot slot(callFrame->codeBlock()->isStrictMode());
- baseValue.put(callFrame, property, value, slot);
- }
- }
-
- CHECK_FOR_EXCEPTION_AT_END();
-}
-
-DEFINE_STUB_FUNCTION(void, op_put_by_val_byte_array)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- CallFrame* callFrame = stackFrame.callFrame;
- JSGlobalData* globalData = stackFrame.globalData;
-
- JSValue baseValue = stackFrame.args[0].jsValue();
- JSValue subscript = stackFrame.args[1].jsValue();
- JSValue value = stackFrame.args[2].jsValue();
-
- if (LIKELY(subscript.isUInt32())) {
- uint32_t i = subscript.asUInt32();
- if (isJSByteArray(globalData, baseValue) && asByteArray(baseValue)->canAccessIndex(i)) {
- JSByteArray* jsByteArray = asByteArray(baseValue);
-
- // All fast byte array accesses are safe from exceptions so return immediately to avoid exception checks.
- if (value.isInt32()) {
- jsByteArray->setIndex(i, value.asInt32());
- return;
- } else {
- double dValue = 0;
- if (value.getNumber(dValue)) {
- jsByteArray->setIndex(i, dValue);
- return;
- }
- }
- }
-
- if (!isJSByteArray(globalData, baseValue))
- ctiPatchCallByReturnAddress(callFrame->codeBlock(), STUB_RETURN_ADDRESS, FunctionPtr(cti_op_put_by_val));
- baseValue.put(callFrame, i, value);
- } else {
- Identifier property(callFrame, subscript.toString(callFrame));
- if (!stackFrame.globalData->exception) { // Don't put to an object if toString threw an exception.
- PutPropertySlot slot(callFrame->codeBlock()->isStrictMode());
- baseValue.put(callFrame, property, value, slot);
- }
- }
-
- CHECK_FOR_EXCEPTION_AT_END();
-}
-
-DEFINE_STUB_FUNCTION(EncodedJSValue, op_lesseq)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- CallFrame* callFrame = stackFrame.callFrame;
- JSValue result = jsBoolean(jsLessEq(callFrame, stackFrame.args[0].jsValue(), stackFrame.args[1].jsValue()));
- CHECK_FOR_EXCEPTION_AT_END();
- return JSValue::encode(result);
-}
-
-DEFINE_STUB_FUNCTION(int, op_load_varargs)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- CallFrame* callFrame = stackFrame.callFrame;
- RegisterFile* registerFile = stackFrame.registerFile;
- int argsOffset = stackFrame.args[0].int32();
- JSValue arguments = callFrame->registers()[argsOffset].jsValue();
- uint32_t argCount = 0;
- if (!arguments) {
- int providedParams = callFrame->registers()[RegisterFile::ArgumentCount].i() - 1;
- argCount = providedParams;
- argCount = min(argCount, static_cast<uint32_t>(Arguments::MaxArguments));
- int32_t sizeDelta = argsOffset + argCount + RegisterFile::CallFrameHeaderSize;
- Register* newEnd = callFrame->registers() + sizeDelta;
- if (!registerFile->grow(newEnd) || ((newEnd - callFrame->registers()) != sizeDelta)) {
- stackFrame.globalData->exception = createStackOverflowError(callFrame);
- VM_THROW_EXCEPTION();
- }
- int32_t expectedParams = asFunction(callFrame->callee())->jsExecutable()->parameterCount();
- int32_t inplaceArgs = min(providedParams, expectedParams);
-
- Register* inplaceArgsDst = callFrame->registers() + argsOffset;
-
- Register* inplaceArgsEnd = inplaceArgsDst + inplaceArgs;
- Register* inplaceArgsEnd2 = inplaceArgsDst + providedParams;
-
- Register* inplaceArgsSrc = callFrame->registers() - RegisterFile::CallFrameHeaderSize - expectedParams;
- Register* inplaceArgsSrc2 = inplaceArgsSrc - providedParams - 1 + inplaceArgs;
-
- // First step is to copy the "expected" parameters from their normal location relative to the callframe
- while (inplaceArgsDst < inplaceArgsEnd)
- *inplaceArgsDst++ = *inplaceArgsSrc++;
-
- // Then we copy any additional arguments that may be further up the stack ('-1' to account for 'this')
- while (inplaceArgsDst < inplaceArgsEnd2)
- *inplaceArgsDst++ = *inplaceArgsSrc2++;
-
- } else if (!arguments.isUndefinedOrNull()) {
- if (!arguments.isObject()) {
- stackFrame.globalData->exception = createInvalidParamError(callFrame, "Function.prototype.apply", arguments);
- VM_THROW_EXCEPTION();
- }
- if (asObject(arguments)->classInfo() == &Arguments::s_info) {
- Arguments* argsObject = asArguments(arguments);
- argCount = argsObject->numProvidedArguments(callFrame);
- argCount = min(argCount, static_cast<uint32_t>(Arguments::MaxArguments));
- int32_t sizeDelta = argsOffset + argCount + RegisterFile::CallFrameHeaderSize;
- Register* newEnd = callFrame->registers() + sizeDelta;
- if (!registerFile->grow(newEnd) || ((newEnd - callFrame->registers()) != sizeDelta)) {
- stackFrame.globalData->exception = createStackOverflowError(callFrame);
- VM_THROW_EXCEPTION();
- }
- argsObject->copyToRegisters(callFrame, callFrame->registers() + argsOffset, argCount);
- } else if (isJSArray(&callFrame->globalData(), arguments)) {
- JSArray* array = asArray(arguments);
- argCount = array->length();
- argCount = min(argCount, static_cast<uint32_t>(Arguments::MaxArguments));
- int32_t sizeDelta = argsOffset + argCount + RegisterFile::CallFrameHeaderSize;
- Register* newEnd = callFrame->registers() + sizeDelta;
- if (!registerFile->grow(newEnd) || ((newEnd - callFrame->registers()) != sizeDelta)) {
- stackFrame.globalData->exception = createStackOverflowError(callFrame);
- VM_THROW_EXCEPTION();
- }
- array->copyToRegisters(callFrame, callFrame->registers() + argsOffset, argCount);
- } else if (asObject(arguments)->inherits(&JSArray::s_info)) {
- JSObject* argObject = asObject(arguments);
- argCount = argObject->get(callFrame, callFrame->propertyNames().length).toUInt32(callFrame);
- argCount = min(argCount, static_cast<uint32_t>(Arguments::MaxArguments));
- int32_t sizeDelta = argsOffset + argCount + RegisterFile::CallFrameHeaderSize;
- Register* newEnd = callFrame->registers() + sizeDelta;
- if (!registerFile->grow(newEnd) || ((newEnd - callFrame->registers()) != sizeDelta)) {
- stackFrame.globalData->exception = createStackOverflowError(callFrame);
- VM_THROW_EXCEPTION();
- }
- Register* argsBuffer = callFrame->registers() + argsOffset;
- for (unsigned i = 0; i < argCount; ++i) {
- argsBuffer[i] = asObject(arguments)->get(callFrame, i);
- CHECK_FOR_EXCEPTION();
- }
- } else {
- stackFrame.globalData->exception = createInvalidParamError(callFrame, "Function.prototype.apply", arguments);
- VM_THROW_EXCEPTION();
- }
- }
-
- return argCount + 1;
-}
-
-DEFINE_STUB_FUNCTION(EncodedJSValue, op_negate)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- JSValue src = stackFrame.args[0].jsValue();
-
- double v;
- if (src.getNumber(v))
- return JSValue::encode(jsNumber(-v));
-
- CallFrame* callFrame = stackFrame.callFrame;
- JSValue result = jsNumber(-src.toNumber(callFrame));
- CHECK_FOR_EXCEPTION_AT_END();
- return JSValue::encode(result);
-}
-
-DEFINE_STUB_FUNCTION(EncodedJSValue, op_resolve_base)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- return JSValue::encode(JSC::resolveBase(stackFrame.callFrame, stackFrame.args[0].identifier(), stackFrame.callFrame->scopeChain(), false));
-}
-
-DEFINE_STUB_FUNCTION(EncodedJSValue, op_resolve_base_strict_put)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
- JSValue base = JSC::resolveBase(stackFrame.callFrame, stackFrame.args[0].identifier(), stackFrame.callFrame->scopeChain(), true);
- if (!base) {
- stackFrame.globalData->exception = createErrorForInvalidGlobalAssignment(stackFrame.callFrame, stackFrame.args[0].identifier().ustring());
- VM_THROW_EXCEPTION();
- }
- return JSValue::encode(base);
-}
-
-DEFINE_STUB_FUNCTION(EncodedJSValue, op_ensure_property_exists)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
- JSValue base = stackFrame.callFrame->r(stackFrame.args[0].int32()).jsValue();
- JSObject* object = asObject(base);
- PropertySlot slot(object);
- ASSERT(stackFrame.callFrame->codeBlock()->isStrictMode());
- if (!object->getPropertySlot(stackFrame.callFrame, stackFrame.args[1].identifier(), slot)) {
- stackFrame.globalData->exception = createErrorForInvalidGlobalAssignment(stackFrame.callFrame, stackFrame.args[1].identifier().ustring());
- VM_THROW_EXCEPTION();
- }
-
- return JSValue::encode(base);
-}
-
-DEFINE_STUB_FUNCTION(EncodedJSValue, op_resolve_skip)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- CallFrame* callFrame = stackFrame.callFrame;
- ScopeChainNode* scopeChain = callFrame->scopeChain();
-
- int skip = stackFrame.args[1].int32();
-
- ScopeChainIterator iter = scopeChain->begin();
- ScopeChainIterator end = scopeChain->end();
- ASSERT(iter != end);
- CodeBlock* codeBlock = callFrame->codeBlock();
- bool checkTopLevel = codeBlock->codeType() == FunctionCode && codeBlock->needsFullScopeChain();
- ASSERT(skip || !checkTopLevel);
- if (checkTopLevel && skip--) {
- if (callFrame->uncheckedR(codeBlock->activationRegister()).jsValue())
- ++iter;
- }
- while (skip--) {
- ++iter;
- ASSERT(iter != end);
- }
- Identifier& ident = stackFrame.args[0].identifier();
- do {
- JSObject* o = iter->get();
- PropertySlot slot(o);
- if (o->getPropertySlot(callFrame, ident, slot)) {
- JSValue result = slot.getValue(callFrame, ident);
- CHECK_FOR_EXCEPTION_AT_END();
- return JSValue::encode(result);
- }
- } while (++iter != end);
-
- stackFrame.globalData->exception = createUndefinedVariableError(callFrame, ident);
- VM_THROW_EXCEPTION();
-}
-
-DEFINE_STUB_FUNCTION(EncodedJSValue, op_resolve_global)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- CallFrame* callFrame = stackFrame.callFrame;
- CodeBlock* codeBlock = callFrame->codeBlock();
- JSGlobalObject* globalObject = codeBlock->globalObject();
- Identifier& ident = stackFrame.args[0].identifier();
- unsigned globalResolveInfoIndex = stackFrame.args[1].int32();
- ASSERT(globalObject->isGlobalObject());
-
- PropertySlot slot(globalObject);
- if (globalObject->getPropertySlot(callFrame, ident, slot)) {
- JSValue result = slot.getValue(callFrame, ident);
- if (slot.isCacheableValue() && !globalObject->structure()->isUncacheableDictionary() && slot.slotBase() == globalObject) {
- GlobalResolveInfo& globalResolveInfo = codeBlock->globalResolveInfo(globalResolveInfoIndex);
- globalResolveInfo.structure.set(callFrame->globalData(), codeBlock->ownerExecutable(), globalObject->structure());
- globalResolveInfo.offset = slot.cachedOffset();
- return JSValue::encode(result);
- }
-
- CHECK_FOR_EXCEPTION_AT_END();
- return JSValue::encode(result);
- }
-
- stackFrame.globalData->exception = createUndefinedVariableError(callFrame, ident);
- VM_THROW_EXCEPTION();
-}
-
-DEFINE_STUB_FUNCTION(EncodedJSValue, op_div)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- JSValue src1 = stackFrame.args[0].jsValue();
- JSValue src2 = stackFrame.args[1].jsValue();
-
- double left;
- double right;
- if (src1.getNumber(left) && src2.getNumber(right))
- return JSValue::encode(jsNumber(left / right));
-
- CallFrame* callFrame = stackFrame.callFrame;
- JSValue result = jsNumber(src1.toNumber(callFrame) / src2.toNumber(callFrame));
- CHECK_FOR_EXCEPTION_AT_END();
- return JSValue::encode(result);
-}
-
-DEFINE_STUB_FUNCTION(EncodedJSValue, op_pre_dec)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- JSValue v = stackFrame.args[0].jsValue();
-
- CallFrame* callFrame = stackFrame.callFrame;
- JSValue result = jsNumber(v.toNumber(callFrame) - 1);
- CHECK_FOR_EXCEPTION_AT_END();
- return JSValue::encode(result);
-}
-
-DEFINE_STUB_FUNCTION(int, op_jless)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- JSValue src1 = stackFrame.args[0].jsValue();
- JSValue src2 = stackFrame.args[1].jsValue();
- CallFrame* callFrame = stackFrame.callFrame;
-
- bool result = jsLess(callFrame, src1, src2);
- CHECK_FOR_EXCEPTION_AT_END();
- return result;
-}
-
-DEFINE_STUB_FUNCTION(int, op_jlesseq)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- JSValue src1 = stackFrame.args[0].jsValue();
- JSValue src2 = stackFrame.args[1].jsValue();
- CallFrame* callFrame = stackFrame.callFrame;
-
- bool result = jsLessEq(callFrame, src1, src2);
- CHECK_FOR_EXCEPTION_AT_END();
- return result;
-}
-
-DEFINE_STUB_FUNCTION(EncodedJSValue, op_not)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- JSValue src = stackFrame.args[0].jsValue();
-
- CallFrame* callFrame = stackFrame.callFrame;
-
- JSValue result = jsBoolean(!src.toBoolean(callFrame));
- CHECK_FOR_EXCEPTION_AT_END();
- return JSValue::encode(result);
-}
-
-DEFINE_STUB_FUNCTION(int, op_jtrue)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- JSValue src1 = stackFrame.args[0].jsValue();
-
- CallFrame* callFrame = stackFrame.callFrame;
-
- bool result = src1.toBoolean(callFrame);
- CHECK_FOR_EXCEPTION_AT_END();
- return result;
-}
-
-DEFINE_STUB_FUNCTION(EncodedJSValue, op_post_inc)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- JSValue v = stackFrame.args[0].jsValue();
-
- CallFrame* callFrame = stackFrame.callFrame;
-
- JSValue number = v.toJSNumber(callFrame);
- CHECK_FOR_EXCEPTION_AT_END();
-
- callFrame->registers()[stackFrame.args[1].int32()] = jsNumber(number.uncheckedGetNumber() + 1);
- return JSValue::encode(number);
-}
-
-DEFINE_STUB_FUNCTION(int, op_eq)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- JSValue src1 = stackFrame.args[0].jsValue();
- JSValue src2 = stackFrame.args[1].jsValue();
-
-#if USE(JSVALUE32_64)
- start:
- if (src2.isUndefined()) {
- return src1.isNull() ||
- (src1.isCell() && src1.asCell()->structure()->typeInfo().masqueradesAsUndefined())
- || src1.isUndefined();
- }
-
- if (src2.isNull()) {
- return src1.isUndefined() ||
- (src1.isCell() && src1.asCell()->structure()->typeInfo().masqueradesAsUndefined())
- || src1.isNull();
- }
-
- if (src1.isInt32()) {
- if (src2.isDouble())
- return src1.asInt32() == src2.asDouble();
- double d = src2.toNumber(stackFrame.callFrame);
- CHECK_FOR_EXCEPTION();
- return src1.asInt32() == d;
- }
-
- if (src1.isDouble()) {
- if (src2.isInt32())
- return src1.asDouble() == src2.asInt32();
- double d = src2.toNumber(stackFrame.callFrame);
- CHECK_FOR_EXCEPTION();
- return src1.asDouble() == d;
- }
-
- if (src1.isTrue()) {
- if (src2.isFalse())
- return false;
- double d = src2.toNumber(stackFrame.callFrame);
- CHECK_FOR_EXCEPTION();
- return d == 1.0;
- }
-
- if (src1.isFalse()) {
- if (src2.isTrue())
- return false;
- double d = src2.toNumber(stackFrame.callFrame);
- CHECK_FOR_EXCEPTION();
- return d == 0.0;
- }
-
- if (src1.isUndefined())
- return src2.isCell() && src2.asCell()->structure()->typeInfo().masqueradesAsUndefined();
-
- if (src1.isNull())
- return src2.isCell() && src2.asCell()->structure()->typeInfo().masqueradesAsUndefined();
-
- JSCell* cell1 = src1.asCell();
-
- if (cell1->isString()) {
- if (src2.isInt32())
- return jsToNumber(static_cast<JSString*>(cell1)->value(stackFrame.callFrame)) == src2.asInt32();
-
- if (src2.isDouble())
- return jsToNumber(static_cast<JSString*>(cell1)->value(stackFrame.callFrame)) == src2.asDouble();
-
- if (src2.isTrue())
- return jsToNumber(static_cast<JSString*>(cell1)->value(stackFrame.callFrame)) == 1.0;
-
- if (src2.isFalse())
- return jsToNumber(static_cast<JSString*>(cell1)->value(stackFrame.callFrame)) == 0.0;
-
- JSCell* cell2 = src2.asCell();
- if (cell2->isString())
- return static_cast<JSString*>(cell1)->value(stackFrame.callFrame) == static_cast<JSString*>(cell2)->value(stackFrame.callFrame);
-
- src2 = asObject(cell2)->toPrimitive(stackFrame.callFrame);
- CHECK_FOR_EXCEPTION();
- goto start;
- }
-
- if (src2.isObject())
- return asObject(cell1) == asObject(src2);
- src1 = asObject(cell1)->toPrimitive(stackFrame.callFrame);
- CHECK_FOR_EXCEPTION();
- goto start;
-
-#else // USE(JSVALUE32_64)
- CallFrame* callFrame = stackFrame.callFrame;
-
- bool result = JSValue::equalSlowCaseInline(callFrame, src1, src2);
- CHECK_FOR_EXCEPTION_AT_END();
- return result;
-#endif // USE(JSVALUE32_64)
-}
-
-DEFINE_STUB_FUNCTION(int, op_eq_strings)
-{
-#if USE(JSVALUE32_64)
- STUB_INIT_STACK_FRAME(stackFrame);
-
- JSString* string1 = stackFrame.args[0].jsString();
- JSString* string2 = stackFrame.args[1].jsString();
-
- ASSERT(string1->isString());
- ASSERT(string2->isString());
- return string1->value(stackFrame.callFrame) == string2->value(stackFrame.callFrame);
-#else
- UNUSED_PARAM(args);
- ASSERT_NOT_REACHED();
- return 0;
-#endif
-}
-
-DEFINE_STUB_FUNCTION(EncodedJSValue, op_lshift)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- JSValue val = stackFrame.args[0].jsValue();
- JSValue shift = stackFrame.args[1].jsValue();
-
- CallFrame* callFrame = stackFrame.callFrame;
- JSValue result = jsNumber((val.toInt32(callFrame)) << (shift.toUInt32(callFrame) & 0x1f));
- CHECK_FOR_EXCEPTION_AT_END();
- return JSValue::encode(result);
-}
-
-DEFINE_STUB_FUNCTION(EncodedJSValue, op_bitand)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- JSValue src1 = stackFrame.args[0].jsValue();
- JSValue src2 = stackFrame.args[1].jsValue();
-
- ASSERT(!src1.isInt32() || !src2.isInt32());
- CallFrame* callFrame = stackFrame.callFrame;
- JSValue result = jsNumber(src1.toInt32(callFrame) & src2.toInt32(callFrame));
- CHECK_FOR_EXCEPTION_AT_END();
- return JSValue::encode(result);
-}
-
-DEFINE_STUB_FUNCTION(EncodedJSValue, op_rshift)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- JSValue val = stackFrame.args[0].jsValue();
- JSValue shift = stackFrame.args[1].jsValue();
-
- CallFrame* callFrame = stackFrame.callFrame;
- JSValue result = jsNumber((val.toInt32(callFrame)) >> (shift.toUInt32(callFrame) & 0x1f));
-
- CHECK_FOR_EXCEPTION_AT_END();
- return JSValue::encode(result);
-}
-
-DEFINE_STUB_FUNCTION(EncodedJSValue, op_bitnot)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- JSValue src = stackFrame.args[0].jsValue();
-
- ASSERT(!src.isInt32());
- CallFrame* callFrame = stackFrame.callFrame;
- JSValue result = jsNumber(~src.toInt32(callFrame));
- CHECK_FOR_EXCEPTION_AT_END();
- return JSValue::encode(result);
-}
-
-DEFINE_STUB_FUNCTION(EncodedJSValue, op_resolve_with_base)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- CallFrame* callFrame = stackFrame.callFrame;
- ScopeChainNode* scopeChain = callFrame->scopeChain();
-
- ScopeChainIterator iter = scopeChain->begin();
- ScopeChainIterator end = scopeChain->end();
-
- // FIXME: add scopeDepthIsZero optimization
-
- ASSERT(iter != end);
-
- Identifier& ident = stackFrame.args[0].identifier();
- JSObject* base;
- do {
- base = iter->get();
- PropertySlot slot(base);
- if (base->getPropertySlot(callFrame, ident, slot)) {
- JSValue result = slot.getValue(callFrame, ident);
- CHECK_FOR_EXCEPTION_AT_END();
-
- callFrame->registers()[stackFrame.args[1].int32()] = JSValue(base);
- return JSValue::encode(result);
- }
- ++iter;
- } while (iter != end);
-
- stackFrame.globalData->exception = createUndefinedVariableError(callFrame, ident);
- VM_THROW_EXCEPTION_AT_END();
- return JSValue::encode(JSValue());
-}
-
-DEFINE_STUB_FUNCTION(JSObject*, op_new_func_exp)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
- CallFrame* callFrame = stackFrame.callFrame;
-
- FunctionExecutable* function = stackFrame.args[0].function();
- JSFunction* func = function->make(callFrame, callFrame->scopeChain());
- ASSERT(callFrame->codeBlock()->codeType() != FunctionCode || !callFrame->codeBlock()->needsFullScopeChain() || callFrame->uncheckedR(callFrame->codeBlock()->activationRegister()).jsValue());
-
- /*
- The Identifier in a FunctionExpression can be referenced from inside
- the FunctionExpression's FunctionBody to allow the function to call
- itself recursively. However, unlike in a FunctionDeclaration, the
- Identifier in a FunctionExpression cannot be referenced from and
- does not affect the scope enclosing the FunctionExpression.
- */
- if (!function->name().isNull()) {
- JSStaticScopeObject* functionScopeObject = new (callFrame) JSStaticScopeObject(callFrame, function->name(), func, ReadOnly | DontDelete);
- func->setScope(callFrame->globalData(), func->scope()->push(functionScopeObject));
- }
-
- return func;
-}
-
-DEFINE_STUB_FUNCTION(EncodedJSValue, op_mod)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- JSValue dividendValue = stackFrame.args[0].jsValue();
- JSValue divisorValue = stackFrame.args[1].jsValue();
-
- CallFrame* callFrame = stackFrame.callFrame;
- double d = dividendValue.toNumber(callFrame);
- JSValue result = jsNumber(fmod(d, divisorValue.toNumber(callFrame)));
- CHECK_FOR_EXCEPTION_AT_END();
- return JSValue::encode(result);
-}
-
-DEFINE_STUB_FUNCTION(EncodedJSValue, op_less)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- CallFrame* callFrame = stackFrame.callFrame;
- JSValue result = jsBoolean(jsLess(callFrame, stackFrame.args[0].jsValue(), stackFrame.args[1].jsValue()));
- CHECK_FOR_EXCEPTION_AT_END();
- return JSValue::encode(result);
-}
-
-DEFINE_STUB_FUNCTION(EncodedJSValue, op_post_dec)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- JSValue v = stackFrame.args[0].jsValue();
-
- CallFrame* callFrame = stackFrame.callFrame;
-
- JSValue number = v.toJSNumber(callFrame);
- CHECK_FOR_EXCEPTION_AT_END();
-
- callFrame->registers()[stackFrame.args[1].int32()] = jsNumber(number.uncheckedGetNumber() - 1);
- return JSValue::encode(number);
-}
-
-DEFINE_STUB_FUNCTION(EncodedJSValue, op_urshift)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- JSValue val = stackFrame.args[0].jsValue();
- JSValue shift = stackFrame.args[1].jsValue();
-
- CallFrame* callFrame = stackFrame.callFrame;
- JSValue result = jsNumber((val.toUInt32(callFrame)) >> (shift.toUInt32(callFrame) & 0x1f));
- CHECK_FOR_EXCEPTION_AT_END();
- return JSValue::encode(result);
-}
-
-DEFINE_STUB_FUNCTION(EncodedJSValue, op_bitxor)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- JSValue src1 = stackFrame.args[0].jsValue();
- JSValue src2 = stackFrame.args[1].jsValue();
-
- CallFrame* callFrame = stackFrame.callFrame;
-
- JSValue result = jsNumber(src1.toInt32(callFrame) ^ src2.toInt32(callFrame));
- CHECK_FOR_EXCEPTION_AT_END();
- return JSValue::encode(result);
-}
-
-DEFINE_STUB_FUNCTION(JSObject*, op_new_regexp)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- CallFrame* callFrame = stackFrame.callFrame;
-
- RegExp* regExp = stackFrame.args[0].regExp();
- if (!regExp->isValid()) {
- stackFrame.globalData->exception = createSyntaxError(callFrame, "Invalid flags supplied to RegExp constructor.");
- VM_THROW_EXCEPTION();
- }
-
- return new (stackFrame.globalData) RegExpObject(stackFrame.callFrame->lexicalGlobalObject(), stackFrame.callFrame->lexicalGlobalObject()->regExpStructure(), regExp);
-}
-
-DEFINE_STUB_FUNCTION(EncodedJSValue, op_bitor)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- JSValue src1 = stackFrame.args[0].jsValue();
- JSValue src2 = stackFrame.args[1].jsValue();
-
- CallFrame* callFrame = stackFrame.callFrame;
-
- JSValue result = jsNumber(src1.toInt32(callFrame) | src2.toInt32(callFrame));
- CHECK_FOR_EXCEPTION_AT_END();
- return JSValue::encode(result);
-}
-
-DEFINE_STUB_FUNCTION(EncodedJSValue, op_call_eval)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
- ASSERT(stackFrame.callFrame->codeBlock()->codeType() != FunctionCode || !stackFrame.callFrame->codeBlock()->needsFullScopeChain() || stackFrame.callFrame->uncheckedR(stackFrame.callFrame->codeBlock()->activationRegister()).jsValue());
-
- CallFrame* callFrame = stackFrame.callFrame;
- RegisterFile* registerFile = stackFrame.registerFile;
-
- Interpreter* interpreter = stackFrame.globalData->interpreter;
-
- JSValue funcVal = stackFrame.args[0].jsValue();
- int registerOffset = stackFrame.args[1].int32();
- int argCount = stackFrame.args[2].int32();
-
- Register* newCallFrame = callFrame->registers() + registerOffset;
- Register* argv = newCallFrame - RegisterFile::CallFrameHeaderSize - argCount;
- JSValue baseValue = argv[0].jsValue();
- JSGlobalObject* globalObject = callFrame->scopeChain()->globalObject.get();
-
- if (baseValue == globalObject && funcVal == globalObject->evalFunction()) {
- JSValue result = interpreter->callEval(callFrame, registerFile, argv, argCount, registerOffset);
- CHECK_FOR_EXCEPTION_AT_END();
- return JSValue::encode(result);
- }
-
- return JSValue::encode(JSValue());
-}
-
-DEFINE_STUB_FUNCTION(void*, op_throw)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
- ExceptionHandler handler = jitThrow(stackFrame.globalData, stackFrame.callFrame, stackFrame.args[0].jsValue(), STUB_RETURN_ADDRESS);
- STUB_SET_RETURN_ADDRESS(handler.catchRoutine);
- return handler.callFrame;
-}
-
-DEFINE_STUB_FUNCTION(JSPropertyNameIterator*, op_get_pnames)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- CallFrame* callFrame = stackFrame.callFrame;
- JSObject* o = stackFrame.args[0].jsObject();
- Structure* structure = o->structure();
- JSPropertyNameIterator* jsPropertyNameIterator = structure->enumerationCache();
- if (!jsPropertyNameIterator || jsPropertyNameIterator->cachedPrototypeChain() != structure->prototypeChain(callFrame))
- jsPropertyNameIterator = JSPropertyNameIterator::create(callFrame, o);
- return jsPropertyNameIterator;
-}
-
-DEFINE_STUB_FUNCTION(int, has_property)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- JSObject* base = stackFrame.args[0].jsObject();
- JSString* property = stackFrame.args[1].jsString();
- int result = base->hasProperty(stackFrame.callFrame, Identifier(stackFrame.callFrame, property->value(stackFrame.callFrame)));
- CHECK_FOR_EXCEPTION_AT_END();
- return result;
-}
-
-DEFINE_STUB_FUNCTION(JSObject*, op_push_scope)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- JSObject* o = stackFrame.args[0].jsValue().toObject(stackFrame.callFrame);
- CHECK_FOR_EXCEPTION();
- stackFrame.callFrame->setScopeChain(stackFrame.callFrame->scopeChain()->push(o));
- return o;
-}
-
-DEFINE_STUB_FUNCTION(void, op_pop_scope)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- stackFrame.callFrame->setScopeChain(stackFrame.callFrame->scopeChain()->pop());
-}
-
-DEFINE_STUB_FUNCTION(EncodedJSValue, op_typeof)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- return JSValue::encode(jsTypeStringForValue(stackFrame.callFrame, stackFrame.args[0].jsValue()));
-}
-
-DEFINE_STUB_FUNCTION(EncodedJSValue, op_is_undefined)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- JSValue v = stackFrame.args[0].jsValue();
- return JSValue::encode(jsBoolean(v.isCell() ? v.asCell()->structure()->typeInfo().masqueradesAsUndefined() : v.isUndefined()));
-}
-
-DEFINE_STUB_FUNCTION(EncodedJSValue, op_is_boolean)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- return JSValue::encode(jsBoolean(stackFrame.args[0].jsValue().isBoolean()));
-}
-
-DEFINE_STUB_FUNCTION(EncodedJSValue, op_is_number)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- return JSValue::encode(jsBoolean(stackFrame.args[0].jsValue().isNumber()));
-}
-
-DEFINE_STUB_FUNCTION(EncodedJSValue, op_is_string)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- return JSValue::encode(jsBoolean(isJSString(stackFrame.globalData, stackFrame.args[0].jsValue())));
-}
-
-DEFINE_STUB_FUNCTION(EncodedJSValue, op_is_object)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- return JSValue::encode(jsBoolean(jsIsObjectType(stackFrame.args[0].jsValue())));
-}
-
-DEFINE_STUB_FUNCTION(EncodedJSValue, op_is_function)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- return JSValue::encode(jsBoolean(jsIsFunctionType(stackFrame.args[0].jsValue())));
-}
-
-DEFINE_STUB_FUNCTION(EncodedJSValue, op_stricteq)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- JSValue src1 = stackFrame.args[0].jsValue();
- JSValue src2 = stackFrame.args[1].jsValue();
-
- bool result = JSValue::strictEqual(stackFrame.callFrame, src1, src2);
- CHECK_FOR_EXCEPTION_AT_END();
- return JSValue::encode(jsBoolean(result));
-}
-
-DEFINE_STUB_FUNCTION(EncodedJSValue, op_to_primitive)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- return JSValue::encode(stackFrame.args[0].jsValue().toPrimitive(stackFrame.callFrame));
-}
-
-DEFINE_STUB_FUNCTION(EncodedJSValue, op_strcat)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- JSValue result = jsString(stackFrame.callFrame, &stackFrame.callFrame->registers()[stackFrame.args[0].int32()], stackFrame.args[1].int32());
- CHECK_FOR_EXCEPTION_AT_END();
- return JSValue::encode(result);
-}
-
-DEFINE_STUB_FUNCTION(EncodedJSValue, op_nstricteq)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- JSValue src1 = stackFrame.args[0].jsValue();
- JSValue src2 = stackFrame.args[1].jsValue();
-
- bool result = !JSValue::strictEqual(stackFrame.callFrame, src1, src2);
- CHECK_FOR_EXCEPTION_AT_END();
- return JSValue::encode(jsBoolean(result));
-}
-
-DEFINE_STUB_FUNCTION(EncodedJSValue, op_to_jsnumber)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- JSValue src = stackFrame.args[0].jsValue();
- CallFrame* callFrame = stackFrame.callFrame;
-
- JSValue result = src.toJSNumber(callFrame);
- CHECK_FOR_EXCEPTION_AT_END();
- return JSValue::encode(result);
-}
-
-DEFINE_STUB_FUNCTION(EncodedJSValue, op_in)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- CallFrame* callFrame = stackFrame.callFrame;
- JSValue baseVal = stackFrame.args[1].jsValue();
-
- if (!baseVal.isObject()) {
- stackFrame.globalData->exception = createInvalidParamError(stackFrame.callFrame, "in", baseVal);
- VM_THROW_EXCEPTION();
- }
-
- JSValue propName = stackFrame.args[0].jsValue();
- JSObject* baseObj = asObject(baseVal);
-
- uint32_t i;
- if (propName.getUInt32(i))
- return JSValue::encode(jsBoolean(baseObj->hasProperty(callFrame, i)));
-
- Identifier property(callFrame, propName.toString(callFrame));
- CHECK_FOR_EXCEPTION();
- return JSValue::encode(jsBoolean(baseObj->hasProperty(callFrame, property)));
-}
-
-DEFINE_STUB_FUNCTION(JSObject*, op_push_new_scope)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- JSObject* scope = new (stackFrame.globalData) JSStaticScopeObject(stackFrame.callFrame, stackFrame.args[0].identifier(), stackFrame.args[1].jsValue(), DontDelete);
-
- CallFrame* callFrame = stackFrame.callFrame;
- callFrame->setScopeChain(callFrame->scopeChain()->push(scope));
- return scope;
-}
-
-DEFINE_STUB_FUNCTION(void, op_jmp_scopes)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- unsigned count = stackFrame.args[0].int32();
- CallFrame* callFrame = stackFrame.callFrame;
-
- ScopeChainNode* tmp = callFrame->scopeChain();
- while (count--)
- tmp = tmp->pop();
- callFrame->setScopeChain(tmp);
-}
-
-DEFINE_STUB_FUNCTION(void, op_put_by_index)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- CallFrame* callFrame = stackFrame.callFrame;
- unsigned property = stackFrame.args[1].int32();
-
- stackFrame.args[0].jsValue().put(callFrame, property, stackFrame.args[2].jsValue());
-}
-
-DEFINE_STUB_FUNCTION(void*, op_switch_imm)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- JSValue scrutinee = stackFrame.args[0].jsValue();
- unsigned tableIndex = stackFrame.args[1].int32();
- CallFrame* callFrame = stackFrame.callFrame;
- CodeBlock* codeBlock = callFrame->codeBlock();
-
- if (scrutinee.isInt32())
- return codeBlock->immediateSwitchJumpTable(tableIndex).ctiForValue(scrutinee.asInt32()).executableAddress();
- else {
- double value;
- int32_t intValue;
- if (scrutinee.getNumber(value) && ((intValue = static_cast<int32_t>(value)) == value))
- return codeBlock->immediateSwitchJumpTable(tableIndex).ctiForValue(intValue).executableAddress();
- else
- return codeBlock->immediateSwitchJumpTable(tableIndex).ctiDefault.executableAddress();
- }
-}
-
-DEFINE_STUB_FUNCTION(void*, op_switch_char)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- JSValue scrutinee = stackFrame.args[0].jsValue();
- unsigned tableIndex = stackFrame.args[1].int32();
- CallFrame* callFrame = stackFrame.callFrame;
- CodeBlock* codeBlock = callFrame->codeBlock();
-
- void* result = codeBlock->characterSwitchJumpTable(tableIndex).ctiDefault.executableAddress();
-
- if (scrutinee.isString()) {
- StringImpl* value = asString(scrutinee)->value(callFrame).impl();
- if (value->length() == 1)
- result = codeBlock->characterSwitchJumpTable(tableIndex).ctiForValue(value->characters()[0]).executableAddress();
- }
-
- CHECK_FOR_EXCEPTION_AT_END();
- return result;
-}
-
-DEFINE_STUB_FUNCTION(void*, op_switch_string)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- JSValue scrutinee = stackFrame.args[0].jsValue();
- unsigned tableIndex = stackFrame.args[1].int32();
- CallFrame* callFrame = stackFrame.callFrame;
- CodeBlock* codeBlock = callFrame->codeBlock();
-
- void* result = codeBlock->stringSwitchJumpTable(tableIndex).ctiDefault.executableAddress();
-
- if (scrutinee.isString()) {
- StringImpl* value = asString(scrutinee)->value(callFrame).impl();
- result = codeBlock->stringSwitchJumpTable(tableIndex).ctiForValue(value).executableAddress();
- }
-
- CHECK_FOR_EXCEPTION_AT_END();
- return result;
-}
-
-DEFINE_STUB_FUNCTION(EncodedJSValue, op_del_by_val)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- CallFrame* callFrame = stackFrame.callFrame;
-
- JSValue baseValue = stackFrame.args[0].jsValue();
- JSObject* baseObj = baseValue.toObject(callFrame); // may throw
-
- JSValue subscript = stackFrame.args[1].jsValue();
- bool result;
- uint32_t i;
- if (subscript.getUInt32(i))
- result = baseObj->deleteProperty(callFrame, i);
- else {
- CHECK_FOR_EXCEPTION();
- Identifier property(callFrame, subscript.toString(callFrame));
- CHECK_FOR_EXCEPTION();
- result = baseObj->deleteProperty(callFrame, property);
- }
-
- if (!result && callFrame->codeBlock()->isStrictMode())
- stackFrame.globalData->exception = createTypeError(stackFrame.callFrame, "Unable to delete property.");
-
- CHECK_FOR_EXCEPTION_AT_END();
- return JSValue::encode(jsBoolean(result));
-}
-
-DEFINE_STUB_FUNCTION(void, op_put_getter)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- CallFrame* callFrame = stackFrame.callFrame;
-
- ASSERT(stackFrame.args[0].jsValue().isObject());
- JSObject* baseObj = asObject(stackFrame.args[0].jsValue());
- ASSERT(stackFrame.args[2].jsValue().isObject());
- baseObj->defineGetter(callFrame, stackFrame.args[1].identifier(), asObject(stackFrame.args[2].jsValue()));
-}
-
-DEFINE_STUB_FUNCTION(void, op_put_setter)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- CallFrame* callFrame = stackFrame.callFrame;
-
- ASSERT(stackFrame.args[0].jsValue().isObject());
- JSObject* baseObj = asObject(stackFrame.args[0].jsValue());
- ASSERT(stackFrame.args[2].jsValue().isObject());
- baseObj->defineSetter(callFrame, stackFrame.args[1].identifier(), asObject(stackFrame.args[2].jsValue()));
-}
-
-DEFINE_STUB_FUNCTION(void, op_throw_reference_error)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- CallFrame* callFrame = stackFrame.callFrame;
- UString message = stackFrame.args[0].jsValue().toString(callFrame);
- stackFrame.globalData->exception = createReferenceError(callFrame, message);
- VM_THROW_EXCEPTION_AT_END();
-}
-
-DEFINE_STUB_FUNCTION(void, op_debug)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- CallFrame* callFrame = stackFrame.callFrame;
-
- int debugHookID = stackFrame.args[0].int32();
- int firstLine = stackFrame.args[1].int32();
- int lastLine = stackFrame.args[2].int32();
-
- stackFrame.globalData->interpreter->debug(callFrame, static_cast<DebugHookID>(debugHookID), firstLine, lastLine);
-}
-
-DEFINE_STUB_FUNCTION(void*, vm_throw)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
- JSGlobalData* globalData = stackFrame.globalData;
- ExceptionHandler handler = jitThrow(globalData, stackFrame.callFrame, globalData->exception, globalData->exceptionLocation);
- STUB_SET_RETURN_ADDRESS(handler.catchRoutine);
- return handler.callFrame;
-}
-
-DEFINE_STUB_FUNCTION(EncodedJSValue, to_object)
-{
- STUB_INIT_STACK_FRAME(stackFrame);
-
- CallFrame* callFrame = stackFrame.callFrame;
- return JSValue::encode(stackFrame.args[0].jsValue().toObject(callFrame));
-}
-
-MacroAssemblerCodePtr JITThunks::ctiStub(JSGlobalData* globalData, ThunkGenerator generator)
-{
- std::pair<CTIStubMap::iterator, bool> entry = m_ctiStubMap.add(generator, MacroAssemblerCodePtr());
- if (entry.second)
- entry.first->second = generator(globalData, m_executablePool.get());
- return entry.first->second;
-}
-
-NativeExecutable* JITThunks::hostFunctionStub(JSGlobalData* globalData, NativeFunction function)
-{
- std::pair<HostFunctionStubMap::iterator, bool> entry = m_hostFunctionStubMap->add(function, Weak<NativeExecutable>());
- if (!*entry.first->second)
- entry.first->second.set(*globalData, NativeExecutable::create(*globalData, JIT::compileCTINativeCall(globalData, m_executablePool, function), function, ctiNativeConstruct(), callHostFunctionAsConstructor));
- return entry.first->second.get();
-}
-
-NativeExecutable* JITThunks::hostFunctionStub(JSGlobalData* globalData, NativeFunction function, ThunkGenerator generator)
-{
- std::pair<HostFunctionStubMap::iterator, bool> entry = m_hostFunctionStubMap->add(function, Weak<NativeExecutable>());
- if (!*entry.first->second) {
- MacroAssemblerCodePtr code = globalData->canUseJIT() ? generator(globalData, m_executablePool.get()) : MacroAssemblerCodePtr();
- entry.first->second.set(*globalData, NativeExecutable::create(*globalData, code, function, ctiNativeConstruct(), callHostFunctionAsConstructor));
- }
- return entry.first->second.get();
-}
-
-void JITThunks::clearHostFunctionStubs()
-{
- m_hostFunctionStubMap.clear();
-}
-
-} // namespace JSC
-