Commit b749f0bb authored by barraclough@apple.com's avatar barraclough@apple.com

https://bugs.webkit.org/show_bug.cgi?id=32184

Handle out-of-memory conditions with JSC Ropes with a JS exception, rather than crashing.
Switch from using fastMalloc to tryFastMalloc, pass an ExecState to record the exception on.

Reviewed by Oliver Hunt.

JavaScriptCore: 

* API/JSCallbackObjectFunctions.h:
(JSC::::toString):
* API/JSValueRef.cpp:
(JSValueIsStrictEqual):
* JavaScriptCore.exp:
* bytecompiler/BytecodeGenerator.cpp:
(JSC::BytecodeGenerator::emitEqualityOp):
* debugger/DebuggerCallFrame.cpp:
(JSC::DebuggerCallFrame::functionName):
(JSC::DebuggerCallFrame::calculatedFunctionName):
* interpreter/Interpreter.cpp:
(JSC::Interpreter::callEval):
(JSC::Interpreter::privateExecute):
* jit/JITStubs.cpp:
(JSC::DEFINE_STUB_FUNCTION):
* profiler/ProfileGenerator.cpp:
(JSC::ProfileGenerator::addParentForConsoleStart):
* profiler/Profiler.cpp:
(JSC::Profiler::willExecute):
(JSC::Profiler::didExecute):
(JSC::Profiler::createCallIdentifier):
(JSC::createCallIdentifierFromFunctionImp):
* profiler/Profiler.h:
* runtime/ArrayPrototype.cpp:
(JSC::arrayProtoFuncIndexOf):
(JSC::arrayProtoFuncLastIndexOf):
* runtime/DateConstructor.cpp:
(JSC::constructDate):
* runtime/FunctionPrototype.cpp:
(JSC::functionProtoFuncToString):
* runtime/InternalFunction.cpp:
(JSC::InternalFunction::name):
(JSC::InternalFunction::displayName):
(JSC::InternalFunction::calculatedDisplayName):
* runtime/InternalFunction.h:
* runtime/JSCell.cpp:
(JSC::JSCell::getString):
* runtime/JSCell.h:
(JSC::JSValue::getString):
* runtime/JSONObject.cpp:
(JSC::gap):
(JSC::Stringifier::Stringifier):
(JSC::Stringifier::appendStringifiedValue):
* runtime/JSObject.cpp:
(JSC::JSObject::putDirectFunction):
(JSC::JSObject::putDirectFunctionWithoutTransition):
(JSC::JSObject::defineOwnProperty):
* runtime/JSObject.h:
* runtime/JSPropertyNameIterator.cpp:
(JSC::JSPropertyNameIterator::get):
* runtime/JSString.cpp:
(JSC::JSString::Rope::~Rope):
(JSC::JSString::resolveRope):
(JSC::JSString::getPrimitiveNumber):
(JSC::JSString::toNumber):
(JSC::JSString::toString):
(JSC::JSString::toThisString):
(JSC::JSString::getStringPropertyDescriptor):
* runtime/JSString.h:
(JSC::JSString::Rope::createOrNull):
(JSC::JSString::Rope::operator new):
(JSC::JSString::value):
(JSC::JSString::tryGetValue):
(JSC::JSString::getIndex):
(JSC::JSString::getStringPropertySlot):
(JSC::JSValue::toString):
* runtime/JSValue.h:
* runtime/NativeErrorConstructor.cpp:
(JSC::NativeErrorConstructor::NativeErrorConstructor):
* runtime/Operations.cpp:
(JSC::JSValue::strictEqualSlowCase):
* runtime/Operations.h:
(JSC::JSValue::equalSlowCaseInline):
(JSC::JSValue::strictEqualSlowCaseInline):
(JSC::JSValue::strictEqual):
(JSC::jsLess):
(JSC::jsLessEq):
(JSC::jsAdd):
(JSC::concatenateStrings):
* runtime/PropertyDescriptor.cpp:
(JSC::PropertyDescriptor::equalTo):
* runtime/PropertyDescriptor.h:
* runtime/StringPrototype.cpp:
(JSC::stringProtoFuncReplace):
(JSC::stringProtoFuncToLowerCase):
(JSC::stringProtoFuncToUpperCase):

WebCore: 

* bindings/ScriptControllerBase.cpp:
(WebCore::ScriptController::executeIfJavaScriptURL):
* bindings/js/JSCanvasRenderingContext2DCustom.cpp:
(WebCore::toHTMLCanvasStyle):
(WebCore::JSCanvasRenderingContext2D::setFillColor):
(WebCore::JSCanvasRenderingContext2D::setStrokeColor):
(WebCore::JSCanvasRenderingContext2D::setShadow):
* bindings/js/ScriptCallStack.cpp:
(WebCore::ScriptCallStack::ScriptCallStack):
(WebCore::ScriptCallStack::initialize):
* bindings/js/ScriptValue.cpp:
(WebCore::ScriptValue::getString):
* bindings/js/ScriptValue.h:
* bindings/js/SerializedScriptValue.cpp:
(WebCore::SerializingTreeWalker::convertIfTerminal):
* bindings/objc/WebScriptObject.mm:
(+[WebScriptObject _convertValueToObjcValue:originRootObject:rootObject:]):
* page/Console.cpp:
(WebCore::Console::addMessage):

WebKit/mac: 

* WebView/WebView.mm:
(aeDescFromJSValue):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@51801 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 9b7eb041
......@@ -467,7 +467,7 @@ UString JSCallbackObject<Base>::toString(ExecState* exec) const
return "";
}
if (value)
return toJS(exec, value).getString();
return toJS(exec, value).getString(exec);
}
return Base::toString(exec);
......
......@@ -169,7 +169,7 @@ bool JSValueIsStrictEqual(JSContextRef ctx, JSValueRef a, JSValueRef b)
JSValue jsA = toJS(exec, a);
JSValue jsB = toJS(exec, b);
return JSValue::strictEqual(jsA, jsB);
return JSValue::strictEqual(exec, jsA, jsB);
}
bool JSValueIsInstanceOfConstructor(JSContextRef ctx, JSValueRef value, JSObjectRef constructor, JSValueRef* exception)
......
2009-12-05 Gavin Barraclough <barraclough@apple.com>
Reviewed by Oliver Hunt.
https://bugs.webkit.org/show_bug.cgi?id=32184
Handle out-of-memory conditions with JSC Ropes with a JS exception, rather than crashing.
Switch from using fastMalloc to tryFastMalloc, pass an ExecState to record the exception on.
* API/JSCallbackObjectFunctions.h:
(JSC::::toString):
* API/JSValueRef.cpp:
(JSValueIsStrictEqual):
* JavaScriptCore.exp:
* bytecompiler/BytecodeGenerator.cpp:
(JSC::BytecodeGenerator::emitEqualityOp):
* debugger/DebuggerCallFrame.cpp:
(JSC::DebuggerCallFrame::functionName):
(JSC::DebuggerCallFrame::calculatedFunctionName):
* interpreter/Interpreter.cpp:
(JSC::Interpreter::callEval):
(JSC::Interpreter::privateExecute):
* jit/JITStubs.cpp:
(JSC::DEFINE_STUB_FUNCTION):
* profiler/ProfileGenerator.cpp:
(JSC::ProfileGenerator::addParentForConsoleStart):
* profiler/Profiler.cpp:
(JSC::Profiler::willExecute):
(JSC::Profiler::didExecute):
(JSC::Profiler::createCallIdentifier):
(JSC::createCallIdentifierFromFunctionImp):
* profiler/Profiler.h:
* runtime/ArrayPrototype.cpp:
(JSC::arrayProtoFuncIndexOf):
(JSC::arrayProtoFuncLastIndexOf):
* runtime/DateConstructor.cpp:
(JSC::constructDate):
* runtime/FunctionPrototype.cpp:
(JSC::functionProtoFuncToString):
* runtime/InternalFunction.cpp:
(JSC::InternalFunction::name):
(JSC::InternalFunction::displayName):
(JSC::InternalFunction::calculatedDisplayName):
* runtime/InternalFunction.h:
* runtime/JSCell.cpp:
(JSC::JSCell::getString):
* runtime/JSCell.h:
(JSC::JSValue::getString):
* runtime/JSONObject.cpp:
(JSC::gap):
(JSC::Stringifier::Stringifier):
(JSC::Stringifier::appendStringifiedValue):
* runtime/JSObject.cpp:
(JSC::JSObject::putDirectFunction):
(JSC::JSObject::putDirectFunctionWithoutTransition):
(JSC::JSObject::defineOwnProperty):
* runtime/JSObject.h:
* runtime/JSPropertyNameIterator.cpp:
(JSC::JSPropertyNameIterator::get):
* runtime/JSString.cpp:
(JSC::JSString::Rope::~Rope):
(JSC::JSString::resolveRope):
(JSC::JSString::getPrimitiveNumber):
(JSC::JSString::toNumber):
(JSC::JSString::toString):
(JSC::JSString::toThisString):
(JSC::JSString::getStringPropertyDescriptor):
* runtime/JSString.h:
(JSC::JSString::Rope::createOrNull):
(JSC::JSString::Rope::operator new):
(JSC::JSString::value):
(JSC::JSString::tryGetValue):
(JSC::JSString::getIndex):
(JSC::JSString::getStringPropertySlot):
(JSC::JSValue::toString):
* runtime/JSValue.h:
* runtime/NativeErrorConstructor.cpp:
(JSC::NativeErrorConstructor::NativeErrorConstructor):
* runtime/Operations.cpp:
(JSC::JSValue::strictEqualSlowCase):
* runtime/Operations.h:
(JSC::JSValue::equalSlowCaseInline):
(JSC::JSValue::strictEqualSlowCaseInline):
(JSC::JSValue::strictEqual):
(JSC::jsLess):
(JSC::jsLessEq):
(JSC::jsAdd):
(JSC::concatenateStrings):
* runtime/PropertyDescriptor.cpp:
(JSC::PropertyDescriptor::equalTo):
* runtime/PropertyDescriptor.h:
* runtime/StringPrototype.cpp:
(JSC::stringProtoFuncReplace):
(JSC::stringProtoFuncToLowerCase):
(JSC::stringProtoFuncToUpperCase):
2009-12-07 Nikolas Zimmermann <nzimmermann@rim.com>
Reviewed by Holger Freyther.
......
......@@ -150,7 +150,7 @@ __ZN3JSC15JSWrapperObject12markChildrenERNS_9MarkStackE
__ZN3JSC15createTypeErrorEPNS_9ExecStateEPKc
__ZN3JSC15toInt32SlowCaseEdRb
__ZN3JSC16InternalFunction4infoE
__ZN3JSC16InternalFunction4nameEPNS_12JSGlobalDataE
__ZN3JSC16InternalFunction4nameEPNS_9ExecStateE
__ZN3JSC16InternalFunctionC2EPNS_12JSGlobalDataEN3WTF17NonNullPassRefPtrINS_9StructureEEERKNS_10IdentifierE
__ZN3JSC16JSVariableObject14deletePropertyEPNS_9ExecStateERKNS_10IdentifierE
__ZN3JSC16JSVariableObject14symbolTableGetERKNS_10IdentifierERNS_18PropertyDescriptorE
......@@ -377,9 +377,9 @@ __ZNK3JSC6JSCell8toNumberEPNS_9ExecStateE
__ZNK3JSC6JSCell8toObjectEPNS_9ExecStateE
__ZNK3JSC6JSCell8toStringEPNS_9ExecStateE
__ZNK3JSC6JSCell9classInfoEv
__ZNK3JSC6JSCell9getStringERNS_7UStringE
__ZNK3JSC6JSCell9getStringEv
__ZNK3JSC6JSCell9getUInt32ERj
__ZNK3JSC6JSCell9getStringEPNS_9ExecStateE
__ZNK3JSC6JSCell9getStringEPNS_9ExecStateERNS_7UStringE
__ZNK3JSC6JSCell9toBooleanEPNS_9ExecStateE
__ZNK3JSC7ArgList8getSliceEiRS0_
__ZNK3JSC7JSValue16toObjectSlowCaseEPNS_9ExecStateE
......@@ -403,7 +403,7 @@ __ZNK3JSC8JSObject8toObjectEPNS_9ExecStateE
__ZNK3JSC8JSObject8toStringEPNS_9ExecStateE
__ZNK3JSC8JSObject9classNameEv
__ZNK3JSC8JSObject9toBooleanEPNS_9ExecStateE
__ZNK3JSC8JSString11resolveRopeEv
__ZNK3JSC8JSString11resolveRopeEPNS_9ExecStateE
__ZNK3JSC9HashTable11createTableEPNS_12JSGlobalDataE
__ZNK3JSC9HashTable11deleteTableEv
__ZNK3WTF8Collator7collateEPKtmS2_m
......
......@@ -904,7 +904,7 @@ RegisterID* BytecodeGenerator::emitEqualityOp(OpcodeID opcodeID, RegisterID* dst
&& src1->isTemporary()
&& m_codeBlock->isConstantRegisterIndex(src2->index())
&& m_codeBlock->constantRegister(src2->index()).jsValue().isString()) {
const UString& value = asString(m_codeBlock->constantRegister(src2->index()).jsValue())->value();
const UString& value = asString(m_codeBlock->constantRegister(src2->index()).jsValue())->tryGetValue();
if (value == "undefined") {
rewindUnaryOp();
emitOpcode(op_is_undefined);
......
......@@ -44,7 +44,7 @@ const UString* DebuggerCallFrame::functionName() const
JSFunction* function = asFunction(m_callFrame->callee());
if (!function)
return 0;
return &function->name(&m_callFrame->globalData());
return &function->name(m_callFrame);
}
UString DebuggerCallFrame::calculatedFunctionName() const
......@@ -55,7 +55,7 @@ UString DebuggerCallFrame::calculatedFunctionName() const
JSFunction* function = asFunction(m_callFrame->callee());
if (!function)
return 0;
return function->calculatedDisplayName(&m_callFrame->globalData());
return function->calculatedDisplayName(m_callFrame);
}
DebuggerCallFrame::Type DebuggerCallFrame::type() const
......
......@@ -300,7 +300,7 @@ NEVER_INLINE JSValue Interpreter::callEval(CallFrame* callFrame, RegisterFile* r
if (!program.isString())
return program;
UString programSource = asString(program)->value();
UString programSource = asString(program)->value(callFrame);
LiteralParser preparser(callFrame, programSource, LiteralParser::NonStrictJSON);
if (JSValue parsedObject = preparser.tryLiteralParse())
......@@ -1306,7 +1306,7 @@ JSValue Interpreter::privateExecute(ExecutionFlag flag, RegisterFile* registerFi
int dst = vPC[1].u.operand;
JSValue src1 = callFrame->r(vPC[2].u.operand).jsValue();
JSValue src2 = callFrame->r(vPC[3].u.operand).jsValue();
callFrame->r(dst) = jsBoolean(JSValue::strictEqual(src1, src2));
callFrame->r(dst) = jsBoolean(JSValue::strictEqual(callFrame, src1, src2));
vPC += OPCODE_LENGTH(op_stricteq);
NEXT_INSTRUCTION();
......@@ -1321,7 +1321,7 @@ JSValue Interpreter::privateExecute(ExecutionFlag flag, RegisterFile* registerFi
int dst = vPC[1].u.operand;
JSValue src1 = callFrame->r(vPC[2].u.operand).jsValue();
JSValue src2 = callFrame->r(vPC[3].u.operand).jsValue();
callFrame->r(dst) = jsBoolean(!JSValue::strictEqual(src1, src2));
callFrame->r(dst) = jsBoolean(!JSValue::strictEqual(callFrame, src1, src2));
vPC += OPCODE_LENGTH(op_nstricteq);
NEXT_INSTRUCTION();
......@@ -2479,7 +2479,7 @@ JSValue Interpreter::privateExecute(ExecutionFlag flag, RegisterFile* registerFi
else
result = jsArray->JSArray::get(callFrame, i);
} else if (isJSString(globalData, baseValue) && asString(baseValue)->canGetIndex(i))
result = asString(baseValue)->getIndex(&callFrame->globalData(), i);
result = asString(baseValue)->getIndex(callFrame, i);
else if (isJSByteArray(globalData, baseValue) && asByteArray(baseValue)->canAccessIndex(i))
result = asByteArray(baseValue)->getIndex(callFrame, i);
else
......@@ -2915,7 +2915,7 @@ JSValue Interpreter::privateExecute(ExecutionFlag flag, RegisterFile* registerFi
if (!scrutinee.isString())
vPC += defaultOffset;
else {
UString::Rep* value = asString(scrutinee)->value().rep();
UString::Rep* value = asString(scrutinee)->value(callFrame).rep();
if (value->size() != 1)
vPC += defaultOffset;
else
......@@ -2938,7 +2938,7 @@ JSValue Interpreter::privateExecute(ExecutionFlag flag, RegisterFile* registerFi
if (!scrutinee.isString())
vPC += defaultOffset;
else
vPC += callFrame->codeBlock()->stringSwitchJumpTable(tableIndex).offsetForValue(asString(scrutinee)->value().rep(), defaultOffset);
vPC += callFrame->codeBlock()->stringSwitchJumpTable(tableIndex).offsetForValue(asString(scrutinee)->value(callFrame).rep(), defaultOffset);
NEXT_INSTRUCTION();
}
DEFINE_OPCODE(op_new_func) {
......@@ -3531,6 +3531,7 @@ JSValue Interpreter::privateExecute(ExecutionFlag flag, RegisterFile* registerFi
int count = vPC[3].u.operand;
callFrame->r(dst) = concatenateStrings(callFrame, &callFrame->registers()[src], count);
CHECK_FOR_EXCEPTION();
vPC += OPCODE_LENGTH(op_strcat);
NEXT_INSTRUCTION();
......
......@@ -1044,14 +1044,18 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, op_add)
bool leftIsString = v1.isString();
if (leftIsString && v2.isString()) {
if (asString(v1)->isRope() || asString(v2)->isRope()) {
RefPtr<JSString::Rope> rope = JSString::Rope::create(2);
RefPtr<JSString::Rope> rope = JSString::Rope::createOrNull(2);
if (UNLIKELY(!rope)) {
throwOutOfMemoryError(callFrame);
VM_THROW_EXCEPTION();
}
rope->initializeFiber(0, asString(v1));
rope->initializeFiber(1, asString(v2));
JSGlobalData* globalData = &callFrame->globalData();
return JSValue::encode(new (globalData) JSString(globalData, rope.release()));
}
RefPtr<UString::Rep> value = concatenate(asString(v1)->value().rep(), asString(v2)->value().rep());
RefPtr<UString::Rep> value = concatenate(asString(v1)->value(callFrame).rep(), asString(v2)->value(callFrame).rep());
if (UNLIKELY(!value)) {
throwOutOfMemoryError(callFrame);
VM_THROW_EXCEPTION();
......@@ -1062,8 +1066,8 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, op_add)
if (rightIsNumber & leftIsString) {
RefPtr<UString::Rep> value = v2.isInt32() ?
concatenate(asString(v1)->value().rep(), v2.asInt32()) :
concatenate(asString(v1)->value().rep(), right);
concatenate(asString(v1)->value(callFrame).rep(), v2.asInt32()) :
concatenate(asString(v1)->value(callFrame).rep(), right);
if (UNLIKELY(!value)) {
throwOutOfMemoryError(callFrame);
......@@ -1888,7 +1892,7 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, op_get_by_val)
} else if (isJSString(globalData, baseValue) && asString(baseValue)->canGetIndex(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_string));
result = asString(baseValue)->getIndex(stackFrame.globalData, i);
result = asString(baseValue)->getIndex(callFrame, i);
} else 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));
......@@ -1919,7 +1923,7 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, op_get_by_val_string)
if (LIKELY(subscript.isUInt32())) {
uint32_t i = subscript.asUInt32();
if (isJSString(globalData, baseValue) && asString(baseValue)->canGetIndex(i))
result = asString(baseValue)->getIndex(stackFrame.globalData, i);
result = asString(baseValue)->getIndex(callFrame, i);
else {
result = baseValue.get(callFrame, i);
if (!isJSString(globalData, baseValue))
......@@ -2422,20 +2426,20 @@ DEFINE_STUB_FUNCTION(int, op_eq)
if (cell1->isString()) {
if (src2.isInt32())
return static_cast<JSString*>(cell1)->value().toDouble() == src2.asInt32();
return static_cast<JSString*>(cell1)->value(stackFrame.callFrame).toDouble() == src2.asInt32();
if (src2.isDouble())
return static_cast<JSString*>(cell1)->value().toDouble() == src2.asDouble();
return static_cast<JSString*>(cell1)->value(stackFrame.callFrame).toDouble() == src2.asDouble();
if (src2.isTrue())
return static_cast<JSString*>(cell1)->value().toDouble() == 1.0;
return static_cast<JSString*>(cell1)->value(stackFrame.callFrame).toDouble() == 1.0;
if (src2.isFalse())
return static_cast<JSString*>(cell1)->value().toDouble() == 0.0;
return static_cast<JSString*>(cell1)->value(stackFrame.callFrame).toDouble() == 0.0;
JSCell* cell2 = asCell(src2);
if (cell2->isString())
return static_cast<JSString*>(cell1)->value() == static_cast<JSString*>(cell2)->value();
return static_cast<JSString*>(cell1)->value(stackFrame.callFrame) == static_cast<JSString*>(cell2)->value(stackFrame.callFrame);
src2 = asObject(cell2)->toPrimitive(stackFrame.callFrame);
CHECK_FOR_EXCEPTION();
......@@ -2458,7 +2462,7 @@ DEFINE_STUB_FUNCTION(int, op_eq_strings)
ASSERT(string1->isString());
ASSERT(string2->isString());
return string1->value() == string2->value();
return string1->value(stackFrame.callFrame) == string2->value(stackFrame.callFrame);
}
#else // USE(JSVALUE32_64)
......@@ -2756,7 +2760,7 @@ DEFINE_STUB_FUNCTION(int, has_property)
JSObject* base = stackFrame.args[0].jsObject();
JSString* property = stackFrame.args[1].jsString();
return base->hasProperty(stackFrame.callFrame, Identifier(stackFrame.callFrame, property->value()));
return base->hasProperty(stackFrame.callFrame, Identifier(stackFrame.callFrame, property->value(stackFrame.callFrame)));
}
DEFINE_STUB_FUNCTION(JSObject*, op_push_scope)
......@@ -2833,7 +2837,7 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, op_stricteq)
JSValue src1 = stackFrame.args[0].jsValue();
JSValue src2 = stackFrame.args[1].jsValue();
return JSValue::encode(jsBoolean(JSValue::strictEqual(src1, src2)));
return JSValue::encode(jsBoolean(JSValue::strictEqual(stackFrame.callFrame, src1, src2)));
}
DEFINE_STUB_FUNCTION(EncodedJSValue, op_to_primitive)
......@@ -2847,7 +2851,9 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, op_strcat)
{
STUB_INIT_STACK_FRAME(stackFrame);
return JSValue::encode(concatenateStrings(stackFrame.callFrame, &stackFrame.callFrame->registers()[stackFrame.args[0].int32()], stackFrame.args[1].int32()));
JSValue result = concatenateStrings(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)
......@@ -2857,7 +2863,7 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, op_nstricteq)
JSValue src1 = stackFrame.args[0].jsValue();
JSValue src2 = stackFrame.args[1].jsValue();
return JSValue::encode(jsBoolean(!JSValue::strictEqual(src1, src2)));
return JSValue::encode(jsBoolean(!JSValue::strictEqual(stackFrame.callFrame, src1, src2)));
}
DEFINE_STUB_FUNCTION(EncodedJSValue, op_to_jsnumber)
......@@ -2966,7 +2972,7 @@ DEFINE_STUB_FUNCTION(void*, op_switch_char)
void* result = codeBlock->characterSwitchJumpTable(tableIndex).ctiDefault.executableAddress();
if (scrutinee.isString()) {
UString::Rep* value = asString(scrutinee)->value().rep();
UString::Rep* value = asString(scrutinee)->value(callFrame).rep();
if (value->size() == 1)
result = codeBlock->characterSwitchJumpTable(tableIndex).ctiForValue(value->data()[0]).executableAddress();
}
......@@ -2986,7 +2992,7 @@ DEFINE_STUB_FUNCTION(void*, op_switch_string)
void* result = codeBlock->stringSwitchJumpTable(tableIndex).ctiDefault.executableAddress();
if (scrutinee.isString()) {
UString::Rep* value = asString(scrutinee)->value().rep();
UString::Rep* value = asString(scrutinee)->value(callFrame).rep();
result = codeBlock->stringSwitchJumpTable(tableIndex).ctiForValue(value).executableAddress();
}
......
......@@ -63,7 +63,7 @@ void ProfileGenerator::addParentForConsoleStart(ExecState* exec)
JSValue function;
exec->interpreter()->retrieveLastCaller(exec, lineNumber, sourceID, sourceURL, function);
m_currentNode = ProfileNode::create(Profiler::createCallIdentifier(&exec->globalData(), function ? function.toThisObject(exec) : 0, sourceURL, lineNumber), m_head.get(), m_head.get());
m_currentNode = ProfileNode::create(Profiler::createCallIdentifier(exec, function ? function.toThisObject(exec) : 0, sourceURL, lineNumber), m_head.get(), m_head.get());
m_head->insertNode(m_currentNode.get());
}
......
......@@ -46,7 +46,7 @@ static const char* GlobalCodeExecution = "(program)";
static const char* AnonymousFunction = "(anonymous function)";
static unsigned ProfilesUID = 0;
static CallIdentifier createCallIdentifierFromFunctionImp(JSGlobalData*, JSFunction*);
static CallIdentifier createCallIdentifierFromFunctionImp(ExecState*, JSFunction*);
Profiler* Profiler::s_sharedProfiler = 0;
Profiler* Profiler::s_sharedEnabledProfilerReference = 0;
......@@ -109,14 +109,14 @@ void Profiler::willExecute(ExecState* exec, JSValue function)
{
ASSERT(!m_currentProfiles.isEmpty());
dispatchFunctionToProfiles(m_currentProfiles, &ProfileGenerator::willExecute, createCallIdentifier(&exec->globalData(), function, "", 0), exec->lexicalGlobalObject()->profileGroup());
dispatchFunctionToProfiles(m_currentProfiles, &ProfileGenerator::willExecute, createCallIdentifier(exec, function, "", 0), exec->lexicalGlobalObject()->profileGroup());
}
void Profiler::willExecute(ExecState* exec, const UString& sourceURL, int startingLineNumber)
{
ASSERT(!m_currentProfiles.isEmpty());
CallIdentifier callIdentifier = createCallIdentifier(&exec->globalData(), JSValue(), sourceURL, startingLineNumber);
CallIdentifier callIdentifier = createCallIdentifier(exec, JSValue(), sourceURL, startingLineNumber);
dispatchFunctionToProfiles(m_currentProfiles, &ProfileGenerator::willExecute, callIdentifier, exec->lexicalGlobalObject()->profileGroup());
}
......@@ -125,17 +125,17 @@ void Profiler::didExecute(ExecState* exec, JSValue function)
{
ASSERT(!m_currentProfiles.isEmpty());
dispatchFunctionToProfiles(m_currentProfiles, &ProfileGenerator::didExecute, createCallIdentifier(&exec->globalData(), function, "", 0), exec->lexicalGlobalObject()->profileGroup());
dispatchFunctionToProfiles(m_currentProfiles, &ProfileGenerator::didExecute, createCallIdentifier(exec, function, "", 0), exec->lexicalGlobalObject()->profileGroup());
}
void Profiler::didExecute(ExecState* exec, const UString& sourceURL, int startingLineNumber)
{
ASSERT(!m_currentProfiles.isEmpty());
dispatchFunctionToProfiles(m_currentProfiles, &ProfileGenerator::didExecute, createCallIdentifier(&exec->globalData(), JSValue(), sourceURL, startingLineNumber), exec->lexicalGlobalObject()->profileGroup());
dispatchFunctionToProfiles(m_currentProfiles, &ProfileGenerator::didExecute, createCallIdentifier(exec, JSValue(), sourceURL, startingLineNumber), exec->lexicalGlobalObject()->profileGroup());
}
CallIdentifier Profiler::createCallIdentifier(JSGlobalData* globalData, JSValue functionValue, const UString& defaultSourceURL, int defaultLineNumber)
CallIdentifier Profiler::createCallIdentifier(ExecState* exec, JSValue functionValue, const UString& defaultSourceURL, int defaultLineNumber)
{
if (!functionValue)
return CallIdentifier(GlobalCodeExecution, defaultSourceURL, defaultLineNumber);
......@@ -144,17 +144,17 @@ CallIdentifier Profiler::createCallIdentifier(JSGlobalData* globalData, JSValue
if (asObject(functionValue)->inherits(&JSFunction::info)) {
JSFunction* function = asFunction(functionValue);
if (!function->executable()->isHostFunction())
return createCallIdentifierFromFunctionImp(globalData, function);
return createCallIdentifierFromFunctionImp(exec, function);
}
if (asObject(functionValue)->inherits(&InternalFunction::info))
return CallIdentifier(static_cast<InternalFunction*>(asObject(functionValue))->name(globalData), defaultSourceURL, defaultLineNumber);
return CallIdentifier(static_cast<InternalFunction*>(asObject(functionValue))->name(exec), defaultSourceURL, defaultLineNumber);
return CallIdentifier("(" + asObject(functionValue)->className() + " object)", defaultSourceURL, defaultLineNumber);
}
CallIdentifier createCallIdentifierFromFunctionImp(JSGlobalData* globalData, JSFunction* function)
CallIdentifier createCallIdentifierFromFunctionImp(ExecState* exec, JSFunction* function)
{
ASSERT(!function->isHostFunction());
const UString& name = function->calculatedDisplayName(globalData);
const UString& name = function->calculatedDisplayName(exec);
return CallIdentifier(name.isEmpty() ? AnonymousFunction : name, function->jsExecutable()->sourceURL(), function->jsExecutable()->lineNo());
}
......
......@@ -52,7 +52,7 @@ namespace JSC {
}
static Profiler* profiler();
static CallIdentifier createCallIdentifier(JSGlobalData*, JSValue, const UString& sourceURL, int lineNumber);
static CallIdentifier createCallIdentifier(ExecState* exec, JSValue, const UString& sourceURL, int lineNumber);
void startProfiling(ExecState*, const UString& title);
PassRefPtr<Profile> stopProfiling(ExecState*, const UString& title);
......
......@@ -1034,7 +1034,7 @@ JSValue JSC_HOST_CALL arrayProtoFuncIndexOf(ExecState* exec, JSObject*, JSValue
JSValue e = getProperty(exec, thisObj, index);
if (!e)
continue;
if (JSValue::strictEqual(searchElement, e))
if (JSValue::strictEqual(exec, searchElement, e))
return jsNumber(exec, index);
}
......@@ -1065,7 +1065,7 @@ JSValue JSC_HOST_CALL arrayProtoFuncLastIndexOf(ExecState* exec, JSObject*, JSVa
JSValue e = getProperty(exec, thisObj, index);
if (!e)
continue;
if (JSValue::strictEqual(searchElement, e))
if (JSValue::strictEqual(exec, searchElement, e))
return jsNumber(exec, index);
}
......
......@@ -84,7 +84,7 @@ JSObject* constructDate(ExecState* exec, const ArgList& args)
else {
JSValue primitive = args.at(0).toPrimitive(exec);
if (primitive.isString())
value = parseDate(exec, primitive.getString());
value = parseDate(exec, primitive.getString(exec));
else
value = primitive.toNumber(exec);
}
......
......@@ -90,13 +90,13 @@ JSValue JSC_HOST_CALL functionProtoFuncToString(ExecState* exec, JSObject*, JSVa
FunctionExecutable* executable = function->jsExecutable();
UString sourceString = executable->source().toString();
insertSemicolonIfNeeded(sourceString);
return jsString(exec, "function " + function->name(&exec->globalData()) + "(" + executable->paramString() + ") " + sourceString);
return jsString(exec, "function " + function->name(exec) + "(" + executable->paramString() + ") " + sourceString);
}
}
if (thisValue.inherits(&InternalFunction::info)) {
InternalFunction* function = asInternalFunction(thisValue);
return jsString(exec, "function " + function->name(&exec->globalData()) + "() {\n [native code]\n}");
return jsString(exec, "function " + function->name(exec) + "() {\n [native code]\n}");
}
return throwError(exec, TypeError);
......
......@@ -43,29 +43,29 @@ InternalFunction::InternalFunction(JSGlobalData* globalData, NonNullPassRefPtr<S
putDirect(globalData->propertyNames->name, jsString(globalData, name.ustring()), DontDelete | ReadOnly | DontEnum);
}
const UString& InternalFunction::name(JSGlobalData* globalData)
const UString& InternalFunction::name(ExecState* exec)
{
return asString(getDirect(globalData->propertyNames->name))->value();
return asString(getDirect(exec->globalData().propertyNames->name))->value(exec);
}
const UString InternalFunction::displayName(JSGlobalData* globalData)
const UString InternalFunction::displayName(ExecState* exec)
{
JSValue displayName = getDirect(globalData->propertyNames->displayName);
JSValue displayName = getDirect(exec->globalData().propertyNames->displayName);
if (displayName && isJSString(globalData, displayName))
return asString(displayName)->value();
if (displayName && isJSString(&exec->globalData(), displayName))
return asString(displayName)->value(exec);
return UString::null();
}
const UString InternalFunction::calculatedDisplayName(JSGlobalData* globalData)
const UString InternalFunction::calculatedDisplayName(ExecState* exec)
{
const UString explicitName = displayName(globalData);
const UString explicitName = displayName(exec);
if (!explicitName.isEmpty())
return explicitName;
return name(globalData);
return name(exec);
}
} // namespace JSC
......@@ -36,9 +36,9 @@ namespace JSC {
virtual const ClassInfo* classInfo() const;
static JS_EXPORTDATA const ClassInfo info;
const UString& name(JSGlobalData*);
const UString displayName(JSGlobalData*);
const UString calculatedDisplayName(JSGlobalData*);
const UString& name(ExecState*);
const UString displayName(ExecState*);
const UString calculatedDisplayName(ExecState*);
static PassRefPtr<Structure> createStructure(JSValue proto)
{
......
......@@ -86,17 +86,17 @@ bool JSCell::getUInt32(uint32_t&) const
return false;
}
bool JSCell::getString(UString&stringValue) const
bool JSCell::getString(ExecState* exec, UString&stringValue) const
{
if (!isString())
return false;
stringValue = static_cast<const JSString*>(this)->value();
stringValue = static_cast<const JSString*>(this)->value(exec);
return true;
}
UString JSCell::getString() const
UString JSCell::getString(ExecState* exec) const
{
return isString() ? static_cast<const JSString*>(this)->value() : UString();
return isString() ? static_cast<const JSString*>(this)->value(exec) : UString();
}
JSObject* JSCell::getObject()
......
......@@ -65,8 +65,8 @@ namespace JSC {
Structure* structure() const;
// Extracting the value.
bool getString(UString&) const;
UString getString() const; // null string if not a string
bool getString(ExecState* exec, UString&) const;
UString getString(ExecState* exec) const; // null string if not a string
JSObject* getObject(); // NULL if not an object
const JSObject* getObject() const; // NULL if not an object
......@@ -179,14 +179,14 @@ namespace JSC {
return isCell() && asCell()->isObject();
}
inline bool JSValue::getString(UString& s) const
inline bool JSValue::getString(ExecState* exec, UString& s) const
{
return isCell() && asCell()->getString(s);
return isCell() && asCell()->getString(exec, s);
}
inline UString JSValue::getString() const
inline UString JSValue::getString(ExecState* exec) const
{
return isCell() ? asCell()->getString() : UString();
return isCell() ? asCell()->getString(exec) : UString();
}
inline JSObject* JSValue::getObject() const
......
......@@ -172,7 +172,7 @@ static inline UString gap(ExecState* exec, JSValue space)
}
// If the space value is a string, use it as the gap string, otherwise use no gap string.
UString spaces = space.getString();
UString spaces = space.getString(exec);
if (spaces.size() > maxGapLength) {
spaces = spaces.substr(0, maxGapLength);
}
......@@ -229,7 +229,7 @@ Stringifier::Stringifier(ExecState* exec, JSValue replacer, JSValue space)
break;
UString propertyName;
if (name.getString(propertyName)) {
if (name.getString(exec, propertyName)) {
m_arrayReplacerPropertyNames.add(Identifier(exec, propertyName));
continue;
}
......@@ -407,7 +407,7 @@ Stringifier::StringifyResult Stringifier::appendStringifiedValue(StringBuilder&
}
UString stringValue;
if (value.getString(stringValue)) {