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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 // Try to allocate the object without transitioning into C code. If any of | 142 // Try to allocate the object without transitioning into C code. If any of |
143 // the preconditions is not met, the code bails out to the runtime call. | 143 // the preconditions is not met, the code bails out to the runtime call. |
144 Label rt_call, allocated; | 144 Label rt_call, allocated; |
145 if (FLAG_inline_new) { | 145 if (FLAG_inline_new) { |
146 ExternalReference debug_step_in_fp = | 146 ExternalReference debug_step_in_fp = |
147 ExternalReference::debug_step_in_fp_address(masm->isolate()); | 147 ExternalReference::debug_step_in_fp_address(masm->isolate()); |
148 __ Move(kScratchRegister, debug_step_in_fp); | 148 __ Move(kScratchRegister, debug_step_in_fp); |
149 __ cmpp(Operand(kScratchRegister, 0), Immediate(0)); | 149 __ cmpp(Operand(kScratchRegister, 0), Immediate(0)); |
150 __ j(not_equal, &rt_call); | 150 __ j(not_equal, &rt_call); |
151 | 151 |
152 // Fall back to runtime if the original constructor and function differ. | 152 // Verify that the original constructor is a JSFunction. |
153 __ cmpp(rdx, rdi); | 153 __ CmpObjectType(rdx, JS_FUNCTION_TYPE, rbx); |
154 __ j(not_equal, &rt_call); | 154 __ j(not_equal, &rt_call); |
155 | 155 |
156 // Verified that the constructor is a JSFunction. | |
157 // Load the initial map and verify that it is in fact a map. | 156 // Load the initial map and verify that it is in fact a map. |
158 // rdi: constructor | 157 // rdx: original constructor |
159 __ movp(rax, FieldOperand(rdi, JSFunction::kPrototypeOrInitialMapOffset)); | 158 __ movp(rax, FieldOperand(rdx, JSFunction::kPrototypeOrInitialMapOffset)); |
160 // Will both indicate a NULL and a Smi | 159 // Will both indicate a NULL and a Smi |
161 DCHECK(kSmiTag == 0); | 160 DCHECK(kSmiTag == 0); |
162 __ JumpIfSmi(rax, &rt_call); | 161 __ JumpIfSmi(rax, &rt_call); |
163 // rdi: constructor | 162 // rdi: constructor |
164 // rax: initial map (if proven valid below) | 163 // rax: initial map (if proven valid below) |
165 __ CmpObjectType(rax, MAP_TYPE, rbx); | 164 __ CmpObjectType(rax, MAP_TYPE, rbx); |
166 __ j(not_equal, &rt_call); | 165 __ j(not_equal, &rt_call); |
167 | 166 |
| 167 // Fall back to runtime if the expected base constructor and base |
| 168 // constructor differ. |
| 169 __ cmpp(rdi, FieldOperand(rax, Map::kConstructorOrBackPointerOffset)); |
| 170 __ j(not_equal, &rt_call); |
| 171 |
168 // Check that the constructor is not constructing a JSFunction (see | 172 // Check that the constructor is not constructing a JSFunction (see |
169 // comments in Runtime_NewObject in runtime.cc). In which case the | 173 // comments in Runtime_NewObject in runtime.cc). In which case the |
170 // initial map's instance type would be JS_FUNCTION_TYPE. | 174 // initial map's instance type would be JS_FUNCTION_TYPE. |
171 // rdi: constructor | 175 // rdi: constructor |
172 // rax: initial map | 176 // rax: initial map |
173 __ CmpInstanceType(rax, JS_FUNCTION_TYPE); | 177 __ CmpInstanceType(rax, JS_FUNCTION_TYPE); |
174 __ j(equal, &rt_call); | 178 __ j(equal, &rt_call); |
175 if (!is_api_function) { | 179 if (!is_api_function) { |
176 Label allocate; | 180 Label allocate; |
177 // The code below relies on these assumptions. | 181 // The code below relies on these assumptions. |
178 STATIC_ASSERT(Map::Counter::kShift + Map::Counter::kSize == 32); | 182 STATIC_ASSERT(Map::Counter::kShift + Map::Counter::kSize == 32); |
179 // Check if slack tracking is enabled. | 183 // Check if slack tracking is enabled. |
180 __ movl(rsi, FieldOperand(rax, Map::kBitField3Offset)); | 184 __ movl(rsi, FieldOperand(rax, Map::kBitField3Offset)); |
181 __ shrl(rsi, Immediate(Map::Counter::kShift)); | 185 __ shrl(rsi, Immediate(Map::Counter::kShift)); |
182 __ cmpl(rsi, Immediate(Map::kSlackTrackingCounterEnd)); | 186 __ cmpl(rsi, Immediate(Map::kSlackTrackingCounterEnd)); |
183 __ j(less, &allocate); | 187 __ j(less, &allocate); |
184 // Decrease generous allocation count. | 188 // Decrease generous allocation count. |
185 __ subl(FieldOperand(rax, Map::kBitField3Offset), | 189 __ subl(FieldOperand(rax, Map::kBitField3Offset), |
186 Immediate(1 << Map::Counter::kShift)); | 190 Immediate(1 << Map::Counter::kShift)); |
187 | 191 |
188 __ cmpl(rsi, Immediate(Map::kSlackTrackingCounterEnd)); | 192 __ cmpl(rsi, Immediate(Map::kSlackTrackingCounterEnd)); |
189 __ j(not_equal, &allocate); | 193 __ j(not_equal, &allocate); |
190 | 194 |
191 __ Push(rax); | 195 __ Push(rax); |
192 __ Push(rdx); | 196 __ Push(rdx); |
193 __ Push(rdi); | 197 __ Push(rdi); |
194 | 198 |
195 __ Push(rdi); // constructor | 199 __ Push(rax); // initial map |
196 __ CallRuntime(Runtime::kFinalizeInstanceSize, 1); | 200 __ CallRuntime(Runtime::kFinalizeInstanceSize, 1); |
197 | 201 |
198 __ Pop(rdi); | 202 __ Pop(rdi); |
199 __ Pop(rdx); | 203 __ Pop(rdx); |
200 __ Pop(rax); | 204 __ Pop(rax); |
201 __ movl(rsi, Immediate(Map::kSlackTrackingCounterEnd - 1)); | 205 __ movl(rsi, Immediate(Map::kSlackTrackingCounterEnd - 1)); |
202 | 206 |
203 __ bind(&allocate); | 207 __ bind(&allocate); |
204 } | 208 } |
205 | 209 |
(...skipping 1809 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2015 __ ret(0); | 2019 __ ret(0); |
2016 } | 2020 } |
2017 | 2021 |
2018 | 2022 |
2019 #undef __ | 2023 #undef __ |
2020 | 2024 |
2021 } // namespace internal | 2025 } // namespace internal |
2022 } // namespace v8 | 2026 } // namespace v8 |
2023 | 2027 |
2024 #endif // V8_TARGET_ARCH_X64 | 2028 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |