Index: src/hydrogen.cc |
diff --git a/src/hydrogen.cc b/src/hydrogen.cc |
index 57220e0de1e5cf77641235343b45aba12249cb8a..db0b5ea331b8867c4ce4c53719bd7baa4a912db9 100644 |
--- a/src/hydrogen.cc |
+++ b/src/hydrogen.cc |
@@ -1043,14 +1043,19 @@ HValue* HGraphBuilder::BuildCheckHeapObject(HValue* obj) { |
} |
-HValue* HGraphBuilder::BuildCheckMap(HValue* obj, |
- Handle<Map> map) { |
+HValue* HGraphBuilder::BuildCheckMap(HValue* obj, Handle<Map> map) { |
HCheckMaps* check = HCheckMaps::New(obj, map, zone()); |
AddInstruction(check); |
return check; |
} |
+HValue* HGraphBuilder::BuildWrapReceiver(HValue* object, HValue* function) { |
+ if (object->type().IsJSObject()) return object; |
+ return Add<HWrapReceiver>(object, function); |
+} |
+ |
+ |
HValue* HGraphBuilder::BuildCheckForCapacityGrow(HValue* object, |
HValue* elements, |
ElementsKind kind, |
@@ -6881,7 +6886,7 @@ bool HOptimizedGraphBuilder::TryCallApply(Call* expr) { |
if (function_state()->outer() == NULL) { |
HInstruction* elements = Add<HArgumentsElements>(false); |
HInstruction* length = Add<HArgumentsLength>(elements); |
- HValue* wrapped_receiver = Add<HWrapReceiver>(receiver, function); |
+ HValue* wrapped_receiver = BuildWrapReceiver(receiver, function); |
HInstruction* result = |
new(zone()) HApplyArguments(function, |
wrapped_receiver, |
@@ -6898,7 +6903,7 @@ bool HOptimizedGraphBuilder::TryCallApply(Call* expr) { |
HArgumentsObject* args = function_state()->entry()->arguments_object(); |
const ZoneList<HValue*>* arguments_values = args->arguments_values(); |
int arguments_count = arguments_values->length(); |
- PushAndAdd(new(zone()) HWrapReceiver(receiver, function)); |
+ Push(BuildWrapReceiver(receiver, function)); |
for (int i = 1; i < arguments_count; i++) { |
Push(arguments_values->at(i)); |
} |