Index: src/ic.cc |
=================================================================== |
--- src/ic.cc (revision 3613) |
+++ src/ic.cc (working copy) |
@@ -378,7 +378,19 @@ |
return *delegate; |
} |
+void CallIC::ReceiverToObject(Object* object) { |
+ HandleScope scope; |
+ Handle<Object> receiver(object); |
+ // Change the receiver to the result of calling ToObject on it. |
+ const int argc = this->target()->arguments_count(); |
+ StackFrameLocator locator; |
+ JavaScriptFrame* frame = locator.FindJavaScriptFrame(0); |
+ int index = frame->ComputeExpressionsCount() - (argc + 1); |
+ frame->SetExpression(index, object->ToObject()); |
+} |
+ |
+ |
Object* CallIC::LoadFunction(State state, |
Handle<Object> object, |
Handle<String> name) { |
@@ -388,6 +400,10 @@ |
return TypeError("non_object_property_call", object, name); |
} |
+ if (object->IsString() || object->IsNumber() || object->IsBoolean()) { |
+ ReceiverToObject(*object); |
+ } |
+ |
// Check if the name is trivially convertible to an index and get |
// the element if so. |
uint32_t index; |