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

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

Issue 2226893002: Optimize AOT's switchable calls for the monomorphic case. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: sync Created 4 years, 4 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/object_service.cc ('k') | runtime/vm/precompiler.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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 "platform/globals.h" 5 #include "platform/globals.h"
6 6
7 #include "vm/assembler.h" 7 #include "vm/assembler.h"
8 #include "vm/class_finalizer.h" 8 #include "vm/class_finalizer.h"
9 #include "vm/dart_api_impl.h" 9 #include "vm/dart_api_impl.h"
10 #include "vm/dart_entry.h" 10 #include "vm/dart_entry.h"
(...skipping 2695 matching lines...) Expand 10 before | Expand all | Expand 10 after
2706 2706
2707 // Test for Code and Instruction object creation. 2707 // Test for Code and Instruction object creation.
2708 VM_TEST_CASE(Code) { 2708 VM_TEST_CASE(Code) {
2709 extern void GenerateIncrement(Assembler* assembler); 2709 extern void GenerateIncrement(Assembler* assembler);
2710 Assembler _assembler_; 2710 Assembler _assembler_;
2711 GenerateIncrement(&_assembler_); 2711 GenerateIncrement(&_assembler_);
2712 const Function& function = Function::Handle(CreateFunction("Test_Code")); 2712 const Function& function = Function::Handle(CreateFunction("Test_Code"));
2713 Code& code = Code::Handle(Code::FinalizeCode(function, &_assembler_)); 2713 Code& code = Code::Handle(Code::FinalizeCode(function, &_assembler_));
2714 function.AttachCode(code); 2714 function.AttachCode(code);
2715 const Instructions& instructions = Instructions::Handle(code.instructions()); 2715 const Instructions& instructions = Instructions::Handle(code.instructions());
2716 uword entry_point = instructions.EntryPoint(); 2716 uword entry_point = instructions.UncheckedEntryPoint();
2717 EXPECT_EQ(instructions.raw(), Instructions::FromEntryPoint(entry_point)); 2717 EXPECT_EQ(instructions.raw(),
2718 Instructions::FromUncheckedEntryPoint(entry_point));
2718 const Object& result = Object::Handle( 2719 const Object& result = Object::Handle(
2719 DartEntry::InvokeFunction(function, Array::empty_array())); 2720 DartEntry::InvokeFunction(function, Array::empty_array()));
2720 EXPECT_EQ(1, Smi::Cast(result).Value()); 2721 EXPECT_EQ(1, Smi::Cast(result).Value());
2721 } 2722 }
2722 2723
2723 2724
2724 // Test for immutability of generated instructions. The test crashes with a 2725 // Test for immutability of generated instructions. The test crashes with a
2725 // segmentation fault when writing into it. 2726 // segmentation fault when writing into it.
2726 VM_TEST_CASE(CodeImmutability) { 2727 VM_TEST_CASE(CodeImmutability) {
2727 extern void GenerateIncrement(Assembler* assembler); 2728 extern void GenerateIncrement(Assembler* assembler);
2728 Assembler _assembler_; 2729 Assembler _assembler_;
2729 GenerateIncrement(&_assembler_); 2730 GenerateIncrement(&_assembler_);
2730 const Function& function = Function::Handle(CreateFunction("Test_Code")); 2731 const Function& function = Function::Handle(CreateFunction("Test_Code"));
2731 Code& code = Code::Handle(Code::FinalizeCode(function, &_assembler_)); 2732 Code& code = Code::Handle(Code::FinalizeCode(function, &_assembler_));
2732 function.AttachCode(code); 2733 function.AttachCode(code);
2733 Instructions& instructions = Instructions::Handle(code.instructions()); 2734 Instructions& instructions = Instructions::Handle(code.instructions());
2734 uword entry_point = instructions.EntryPoint(); 2735 uword entry_point = instructions.UncheckedEntryPoint();
2735 EXPECT_EQ(instructions.raw(), Instructions::FromEntryPoint(entry_point)); 2736 EXPECT_EQ(instructions.raw(),
2737 Instructions::FromUncheckedEntryPoint(entry_point));
2736 // Try writing into the generated code, expected to crash. 2738 // Try writing into the generated code, expected to crash.
2737 *(reinterpret_cast<char*>(entry_point) + 1) = 1; 2739 *(reinterpret_cast<char*>(entry_point) + 1) = 1;
2738 if (!FLAG_write_protect_code) { 2740 if (!FLAG_write_protect_code) {
2739 // Since this test is expected to crash, crash if write protection of code 2741 // Since this test is expected to crash, crash if write protection of code
2740 // is switched off. 2742 // is switched off.
2741 // TODO(regis, fschneider): Should this be FATAL() instead? 2743 // TODO(regis, fschneider): Should this be FATAL() instead?
2742 OS::DebugBreak(); 2744 OS::DebugBreak();
2743 } 2745 }
2744 } 2746 }
2745 2747
(...skipping 1973 matching lines...) Expand 10 before | Expand all | Expand 10 after
4719 String& test = String::Handle(); 4721 String& test = String::Handle();
4720 String& result = String::Handle(); 4722 String& result = String::Handle();
4721 for (size_t i = 0; i < ARRAY_SIZE(tests); i++) { 4723 for (size_t i = 0; i < ARRAY_SIZE(tests); i++) {
4722 test = String::New(tests[i].in); 4724 test = String::New(tests[i].in);
4723 result = String::ScrubName(test); 4725 result = String::ScrubName(test);
4724 EXPECT_STREQ(tests[i].out, result.ToCString()); 4726 EXPECT_STREQ(tests[i].out, result.ToCString());
4725 } 4727 }
4726 } 4728 }
4727 4729
4728 } // namespace dart 4730 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object_service.cc ('k') | runtime/vm/precompiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698