Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(913)

Side by Side Diff: src/arm64/builtins-arm64.cc

Issue 1413003008: Support fast-path allocation for subclass constructors with correctly initialized initial maps. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/arm/builtins-arm.cc ('k') | src/ia32/builtins-ia32.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 // Try to allocate the object without transitioning into C code. If any of 383 // Try to allocate the object without transitioning into C code. If any of
384 // the preconditions is not met, the code bails out to the runtime call. 384 // the preconditions is not met, the code bails out to the runtime call.
385 Label rt_call, allocated; 385 Label rt_call, allocated;
386 if (FLAG_inline_new) { 386 if (FLAG_inline_new) {
387 ExternalReference debug_step_in_fp = 387 ExternalReference debug_step_in_fp =
388 ExternalReference::debug_step_in_fp_address(isolate); 388 ExternalReference::debug_step_in_fp_address(isolate);
389 __ Mov(x2, Operand(debug_step_in_fp)); 389 __ Mov(x2, Operand(debug_step_in_fp));
390 __ Ldr(x2, MemOperand(x2)); 390 __ Ldr(x2, MemOperand(x2));
391 __ Cbnz(x2, &rt_call); 391 __ Cbnz(x2, &rt_call);
392 392
393 // Fall back to runtime if the original constructor and function differ. 393 // Verify that the original constructor is a JSFunction.
394 __ Cmp(constructor, original_constructor); 394 __ JumpIfNotObjectType(original_constructor, x10, x11, JS_FUNCTION_TYPE,
395 __ B(ne, &rt_call); 395 &rt_call);
396 396
397 // Load the initial map and verify that it is in fact a map. 397 // Load the initial map and verify that it is in fact a map.
398 Register init_map = x2; 398 Register init_map = x2;
399 __ Ldr(init_map, 399 __ Ldr(init_map,
400 FieldMemOperand(constructor, 400 FieldMemOperand(original_constructor,
401 JSFunction::kPrototypeOrInitialMapOffset)); 401 JSFunction::kPrototypeOrInitialMapOffset));
402 __ JumpIfSmi(init_map, &rt_call); 402 __ JumpIfSmi(init_map, &rt_call);
403 __ JumpIfNotObjectType(init_map, x10, x11, MAP_TYPE, &rt_call); 403 __ JumpIfNotObjectType(init_map, x10, x11, MAP_TYPE, &rt_call);
404 404
405 // Fall back to runtime if the expected base constructor and base
406 // constructor differ.
407 __ Ldr(x10,
408 FieldMemOperand(init_map, Map::kConstructorOrBackPointerOffset));
409 __ Cmp(constructor, x10);
410 __ B(ne, &rt_call);
411
405 // Check that the constructor is not constructing a JSFunction (see 412 // Check that the constructor is not constructing a JSFunction (see
406 // comments in Runtime_NewObject in runtime.cc). In which case the initial 413 // comments in Runtime_NewObject in runtime.cc). In which case the initial
407 // map's instance type would be JS_FUNCTION_TYPE. 414 // map's instance type would be JS_FUNCTION_TYPE.
408 __ CompareInstanceType(init_map, x10, JS_FUNCTION_TYPE); 415 __ CompareInstanceType(init_map, x10, JS_FUNCTION_TYPE);
409 __ B(eq, &rt_call); 416 __ B(eq, &rt_call);
410 417
411 Register constructon_count = x14; 418 Register constructon_count = x14;
412 if (!is_api_function) { 419 if (!is_api_function) {
413 Label allocate; 420 Label allocate;
414 MemOperand bit_field3 = 421 MemOperand bit_field3 =
415 FieldMemOperand(init_map, Map::kBitField3Offset); 422 FieldMemOperand(init_map, Map::kBitField3Offset);
416 // Check if slack tracking is enabled. 423 // Check if slack tracking is enabled.
417 __ Ldr(x4, bit_field3); 424 __ Ldr(x4, bit_field3);
418 __ DecodeField<Map::Counter>(constructon_count, x4); 425 __ DecodeField<Map::Counter>(constructon_count, x4);
419 __ Cmp(constructon_count, Operand(Map::kSlackTrackingCounterEnd)); 426 __ Cmp(constructon_count, Operand(Map::kSlackTrackingCounterEnd));
420 __ B(lt, &allocate); 427 __ B(lt, &allocate);
421 // Decrease generous allocation count. 428 // Decrease generous allocation count.
422 __ Subs(x4, x4, Operand(1 << Map::Counter::kShift)); 429 __ Subs(x4, x4, Operand(1 << Map::Counter::kShift));
423 __ Str(x4, bit_field3); 430 __ Str(x4, bit_field3);
424 __ Cmp(constructon_count, Operand(Map::kSlackTrackingCounterEnd)); 431 __ Cmp(constructon_count, Operand(Map::kSlackTrackingCounterEnd));
425 __ B(ne, &allocate); 432 __ B(ne, &allocate);
426 433
427 // Push the constructor and map to the stack, and the constructor again 434 // Push the constructor and map to the stack, and the map again
428 // as argument to the runtime call. 435 // as argument to the runtime call.
429 __ Push(constructor, init_map, constructor); 436 __ Push(constructor, init_map, init_map);
430 __ CallRuntime(Runtime::kFinalizeInstanceSize, 1); 437 __ CallRuntime(Runtime::kFinalizeInstanceSize, 1);
431 __ Pop(init_map, constructor); 438 __ Pop(init_map, constructor);
432 __ Mov(constructon_count, Operand(Map::kSlackTrackingCounterEnd - 1)); 439 __ Mov(constructon_count, Operand(Map::kSlackTrackingCounterEnd - 1));
433 __ Bind(&allocate); 440 __ Bind(&allocate);
434 } 441 }
435 442
436 // Now allocate the JSObject on the heap. 443 // Now allocate the JSObject on the heap.
437 Label rt_call_reload_new_target; 444 Label rt_call_reload_new_target;
438 Register obj_size = x3; 445 Register obj_size = x3;
439 Register new_obj = x4; 446 Register new_obj = x4;
(...skipping 1585 matching lines...) Expand 10 before | Expand all | Expand 10 after
2025 } 2032 }
2026 } 2033 }
2027 2034
2028 2035
2029 #undef __ 2036 #undef __
2030 2037
2031 } // namespace internal 2038 } // namespace internal
2032 } // namespace v8 2039 } // namespace v8
2033 2040
2034 #endif // V8_TARGET_ARCH_ARM 2041 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « src/arm/builtins-arm.cc ('k') | src/ia32/builtins-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698