Index: src/x64/builtins-x64.cc |
diff --git a/src/x64/builtins-x64.cc b/src/x64/builtins-x64.cc |
index b1b99b473bde29b97f4bbe64ebad9d1e405bcdd1..2a01b0b24cdc4589a4b105be307a7ca73ba624bb 100644 |
--- a/src/x64/builtins-x64.cc |
+++ b/src/x64/builtins-x64.cc |
@@ -1477,14 +1477,20 @@ void Builtins::Generate_InternalArrayCode(MacroAssembler* masm) { |
// Run the native code for the InternalArray function called as a normal |
// function. |
- ArrayNativeCode(masm, &generic_array_code); |
- |
- // Jump to the generic array code in case the specialized code cannot handle |
- // the construction. |
- __ bind(&generic_array_code); |
- Handle<Code> array_code = |
- masm->isolate()->builtins()->InternalArrayCodeGeneric(); |
- __ Jump(array_code, RelocInfo::CODE_TARGET); |
+ if (FLAG_optimize_constructed_arrays) { |
+ // tail call a stub |
+ InternalArrayConstructorStub stub(masm->isolate()); |
+ __ TailCallStub(&stub); |
+ } else { |
+ ArrayNativeCode(masm, &generic_array_code); |
+ |
+ // Jump to the generic array code in case the specialized code cannot handle |
+ // the construction. |
+ __ bind(&generic_array_code); |
+ Handle<Code> array_code = |
+ masm->isolate()->builtins()->InternalArrayCodeGeneric(); |
+ __ Jump(array_code, RelocInfo::CODE_TARGET); |
+ } |
} |
@@ -1511,14 +1517,24 @@ void Builtins::Generate_ArrayCode(MacroAssembler* masm) { |
} |
// Run the native code for the Array function called as a normal function. |
- ArrayNativeCode(masm, &generic_array_code); |
- |
- // Jump to the generic array code in case the specialized code cannot handle |
- // the construction. |
- __ bind(&generic_array_code); |
- Handle<Code> array_code = |
- masm->isolate()->builtins()->ArrayCodeGeneric(); |
- __ Jump(array_code, RelocInfo::CODE_TARGET); |
+ if (FLAG_optimize_constructed_arrays) { |
+ // tail call a stub |
+ Handle<Object> undefined_sentinel( |
+ masm->isolate()->heap()->undefined_value(), |
+ masm->isolate()); |
+ __ Move(rbx, undefined_sentinel); |
+ ArrayConstructorStub stub(masm->isolate()); |
+ __ TailCallStub(&stub); |
+ } else { |
+ ArrayNativeCode(masm, &generic_array_code); |
+ |
+ // Jump to the generic array code in case the specialized code cannot handle |
+ // the construction. |
+ __ bind(&generic_array_code); |
+ Handle<Code> array_code = |
+ masm->isolate()->builtins()->ArrayCodeGeneric(); |
+ __ Jump(array_code, RelocInfo::CODE_TARGET); |
+ } |
} |