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

Side by Side Diff: runtime/vm/intermediate_language_arm.cc

Issue 2799373002: Pass a second type argument vector to all type instantiation calls in the VM. (Closed)
Patch Set: Created 3 years, 8 months 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
OLDNEW
1 1
2 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 2 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
3 // for details. All rights reserved. Use of this source code is governed by a 3 // for details. All rights reserved. Use of this source code is governed by a
4 // BSD-style license that can be found in the LICENSE file. 4 // BSD-style license that can be found in the LICENSE file.
5 5
6 #include "vm/globals.h" // Needed here to get TARGET_ARCH_ARM. 6 #include "vm/globals.h" // Needed here to get TARGET_ARCH_ARM.
7 #if defined(TARGET_ARCH_ARM) 7 #if defined(TARGET_ARCH_ARM)
8 8
9 #include "vm/intermediate_language.h" 9 #include "vm/intermediate_language.h"
10 10
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 default: 341 default:
342 UNREACHABLE(); 342 UNREACHABLE();
343 break; 343 break;
344 } 344 }
345 } 345 }
346 } 346 }
347 347
348 348
349 LocationSummary* AssertAssignableInstr::MakeLocationSummary(Zone* zone, 349 LocationSummary* AssertAssignableInstr::MakeLocationSummary(Zone* zone,
350 bool opt) const { 350 bool opt) const {
351 const intptr_t kNumInputs = 2; 351 const intptr_t kNumInputs = 3;
352 const intptr_t kNumTemps = 0; 352 const intptr_t kNumTemps = 0;
353 LocationSummary* summary = new (zone) 353 LocationSummary* summary = new (zone)
354 LocationSummary(zone, kNumInputs, kNumTemps, LocationSummary::kCall); 354 LocationSummary(zone, kNumInputs, kNumTemps, LocationSummary::kCall);
355 summary->set_in(0, Location::RegisterLocation(R0)); // Value. 355 summary->set_in(0, Location::RegisterLocation(R0)); // Value.
356 summary->set_in(1, Location::RegisterLocation(R1)); // Type arguments. 356 summary->set_in(1, Location::RegisterLocation(R1)); // Instant. type args.
357 summary->set_in(2, Location::RegisterLocation(R2)); // Function type args.
357 summary->set_out(0, Location::RegisterLocation(R0)); 358 summary->set_out(0, Location::RegisterLocation(R0));
358 return summary; 359 return summary;
359 } 360 }
360 361
361 362
362 LocationSummary* AssertBooleanInstr::MakeLocationSummary(Zone* zone, 363 LocationSummary* AssertBooleanInstr::MakeLocationSummary(Zone* zone,
363 bool opt) const { 364 bool opt) const {
364 const intptr_t kNumInputs = 1; 365 const intptr_t kNumInputs = 1;
365 const intptr_t kNumTemps = 0; 366 const intptr_t kNumTemps = 0;
366 LocationSummary* locs = new (zone) 367 LocationSummary* locs = new (zone)
(...skipping 1990 matching lines...) Expand 10 before | Expand all | Expand 10 after
2357 value, CanValueBeSmi()); 2358 value, CanValueBeSmi());
2358 } else { 2359 } else {
2359 __ StoreIntoObjectNoBarrier( 2360 __ StoreIntoObjectNoBarrier(
2360 temp, FieldAddress(temp, Field::static_value_offset()), value); 2361 temp, FieldAddress(temp, Field::static_value_offset()), value);
2361 } 2362 }
2362 } 2363 }
2363 2364
2364 2365
2365 LocationSummary* InstanceOfInstr::MakeLocationSummary(Zone* zone, 2366 LocationSummary* InstanceOfInstr::MakeLocationSummary(Zone* zone,
2366 bool opt) const { 2367 bool opt) const {
2367 const intptr_t kNumInputs = 2; 2368 const intptr_t kNumInputs = 3;
2368 const intptr_t kNumTemps = 0; 2369 const intptr_t kNumTemps = 0;
2369 LocationSummary* summary = new (zone) 2370 LocationSummary* summary = new (zone)
2370 LocationSummary(zone, kNumInputs, kNumTemps, LocationSummary::kCall); 2371 LocationSummary(zone, kNumInputs, kNumTemps, LocationSummary::kCall);
2371 summary->set_in(0, Location::RegisterLocation(R0)); 2372 summary->set_in(0, Location::RegisterLocation(R0)); // Instance.
2372 summary->set_in(1, Location::RegisterLocation(R1)); 2373 summary->set_in(1, Location::RegisterLocation(R1)); // Instant. type args.
2374 summary->set_in(2, Location::RegisterLocation(R2)); // Function type args.
2373 summary->set_out(0, Location::RegisterLocation(R0)); 2375 summary->set_out(0, Location::RegisterLocation(R0));
2374 return summary; 2376 return summary;
2375 } 2377 }
2376 2378
2377 2379
2378 void InstanceOfInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 2380 void InstanceOfInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
2379 ASSERT(locs()->in(0).reg() == R0); // Value. 2381 ASSERT(locs()->in(0).reg() == R0); // Value.
2380 ASSERT(locs()->in(1).reg() == R1); // Instantiator type arguments. 2382 ASSERT(locs()->in(1).reg() == R1); // Instantiator type arguments.
2383 ASSERT(locs()->in(2).reg() == R2); // Function type arguments.
2381 2384
2382 compiler->GenerateInstanceOf(token_pos(), deopt_id(), type(), locs()); 2385 compiler->GenerateInstanceOf(token_pos(), deopt_id(), type(), locs());
2383 ASSERT(locs()->out(0).reg() == R0); 2386 ASSERT(locs()->out(0).reg() == R0);
2384 } 2387 }
2385 2388
2386 2389
2387 LocationSummary* CreateArrayInstr::MakeLocationSummary(Zone* zone, 2390 LocationSummary* CreateArrayInstr::MakeLocationSummary(Zone* zone,
2388 bool opt) const { 2391 bool opt) const {
2389 const intptr_t kNumInputs = 2; 2392 const intptr_t kNumInputs = 2;
2390 const intptr_t kNumTemps = 0; 2393 const intptr_t kNumTemps = 0;
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
2615 2618
2616 __ Bind(&load_pointer); 2619 __ Bind(&load_pointer);
2617 } 2620 }
2618 __ LoadFieldFromOffset(kWord, result_reg, instance_reg, offset_in_bytes()); 2621 __ LoadFieldFromOffset(kWord, result_reg, instance_reg, offset_in_bytes());
2619 __ Bind(&done); 2622 __ Bind(&done);
2620 } 2623 }
2621 2624
2622 2625
2623 LocationSummary* InstantiateTypeInstr::MakeLocationSummary(Zone* zone, 2626 LocationSummary* InstantiateTypeInstr::MakeLocationSummary(Zone* zone,
2624 bool opt) const { 2627 bool opt) const {
2625 const intptr_t kNumInputs = 1; 2628 const intptr_t kNumInputs = 2;
2626 const intptr_t kNumTemps = 0; 2629 const intptr_t kNumTemps = 0;
2627 LocationSummary* locs = new (zone) 2630 LocationSummary* locs = new (zone)
2628 LocationSummary(zone, kNumInputs, kNumTemps, LocationSummary::kCall); 2631 LocationSummary(zone, kNumInputs, kNumTemps, LocationSummary::kCall);
2629 locs->set_in(0, Location::RegisterLocation(R0)); 2632 locs->set_in(0, Location::RegisterLocation(R0)); // Instant. type args.
2633 locs->set_in(1, Location::RegisterLocation(R1)); // Function type args.
2630 locs->set_out(0, Location::RegisterLocation(R0)); 2634 locs->set_out(0, Location::RegisterLocation(R0));
2631 return locs; 2635 return locs;
2632 } 2636 }
2633 2637
2634 2638
2635 void InstantiateTypeInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 2639 void InstantiateTypeInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
2636 const Register instantiator_reg = locs()->in(0).reg(); 2640 const Register instantiator_type_args_reg = locs()->in(0).reg();
2641 const Register function_type_args_reg = locs()->in(1).reg();
2637 const Register result_reg = locs()->out(0).reg(); 2642 const Register result_reg = locs()->out(0).reg();
2638 2643
2639 // 'instantiator_reg' is the instantiator TypeArguments object (or null). 2644 // 'instantiator_type_args_reg' is a TypeArguments object (or null).
2645 // 'function_type_args_reg' is a TypeArguments object (or null).
2640 // A runtime call to instantiate the type is required. 2646 // A runtime call to instantiate the type is required.
2641 __ PushObject(Object::null_object()); // Make room for the result. 2647 __ PushObject(Object::null_object()); // Make room for the result.
2642 __ PushObject(type()); 2648 __ PushObject(type());
2643 __ Push(instantiator_reg); // Push instantiator type arguments. 2649 __ Push(instantiator_type_args_reg); // Push instantiator type arguments.
zra 2017/04/07 17:36:31 PushList
regis 2017/04/11 04:23:08 Added: // TODO(regis): Renumber registers and us
2650 __ Push(function_type_args_reg); // Push function type arguments.
2644 compiler->GenerateRuntimeCall(token_pos(), deopt_id(), 2651 compiler->GenerateRuntimeCall(token_pos(), deopt_id(),
2645 kInstantiateTypeRuntimeEntry, 2, locs()); 2652 kInstantiateTypeRuntimeEntry, 3, locs());
2646 __ Drop(2); // Drop instantiator and uninstantiated type. 2653 __ Drop(3); // Drop 2 type argument vectors and uninstantiated type.
2647 __ Pop(result_reg); // Pop instantiated type. 2654 __ Pop(result_reg); // Pop instantiated type.
2648 ASSERT(instantiator_reg == result_reg); 2655 ASSERT(instantiator_type_args_reg == result_reg);
2649 } 2656 }
2650 2657
2651 2658
2652 LocationSummary* InstantiateTypeArgumentsInstr::MakeLocationSummary( 2659 LocationSummary* InstantiateTypeArgumentsInstr::MakeLocationSummary(
2653 Zone* zone, 2660 Zone* zone,
2654 bool opt) const { 2661 bool opt) const {
2655 const intptr_t kNumInputs = 1; 2662 const intptr_t kNumInputs = 2;
2656 const intptr_t kNumTemps = 0; 2663 const intptr_t kNumTemps = 0;
2657 LocationSummary* locs = new (zone) 2664 LocationSummary* locs = new (zone)
2658 LocationSummary(zone, kNumInputs, kNumTemps, LocationSummary::kCall); 2665 LocationSummary(zone, kNumInputs, kNumTemps, LocationSummary::kCall);
2659 locs->set_in(0, Location::RegisterLocation(R0)); 2666 locs->set_in(0, Location::RegisterLocation(R0)); // Instant. type args.
2667 locs->set_in(1, Location::RegisterLocation(R1)); // Function type args.
2660 locs->set_out(0, Location::RegisterLocation(R0)); 2668 locs->set_out(0, Location::RegisterLocation(R0));
2661 return locs; 2669 return locs;
2662 } 2670 }
2663 2671
2664 2672
2665 void InstantiateTypeArgumentsInstr::EmitNativeCode( 2673 void InstantiateTypeArgumentsInstr::EmitNativeCode(
2666 FlowGraphCompiler* compiler) { 2674 FlowGraphCompiler* compiler) {
2667 const Register instantiator_reg = locs()->in(0).reg(); 2675 const Register instantiator_type_args_reg = locs()->in(0).reg();
2676 const Register function_type_args_reg = locs()->in(1).reg();
2668 const Register result_reg = locs()->out(0).reg(); 2677 const Register result_reg = locs()->out(0).reg();
2669 ASSERT(instantiator_reg == R0); 2678 ASSERT(instantiator_type_args_reg == R0);
2670 ASSERT(instantiator_reg == result_reg); 2679 ASSERT(function_type_args_reg == R1);
2680 ASSERT(instantiator_type_args_reg == result_reg);
2671 2681
2672 // 'instantiator_reg' is the instantiator TypeArguments object (or null). 2682 // 'instantiator_type_args_reg' is a TypeArguments object (or null).
2683 // 'function_type_args_reg' is a TypeArguments object (or null).
2673 ASSERT(!type_arguments().IsUninstantiatedIdentity() && 2684 ASSERT(!type_arguments().IsUninstantiatedIdentity() &&
2674 !type_arguments().CanShareInstantiatorTypeArguments( 2685 !type_arguments().CanShareInstantiatorTypeArguments(
2675 instantiator_class())); 2686 instantiator_class()));
2676 // If the instantiator is null and if the type argument vector 2687 // If both the instantiator and function type arguments are null and if the
2677 // instantiated from null becomes a vector of dynamic, then use null as 2688 // type argument vector instantiated from null becomes a vector of dynamic,
2678 // the type arguments. 2689 // then use null as the type arguments.
2679 Label type_arguments_instantiated; 2690 Label type_arguments_instantiated;
2680 const intptr_t len = type_arguments().Length(); 2691 const intptr_t len = type_arguments().Length();
2681 if (type_arguments().IsRawInstantiatedRaw(len)) { 2692 if (type_arguments().IsRawInstantiatedRaw(len)) {
2682 __ LoadObject(IP, Object::null_object()); 2693 __ LoadObject(IP, Object::null_object());
2683 __ cmp(instantiator_reg, Operand(IP)); 2694 __ cmp(instantiator_type_args_reg, Operand(IP));
2695 __ cmp(function_type_args_reg, Operand(IP), EQ);
2684 __ b(&type_arguments_instantiated, EQ); 2696 __ b(&type_arguments_instantiated, EQ);
2685 } 2697 }
2686 2698
2687 __ LoadObject(R2, type_arguments()); 2699 // Lookup cache before calling runtime.
2688 __ ldr(R2, FieldAddress(R2, TypeArguments::instantiations_offset())); 2700 // TODO(regis): Consider moving this into a shared stub to reduce
2689 __ AddImmediate(R2, Array::data_offset() - kHeapObjectTag); 2701 // generated code size.
2702 __ LoadObject(R3, type_arguments());
2703 __ ldr(R3, FieldAddress(R3, TypeArguments::instantiations_offset()));
2704 __ AddImmediate(R3, Array::data_offset() - kHeapObjectTag);
2690 // The instantiations cache is initialized with Object::zero_array() and is 2705 // The instantiations cache is initialized with Object::zero_array() and is
2691 // therefore guaranteed to contain kNoInstantiator. No length check needed. 2706 // therefore guaranteed to contain kNoInstantiator. No length check needed.
2692 Label loop, found, slow_case; 2707 Label loop, next, found, slow_case;
2693 __ Bind(&loop); 2708 __ Bind(&loop);
2694 __ ldr(R1, Address(R2, 0 * kWordSize)); // Cached instantiator. 2709 __ ldr(R2, Address(R3, 0 * kWordSize)); // Cached instantiator type args.
2695 __ cmp(R1, Operand(R0)); 2710 __ cmp(R2, Operand(instantiator_type_args_reg));
2711 __ b(&next, NE);
2712 __ ldr(IP, Address(R3, 1 * kWordSize)); // Cached function type args.
2713 __ cmp(IP, Operand(function_type_args_reg));
2696 __ b(&found, EQ); 2714 __ b(&found, EQ);
2697 __ AddImmediate(R2, 2 * kWordSize); 2715 __ Bind(&next);
2698 __ CompareImmediate(R1, Smi::RawValue(StubCode::kNoInstantiator)); 2716 __ AddImmediate(R3, StubCode::kInstantiationSizeInWords * kWordSize);
2717 __ CompareImmediate(R2, Smi::RawValue(StubCode::kNoInstantiator));
2699 __ b(&loop, NE); 2718 __ b(&loop, NE);
2700 __ b(&slow_case); 2719 __ b(&slow_case);
2701 __ Bind(&found); 2720 __ Bind(&found);
2702 __ ldr(R0, Address(R2, 1 * kWordSize)); // Cached instantiated args. 2721 __ ldr(result_reg, Address(R3, 2 * kWordSize)); // Cached instantiated args.
2703 __ b(&type_arguments_instantiated); 2722 __ b(&type_arguments_instantiated);
2704 2723
2705 __ Bind(&slow_case); 2724 __ Bind(&slow_case);
2706 // Instantiate non-null type arguments. 2725 // Instantiate non-null type arguments.
2707 // A runtime call to instantiate the type arguments is required. 2726 // A runtime call to instantiate the type arguments is required.
2708 __ PushObject(Object::null_object()); // Make room for the result. 2727 __ PushObject(Object::null_object()); // Make room for the result.
2709 __ PushObject(type_arguments()); 2728 __ PushObject(type_arguments());
2710 __ Push(instantiator_reg); // Push instantiator type arguments. 2729 __ Push(instantiator_type_args_reg); // Push instantiator type arguments.
zra 2017/04/07 17:36:31 PushList
regis 2017/04/11 04:23:08 Added: // TODO(regis): Renumber registers and us
2730 __ Push(function_type_args_reg); // Push function type arguments.
2711 compiler->GenerateRuntimeCall(token_pos(), deopt_id(), 2731 compiler->GenerateRuntimeCall(token_pos(), deopt_id(),
2712 kInstantiateTypeArgumentsRuntimeEntry, 2, 2732 kInstantiateTypeArgumentsRuntimeEntry, 3,
2713 locs()); 2733 locs());
2714 __ Drop(2); // Drop instantiator and uninstantiated type arguments. 2734 __ Drop(3); // Drop 2 type argument vectors and uninstantiated args.
2715 __ Pop(result_reg); // Pop instantiated type arguments. 2735 __ Pop(result_reg); // Pop instantiated type arguments.
2716 __ Bind(&type_arguments_instantiated); 2736 __ Bind(&type_arguments_instantiated);
2717 } 2737 }
2718 2738
2719 2739
2720 LocationSummary* AllocateUninitializedContextInstr::MakeLocationSummary( 2740 LocationSummary* AllocateUninitializedContextInstr::MakeLocationSummary(
2721 Zone* zone, 2741 Zone* zone,
2722 bool opt) const { 2742 bool opt) const {
2723 ASSERT(opt); 2743 ASSERT(opt);
2724 const intptr_t kNumInputs = 0; 2744 const intptr_t kNumInputs = 0;
(...skipping 4537 matching lines...) Expand 10 before | Expand all | Expand 10 after
7262 compiler->GenerateRuntimeCall(TokenPosition::kNoSource, deopt_id(), 7282 compiler->GenerateRuntimeCall(TokenPosition::kNoSource, deopt_id(),
7263 kGrowRegExpStackRuntimeEntry, 1, locs()); 7283 kGrowRegExpStackRuntimeEntry, 1, locs());
7264 __ Drop(1); 7284 __ Drop(1);
7265 __ Pop(result); 7285 __ Pop(result);
7266 } 7286 }
7267 7287
7268 7288
7269 } // namespace dart 7289 } // namespace dart
7270 7290
7271 #endif // defined TARGET_ARCH_ARM 7291 #endif // defined TARGET_ARCH_ARM
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698