OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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_ARM64 | 5 #if V8_TARGET_ARCH_ARM64 |
6 | 6 |
7 #include "src/arm64/frames-arm64.h" | 7 #include "src/arm64/frames-arm64.h" |
8 #include "src/codegen.h" | 8 #include "src/codegen.h" |
9 #include "src/debug/debug.h" | 9 #include "src/debug/debug.h" |
10 #include "src/deoptimizer.h" | 10 #include "src/deoptimizer.h" |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 ToStringStub stub(masm->isolate()); | 240 ToStringStub stub(masm->isolate()); |
241 __ Push(x1, x3); | 241 __ Push(x1, x3); |
242 __ Move(x0, x2); | 242 __ Move(x0, x2); |
243 __ CallStub(&stub); | 243 __ CallStub(&stub); |
244 __ Move(x2, x0); | 244 __ Move(x2, x0); |
245 __ Pop(x1, x3); | 245 __ Pop(x1, x3); |
246 } | 246 } |
247 __ Bind(&done_convert); | 247 __ Bind(&done_convert); |
248 } | 248 } |
249 | 249 |
250 // 3. Allocate a JSValue wrapper for the string. | 250 // 3. Check if original constructor and constructor differ. |
| 251 Label new_object; |
| 252 __ Cmp(x1, x3); |
| 253 __ B(ne, &new_object); |
| 254 |
| 255 // 4. Allocate a JSValue wrapper for the string. |
251 { | 256 { |
252 // ----------- S t a t e ------------- | 257 // ----------- S t a t e ------------- |
253 // -- x2 : the first argument | 258 // -- x2 : the first argument |
254 // -- x1 : constructor function | 259 // -- x1 : constructor function |
255 // -- x3 : original constructor | 260 // -- x3 : original constructor |
256 // -- lr : return address | 261 // -- lr : return address |
257 // ----------------------------------- | 262 // ----------------------------------- |
258 | 263 __ Allocate(JSValue::kSize, x0, x4, x5, &new_object, TAG_OBJECT); |
259 Label allocate, done_allocate, rt_call; | |
260 | |
261 // Fall back to runtime if the original constructor and function differ. | |
262 __ cmp(x1, x3); | |
263 __ B(ne, &rt_call); | |
264 | |
265 __ Allocate(JSValue::kSize, x0, x3, x4, &allocate, TAG_OBJECT); | |
266 __ Bind(&done_allocate); | |
267 | 264 |
268 // Initialize the JSValue in eax. | 265 // Initialize the JSValue in eax. |
269 __ LoadGlobalFunctionInitialMap(x1, x3, x4); | 266 __ LoadGlobalFunctionInitialMap(x1, x3, x4); |
270 __ Str(x3, FieldMemOperand(x0, HeapObject::kMapOffset)); | 267 __ Str(x3, FieldMemOperand(x0, HeapObject::kMapOffset)); |
271 __ LoadRoot(x3, Heap::kEmptyFixedArrayRootIndex); | 268 __ LoadRoot(x3, Heap::kEmptyFixedArrayRootIndex); |
272 __ Str(x3, FieldMemOperand(x0, JSObject::kPropertiesOffset)); | 269 __ Str(x3, FieldMemOperand(x0, JSObject::kPropertiesOffset)); |
273 __ Str(x3, FieldMemOperand(x0, JSObject::kElementsOffset)); | 270 __ Str(x3, FieldMemOperand(x0, JSObject::kElementsOffset)); |
274 __ Str(x2, FieldMemOperand(x0, JSValue::kValueOffset)); | 271 __ Str(x2, FieldMemOperand(x0, JSValue::kValueOffset)); |
275 STATIC_ASSERT(JSValue::kSize == 4 * kPointerSize); | 272 STATIC_ASSERT(JSValue::kSize == 4 * kPointerSize); |
276 __ Ret(); | 273 __ Ret(); |
| 274 } |
277 | 275 |
278 // Fallback to the runtime to allocate in new space. | 276 // 5. Fallback to the runtime to create new object. |
279 __ Bind(&allocate); | 277 __ bind(&new_object); |
280 { | 278 { |
281 FrameScope scope(masm, StackFrame::INTERNAL); | 279 FrameScope scope(masm, StackFrame::INTERNAL); |
282 __ Push(x1, x2); | 280 __ Push(x2, x1); // first argument, constructor |
283 __ Push(Smi::FromInt(JSValue::kSize)); | 281 __ Push(x1, x3); // constructor, original constructor |
284 __ CallRuntime(Runtime::kAllocateInNewSpace, 1); | 282 __ CallRuntime(Runtime::kNewObject, 2); |
285 __ Pop(x2, x1); | 283 __ Pop(x1, x2); |
286 } | |
287 __ B(&done_allocate); | |
288 | |
289 // Fallback to the runtime to create new object. | |
290 __ bind(&rt_call); | |
291 { | |
292 FrameScope scope(masm, StackFrame::INTERNAL); | |
293 __ Push(x1, x2, x1, x3); // constructor function, original constructor | |
294 __ CallRuntime(Runtime::kNewObject, 2); | |
295 __ Pop(x2, x1); | |
296 } | |
297 __ Str(x2, FieldMemOperand(x0, JSValue::kValueOffset)); | |
298 __ Ret(); | |
299 } | 284 } |
| 285 __ Str(x2, FieldMemOperand(x0, JSValue::kValueOffset)); |
| 286 __ Ret(); |
300 } | 287 } |
301 | 288 |
302 | 289 |
303 static void CallRuntimePassFunction(MacroAssembler* masm, | 290 static void CallRuntimePassFunction(MacroAssembler* masm, |
304 Runtime::FunctionId function_id) { | 291 Runtime::FunctionId function_id) { |
305 FrameScope scope(masm, StackFrame::INTERNAL); | 292 FrameScope scope(masm, StackFrame::INTERNAL); |
306 // - Push a copy of the function onto the stack. | 293 // - Push a copy of the function onto the stack. |
307 // - Push another copy as a parameter to the runtime call. | 294 // - Push another copy as a parameter to the runtime call. |
308 __ Push(x1, x1); | 295 __ Push(x1, x1); |
309 | 296 |
(...skipping 1722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2032 } | 2019 } |
2033 } | 2020 } |
2034 | 2021 |
2035 | 2022 |
2036 #undef __ | 2023 #undef __ |
2037 | 2024 |
2038 } // namespace internal | 2025 } // namespace internal |
2039 } // namespace v8 | 2026 } // namespace v8 |
2040 | 2027 |
2041 #endif // V8_TARGET_ARCH_ARM | 2028 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |