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

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

Issue 1191813002: Port "Add flag to disable lazy compilation of invocation dispatchers." (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 6 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
« no previous file with comments | « runtime/vm/stack_frame_test.cc ('k') | runtime/vm/stub_code_arm64.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 (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/globals.h" 5 #include "vm/globals.h"
6 #if defined(TARGET_ARCH_ARM) 6 #if defined(TARGET_ARCH_ARM)
7 7
8 #include "vm/assembler.h" 8 #include "vm/assembler.h"
9 #include "vm/code_generator.h" 9 #include "vm/code_generator.h"
10 #include "vm/cpu.h" 10 #include "vm/cpu.h"
(...skipping 10 matching lines...) Expand all
21 #define __ assembler-> 21 #define __ assembler->
22 22
23 namespace dart { 23 namespace dart {
24 24
25 DEFINE_FLAG(bool, inline_alloc, true, "Inline allocation of objects."); 25 DEFINE_FLAG(bool, inline_alloc, true, "Inline allocation of objects.");
26 DEFINE_FLAG(bool, use_slow_path, false, 26 DEFINE_FLAG(bool, use_slow_path, false,
27 "Set to true for debugging & verifying the slow paths."); 27 "Set to true for debugging & verifying the slow paths.");
28 DECLARE_FLAG(bool, trace_optimized_ic_calls); 28 DECLARE_FLAG(bool, trace_optimized_ic_calls);
29 DECLARE_FLAG(int, optimization_counter_threshold); 29 DECLARE_FLAG(int, optimization_counter_threshold);
30 DECLARE_FLAG(bool, support_debugger); 30 DECLARE_FLAG(bool, support_debugger);
31 DECLARE_FLAG(bool, lazy_dispatchers);
31 32
32 // Input parameters: 33 // Input parameters:
33 // LR : return address. 34 // LR : return address.
34 // SP : address of last argument in argument array. 35 // SP : address of last argument in argument array.
35 // SP + 4*R4 - 4 : address of first argument in argument array. 36 // SP + 4*R4 - 4 : address of first argument in argument array.
36 // SP + 4*R4 : address of return value. 37 // SP + 4*R4 : address of return value.
37 // R5 : address of the runtime function to call. 38 // R5 : address of the runtime function to call.
38 // R4 : number of arguments to the call. 39 // R4 : number of arguments to the call.
39 void StubCode::GenerateCallToRuntimeStub(Assembler* assembler) { 40 void StubCode::GenerateCallToRuntimeStub(Assembler* assembler) {
40 const intptr_t thread_offset = NativeArguments::thread_offset(); 41 const intptr_t thread_offset = NativeArguments::thread_offset();
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 __ AddImmediate(LR, -CallPattern::LengthInBytes()); 548 __ AddImmediate(LR, -CallPattern::LengthInBytes());
548 GenerateDeoptimizationSequence(assembler, true); // Preserve R0. 549 GenerateDeoptimizationSequence(assembler, true); // Preserve R0.
549 } 550 }
550 551
551 552
552 void StubCode::GenerateDeoptimizeStub(Assembler* assembler) { 553 void StubCode::GenerateDeoptimizeStub(Assembler* assembler) {
553 GenerateDeoptimizationSequence(assembler, false); // Don't preserve R0. 554 GenerateDeoptimizationSequence(assembler, false); // Don't preserve R0.
554 } 555 }
555 556
556 557
558 static void GenerateDispatcherCode(Assembler* assembler,
559 Label* call_target_function) {
560 __ Comment("NoSuchMethodDispatch");
561 // When lazily generated invocation dispatchers are disabled, the
562 // miss-handler may return null.
563 __ CompareObject(R0, Object::null_object());
564 __ b(call_target_function, NE);
565 __ EnterStubFrame();
566 // Load the receiver.
567 __ ldr(R2, FieldAddress(R4, ArgumentsDescriptor::count_offset()));
568 __ add(IP, FP, Operand(R2, LSL, 1)); // R2 is Smi.
569 __ ldr(R6, Address(IP, kParamEndSlotFromFp * kWordSize));
570 __ PushObject(Object::null_object());
571 __ Push(R6);
572 __ Push(R5);
573 __ Push(R4);
574 // R2: Smi-tagged arguments array length.
575 PushArgumentsArray(assembler);
576 const intptr_t kNumArgs = 4;
577 __ CallRuntime(kInvokeNoSuchMethodDispatcherRuntimeEntry, kNumArgs);
578 __ Drop(4);
579 __ Pop(R0); // Return value.
580 __ LeaveStubFrame();
581 __ Ret();
582 }
583
584
557 void StubCode::GenerateMegamorphicMissStub(Assembler* assembler) { 585 void StubCode::GenerateMegamorphicMissStub(Assembler* assembler) {
558 __ EnterStubFrame(); 586 __ EnterStubFrame();
559 587
560 // Load the receiver. 588 // Load the receiver.
561 __ ldr(R2, FieldAddress(R4, ArgumentsDescriptor::count_offset())); 589 __ ldr(R2, FieldAddress(R4, ArgumentsDescriptor::count_offset()));
562 __ add(IP, FP, Operand(R2, LSL, 1)); // R2 is Smi. 590 __ add(IP, FP, Operand(R2, LSL, 1)); // R2 is Smi.
563 __ ldr(R6, Address(IP, kParamEndSlotFromFp * kWordSize)); 591 __ ldr(R6, Address(IP, kParamEndSlotFromFp * kWordSize));
564 592
565 // Preserve IC data and arguments descriptor. 593 // Preserve IC data and arguments descriptor.
566 __ PushList((1 << R4) | (1 << R5)); 594 __ PushList((1 << R4) | (1 << R5));
567 595
568 // Push space for the return value. 596 // Push space for the return value.
569 // Push the receiver. 597 // Push the receiver.
570 // Push IC data object. 598 // Push IC data object.
571 // Push arguments descriptor array. 599 // Push arguments descriptor array.
572 __ LoadImmediate(IP, reinterpret_cast<intptr_t>(Object::null())); 600 __ LoadImmediate(IP, reinterpret_cast<intptr_t>(Object::null()));
573 __ PushList((1 << R4) | (1 << R5) | (1 << R6) | (1 << IP)); 601 __ PushList((1 << R4) | (1 << R5) | (1 << R6) | (1 << IP));
574 __ CallRuntime(kMegamorphicCacheMissHandlerRuntimeEntry, 3); 602 __ CallRuntime(kMegamorphicCacheMissHandlerRuntimeEntry, 3);
575 // Remove arguments. 603 // Remove arguments.
576 __ Drop(3); 604 __ Drop(3);
577 __ Pop(R0); // Get result into R0 (target function). 605 __ Pop(R0); // Get result into R0 (target function).
578 606
579 // Restore IC data and arguments descriptor. 607 // Restore IC data and arguments descriptor.
580 __ PopList((1 << R4) | (1 << R5)); 608 __ PopList((1 << R4) | (1 << R5));
581 609
582 __ LeaveStubFrame(); 610 __ LeaveStubFrame();
583 611
612 if (!FLAG_lazy_dispatchers) {
613 Label call_target_function;
614 GenerateDispatcherCode(assembler, &call_target_function);
615 __ Bind(&call_target_function);
616 }
617
584 // Tail-call to target function. 618 // Tail-call to target function.
585 __ ldr(R2, FieldAddress(R0, Function::instructions_offset())); 619 __ ldr(R2, FieldAddress(R0, Function::instructions_offset()));
586 __ AddImmediate(R2, Instructions::HeaderSize() - kHeapObjectTag); 620 __ AddImmediate(R2, Instructions::HeaderSize() - kHeapObjectTag);
587 __ bx(R2); 621 __ bx(R2);
588 } 622 }
589 623
590 624
591 // Called for inline allocation of arrays. 625 // Called for inline allocation of arrays.
592 // Input parameters: 626 // Input parameters:
593 // LR: return address. 627 // LR: return address.
(...skipping 845 matching lines...) Expand 10 before | Expand all | Expand 10 after
1439 // Pass IC data object. 1473 // Pass IC data object.
1440 __ Push(R5); 1474 __ Push(R5);
1441 __ CallRuntime(handle_ic_miss, num_args + 1); 1475 __ CallRuntime(handle_ic_miss, num_args + 1);
1442 // Remove the call arguments pushed earlier, including the IC data object. 1476 // Remove the call arguments pushed earlier, including the IC data object.
1443 __ Drop(num_args + 1); 1477 __ Drop(num_args + 1);
1444 // Pop returned function object into R0. 1478 // Pop returned function object into R0.
1445 // Restore arguments descriptor array and IC data array. 1479 // Restore arguments descriptor array and IC data array.
1446 __ PopList((1 << R0) | (1 << R4) | (1 << R5)); 1480 __ PopList((1 << R0) | (1 << R4) | (1 << R5));
1447 __ LeaveStubFrame(); 1481 __ LeaveStubFrame();
1448 Label call_target_function; 1482 Label call_target_function;
1449 __ b(&call_target_function); 1483 if (!FLAG_lazy_dispatchers) {
1484 GenerateDispatcherCode(assembler, &call_target_function);
1485 } else {
1486 __ b(&call_target_function);
1487 }
1450 1488
1451 __ Bind(&found); 1489 __ Bind(&found);
1452 // R6: pointer to an IC data check group. 1490 // R6: pointer to an IC data check group.
1453 const intptr_t target_offset = ICData::TargetIndexFor(num_args) * kWordSize; 1491 const intptr_t target_offset = ICData::TargetIndexFor(num_args) * kWordSize;
1454 const intptr_t count_offset = ICData::CountIndexFor(num_args) * kWordSize; 1492 const intptr_t count_offset = ICData::CountIndexFor(num_args) * kWordSize;
1455 __ LoadFromOffset(kWord, R0, R6, target_offset); 1493 __ LoadFromOffset(kWord, R0, R6, target_offset);
1456 1494
1457 if (FLAG_optimization_counter_threshold >= 0) { 1495 if (FLAG_optimization_counter_threshold >= 0) {
1458 __ Comment("Update caller's counter"); 1496 __ Comment("Update caller's counter");
1459 __ LoadFromOffset(kWord, R1, R6, count_offset); 1497 __ LoadFromOffset(kWord, R1, R6, count_offset);
(...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after
2084 // Result: 2122 // Result:
2085 // R1: entry point. 2123 // R1: entry point.
2086 void StubCode::GenerateMegamorphicLookupStub(Assembler* assembler) { 2124 void StubCode::GenerateMegamorphicLookupStub(Assembler* assembler) {
2087 EmitMegamorphicLookup(assembler, R0, R1, R1); 2125 EmitMegamorphicLookup(assembler, R0, R1, R1);
2088 __ Ret(); 2126 __ Ret();
2089 } 2127 }
2090 2128
2091 } // namespace dart 2129 } // namespace dart
2092 2130
2093 #endif // defined TARGET_ARCH_ARM 2131 #endif // defined TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « runtime/vm/stack_frame_test.cc ('k') | runtime/vm/stub_code_arm64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698