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

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

Issue 2463083002: Remove default monomorphic check code from functions and stubs that do not need it. (Closed)
Patch Set: address comment Created 4 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
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 2703 matching lines...) Expand 10 before | Expand all | Expand 10 after
2714 2714
2715 // Test for Code and Instruction object creation. 2715 // Test for Code and Instruction object creation.
2716 VM_TEST_CASE(Code) { 2716 VM_TEST_CASE(Code) {
2717 extern void GenerateIncrement(Assembler* assembler); 2717 extern void GenerateIncrement(Assembler* assembler);
2718 Assembler _assembler_; 2718 Assembler _assembler_;
2719 GenerateIncrement(&_assembler_); 2719 GenerateIncrement(&_assembler_);
2720 const Function& function = Function::Handle(CreateFunction("Test_Code")); 2720 const Function& function = Function::Handle(CreateFunction("Test_Code"));
2721 Code& code = Code::Handle(Code::FinalizeCode(function, &_assembler_)); 2721 Code& code = Code::Handle(Code::FinalizeCode(function, &_assembler_));
2722 function.AttachCode(code); 2722 function.AttachCode(code);
2723 const Instructions& instructions = Instructions::Handle(code.instructions()); 2723 const Instructions& instructions = Instructions::Handle(code.instructions());
2724 uword entry_point = instructions.UncheckedEntryPoint(); 2724 uword payload_start = instructions.PayloadStart();
2725 EXPECT_EQ(instructions.raw(), 2725 EXPECT_EQ(instructions.raw(), Instructions::FromPayloadStart(payload_start));
2726 Instructions::FromUncheckedEntryPoint(entry_point));
2727 const Object& result = Object::Handle( 2726 const Object& result = Object::Handle(
2728 DartEntry::InvokeFunction(function, Array::empty_array())); 2727 DartEntry::InvokeFunction(function, Array::empty_array()));
2729 EXPECT_EQ(1, Smi::Cast(result).Value()); 2728 EXPECT_EQ(1, Smi::Cast(result).Value());
2730 } 2729 }
2731 2730
2732 2731
2733 // Test for immutability of generated instructions. The test crashes with a 2732 // Test for immutability of generated instructions. The test crashes with a
2734 // segmentation fault when writing into it. 2733 // segmentation fault when writing into it.
2735 VM_TEST_CASE(CodeImmutability) { 2734 VM_TEST_CASE(CodeImmutability) {
2736 extern void GenerateIncrement(Assembler* assembler); 2735 extern void GenerateIncrement(Assembler* assembler);
2737 Assembler _assembler_; 2736 Assembler _assembler_;
2738 GenerateIncrement(&_assembler_); 2737 GenerateIncrement(&_assembler_);
2739 const Function& function = Function::Handle(CreateFunction("Test_Code")); 2738 const Function& function = Function::Handle(CreateFunction("Test_Code"));
2740 Code& code = Code::Handle(Code::FinalizeCode(function, &_assembler_)); 2739 Code& code = Code::Handle(Code::FinalizeCode(function, &_assembler_));
2741 function.AttachCode(code); 2740 function.AttachCode(code);
2742 Instructions& instructions = Instructions::Handle(code.instructions()); 2741 Instructions& instructions = Instructions::Handle(code.instructions());
2743 uword entry_point = instructions.UncheckedEntryPoint(); 2742 uword payload_start = instructions.PayloadStart();
2744 EXPECT_EQ(instructions.raw(), 2743 EXPECT_EQ(instructions.raw(), Instructions::FromPayloadStart(payload_start));
2745 Instructions::FromUncheckedEntryPoint(entry_point));
2746 // Try writing into the generated code, expected to crash. 2744 // Try writing into the generated code, expected to crash.
2747 *(reinterpret_cast<char*>(entry_point) + 1) = 1; 2745 *(reinterpret_cast<char*>(payload_start) + 1) = 1;
2748 if (!FLAG_write_protect_code) { 2746 if (!FLAG_write_protect_code) {
2749 // Since this test is expected to crash, crash if write protection of code 2747 // Since this test is expected to crash, crash if write protection of code
2750 // is switched off. 2748 // is switched off.
2751 // TODO(regis, fschneider): Should this be FATAL() instead? 2749 // TODO(regis, fschneider): Should this be FATAL() instead?
2752 OS::DebugBreak(); 2750 OS::DebugBreak();
2753 } 2751 }
2754 } 2752 }
2755 2753
2756 2754
2757 // Test for Embedded String object in the instructions. 2755 // Test for Embedded String object in the instructions.
(...skipping 1986 matching lines...) Expand 10 before | Expand all | Expand 10 after
4744 int32_t char_codes[] = { 4742 int32_t char_codes[] = {
4745 0, 0x0a, 0x0d, 0x7f, 0xff, 0xffff, 0xd800, 0xdc00, 0xdbff, 0xdfff 4743 0, 0x0a, 0x0d, 0x7f, 0xff, 0xffff, 0xd800, 0xdc00, 0xdbff, 0xdfff
4746 }; 4744 };
4747 4745
4748 const String& str = 4746 const String& str =
4749 String::Handle(String::FromUTF32(char_codes, ARRAY_SIZE(char_codes))); 4747 String::Handle(String::FromUTF32(char_codes, ARRAY_SIZE(char_codes)));
4750 EXPECT(str.Equals(char_codes, ARRAY_SIZE(char_codes))); 4748 EXPECT(str.Equals(char_codes, ARRAY_SIZE(char_codes)));
4751 } 4749 }
4752 4750
4753 } // namespace dart 4751 } // namespace dart
OLDNEW
« runtime/vm/object.h ('K') | « runtime/vm/object.cc ('k') | runtime/vm/raw_object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698