Commit 8707b362 authored by sgjesse@chromium.org's avatar sgjesse@chromium.org

Fix GC bug

The patching of the receiver added in r3616 was not GC-safe and could leave a failure object in place of the receiver if allocation of the wrapper JS object failed.
Review URL: http://codereview.chromium.org/546068

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3633 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent ef0743ab
...@@ -718,6 +718,11 @@ Handle<JSFunction> Factory::NewFunction(Handle<String> name, ...@@ -718,6 +718,11 @@ Handle<JSFunction> Factory::NewFunction(Handle<String> name,
} }
Handle<Object> Factory::ToObject(Handle<Object> object) {
CALL_HEAP_FUNCTION(object->ToObject(), Object);
}
Handle<Object> Factory::ToObject(Handle<Object> object, Handle<Object> Factory::ToObject(Handle<Object> object,
Handle<Context> global_context) { Handle<Context> global_context) {
CALL_HEAP_FUNCTION(object->ToObject(*global_context), Object); CALL_HEAP_FUNCTION(object->ToObject(*global_context), Object);
......
...@@ -229,6 +229,7 @@ class Factory : public AllStatic { ...@@ -229,6 +229,7 @@ class Factory : public AllStatic {
static Handle<Code> CopyCode(Handle<Code> code); static Handle<Code> CopyCode(Handle<Code> code);
static Handle<Object> ToObject(Handle<Object> object);
static Handle<Object> ToObject(Handle<Object> object, static Handle<Object> ToObject(Handle<Object> object,
Handle<Context> global_context); Handle<Context> global_context);
......
...@@ -378,7 +378,7 @@ Object* CallIC::TryCallAsFunction(Object* object) { ...@@ -378,7 +378,7 @@ Object* CallIC::TryCallAsFunction(Object* object) {
return *delegate; return *delegate;
} }
void CallIC::ReceiverToObject(Object* object) { void CallIC::ReceiverToObject(Handle<Object> object) {
HandleScope scope; HandleScope scope;
Handle<Object> receiver(object); Handle<Object> receiver(object);
...@@ -387,7 +387,7 @@ void CallIC::ReceiverToObject(Object* object) { ...@@ -387,7 +387,7 @@ void CallIC::ReceiverToObject(Object* object) {
StackFrameLocator locator; StackFrameLocator locator;
JavaScriptFrame* frame = locator.FindJavaScriptFrame(0); JavaScriptFrame* frame = locator.FindJavaScriptFrame(0);
int index = frame->ComputeExpressionsCount() - (argc + 1); int index = frame->ComputeExpressionsCount() - (argc + 1);
frame->SetExpression(index, object->ToObject()); frame->SetExpression(index, *Factory::ToObject(object));
} }
...@@ -401,7 +401,7 @@ Object* CallIC::LoadFunction(State state, ...@@ -401,7 +401,7 @@ Object* CallIC::LoadFunction(State state,
} }
if (object->IsString() || object->IsNumber() || object->IsBoolean()) { if (object->IsString() || object->IsNumber() || object->IsBoolean()) {
ReceiverToObject(*object); ReceiverToObject(object);
} }
// Check if the name is trivially convertible to an index and get // Check if the name is trivially convertible to an index and get
......
...@@ -209,7 +209,7 @@ class CallIC: public IC { ...@@ -209,7 +209,7 @@ class CallIC: public IC {
// Otherwise, it returns the undefined value. // Otherwise, it returns the undefined value.
Object* TryCallAsFunction(Object* object); Object* TryCallAsFunction(Object* object);
void ReceiverToObject(Object* object); void ReceiverToObject(Handle<Object> object);
static void Clear(Address address, Code* target); static void Clear(Address address, Code* target);
friend class IC; friend class IC;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment