OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #if V8_TARGET_ARCH_X64 | 5 #if V8_TARGET_ARCH_X64 |
6 | 6 |
7 #include "src/code-factory.h" | 7 #include "src/code-factory.h" |
8 #include "src/codegen.h" | 8 #include "src/codegen.h" |
9 #include "src/deoptimizer.h" | 9 #include "src/deoptimizer.h" |
10 #include "src/full-codegen/full-codegen.h" | 10 #include "src/full-codegen/full-codegen.h" |
(...skipping 2076 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2087 // Check if string has a cached array index. | 2087 // Check if string has a cached array index. |
2088 Label runtime; | 2088 Label runtime; |
2089 __ testl(FieldOperand(rax, String::kHashFieldOffset), | 2089 __ testl(FieldOperand(rax, String::kHashFieldOffset), |
2090 Immediate(String::kContainsCachedArrayIndexMask)); | 2090 Immediate(String::kContainsCachedArrayIndexMask)); |
2091 __ j(not_zero, &runtime, Label::kNear); | 2091 __ j(not_zero, &runtime, Label::kNear); |
2092 __ movl(rax, FieldOperand(rax, String::kHashFieldOffset)); | 2092 __ movl(rax, FieldOperand(rax, String::kHashFieldOffset)); |
2093 __ IndexFromHash(rax, rax); | 2093 __ IndexFromHash(rax, rax); |
2094 __ Ret(); | 2094 __ Ret(); |
2095 | 2095 |
2096 __ bind(&runtime); | 2096 __ bind(&runtime); |
2097 __ PopReturnAddressTo(rcx); // Pop return address. | 2097 { |
2098 __ Push(rax); // Push argument. | 2098 FrameScope frame(masm, StackFrame::INTERNAL); |
2099 __ PushReturnAddressFrom(rcx); // Push return address. | 2099 // Push argument. |
2100 __ TailCallRuntime(Runtime::kStringToNumber); | 2100 __ Push(rax); |
| 2101 // We cannot use a tail call here because this builtin can also be called |
| 2102 // from wasm. |
| 2103 __ CallRuntime(Runtime::kStringToNumber); |
| 2104 } |
| 2105 __ Ret(); |
2101 } | 2106 } |
2102 | 2107 |
2103 // static | 2108 // static |
2104 void Builtins::Generate_ToNumber(MacroAssembler* masm) { | 2109 void Builtins::Generate_ToNumber(MacroAssembler* masm) { |
2105 // The ToNumber stub takes one argument in rax. | 2110 // The ToNumber stub takes one argument in rax. |
2106 Label not_smi; | 2111 Label not_smi; |
2107 __ JumpIfNotSmi(rax, ¬_smi, Label::kNear); | 2112 __ JumpIfNotSmi(rax, ¬_smi, Label::kNear); |
2108 __ Ret(); | 2113 __ Ret(); |
2109 __ bind(¬_smi); | 2114 __ bind(¬_smi); |
2110 | 2115 |
(...skipping 21 matching lines...) Expand all Loading... |
2132 __ Jump(masm->isolate()->builtins()->StringToNumber(), | 2137 __ Jump(masm->isolate()->builtins()->StringToNumber(), |
2133 RelocInfo::CODE_TARGET); | 2138 RelocInfo::CODE_TARGET); |
2134 __ bind(¬_string); | 2139 __ bind(¬_string); |
2135 | 2140 |
2136 Label not_oddball; | 2141 Label not_oddball; |
2137 __ CmpInstanceType(rdi, ODDBALL_TYPE); | 2142 __ CmpInstanceType(rdi, ODDBALL_TYPE); |
2138 __ j(not_equal, ¬_oddball, Label::kNear); | 2143 __ j(not_equal, ¬_oddball, Label::kNear); |
2139 __ movp(rax, FieldOperand(rax, Oddball::kToNumberOffset)); | 2144 __ movp(rax, FieldOperand(rax, Oddball::kToNumberOffset)); |
2140 __ Ret(); | 2145 __ Ret(); |
2141 __ bind(¬_oddball); | 2146 __ bind(¬_oddball); |
2142 | 2147 { |
2143 __ PopReturnAddressTo(rcx); // Pop return address. | 2148 FrameScope frame(masm, StackFrame::INTERNAL); |
2144 __ Push(rax); // Push argument. | 2149 // Push argument. |
2145 __ PushReturnAddressFrom(rcx); // Push return address. | 2150 __ Push(rax); |
2146 __ TailCallRuntime(Runtime::kToNumber); | 2151 // We cannot use a tail call here because this builtin can also be called |
| 2152 // from wasm. |
| 2153 __ CallRuntime(Runtime::kToNumber); |
| 2154 } |
| 2155 __ Ret(); |
2147 } | 2156 } |
2148 | 2157 |
2149 void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) { | 2158 void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) { |
2150 // ----------- S t a t e ------------- | 2159 // ----------- S t a t e ------------- |
2151 // -- rax : actual number of arguments | 2160 // -- rax : actual number of arguments |
2152 // -- rbx : expected number of arguments | 2161 // -- rbx : expected number of arguments |
2153 // -- rdx : new target (passed through to callee) | 2162 // -- rdx : new target (passed through to callee) |
2154 // -- rdi : function (passed through to callee) | 2163 // -- rdi : function (passed through to callee) |
2155 // ----------------------------------- | 2164 // ----------------------------------- |
2156 | 2165 |
(...skipping 874 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3031 __ ret(0); | 3040 __ ret(0); |
3032 } | 3041 } |
3033 | 3042 |
3034 | 3043 |
3035 #undef __ | 3044 #undef __ |
3036 | 3045 |
3037 } // namespace internal | 3046 } // namespace internal |
3038 } // namespace v8 | 3047 } // namespace v8 |
3039 | 3048 |
3040 #endif // V8_TARGET_ARCH_X64 | 3049 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |