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

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

Issue 2714083002: Revert "Fixed issue in MallocHooks where a MallocHookScope was accidentally removed during a merge,… (Closed)
Patch Set: Created 3 years, 10 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/malloc_hooks_unsupported.cc ('k') | runtime/vm/os.h » ('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"
11 #include "vm/debugger.h" 11 #include "vm/debugger.h"
12 #include "vm/isolate.h" 12 #include "vm/isolate.h"
13 #include "vm/malloc_hooks.h"
14 #include "vm/object.h" 13 #include "vm/object.h"
15 #include "vm/object_store.h" 14 #include "vm/object_store.h"
16 #include "vm/simulator.h" 15 #include "vm/simulator.h"
17 #include "vm/symbols.h" 16 #include "vm/symbols.h"
18 #include "vm/unit_test.h" 17 #include "vm/unit_test.h"
19 #include "vm/code_descriptors.h" 18 #include "vm/code_descriptors.h"
20 19
21 namespace dart { 20 namespace dart {
22 21
23 DECLARE_FLAG(bool, write_protect_code); 22 DECLARE_FLAG(bool, write_protect_code);
(...skipping 2679 matching lines...) Expand 10 before | Expand all | Expand 10 after
2703 EXPECT_EQ(instructions.raw(), Instructions::FromPayloadStart(payload_start)); 2702 EXPECT_EQ(instructions.raw(), Instructions::FromPayloadStart(payload_start));
2704 const Object& result = 2703 const Object& result =
2705 Object::Handle(DartEntry::InvokeFunction(function, Array::empty_array())); 2704 Object::Handle(DartEntry::InvokeFunction(function, Array::empty_array()));
2706 EXPECT_EQ(1, Smi::Cast(result).Value()); 2705 EXPECT_EQ(1, Smi::Cast(result).Value());
2707 } 2706 }
2708 2707
2709 2708
2710 // Test for immutability of generated instructions. The test crashes with a 2709 // Test for immutability of generated instructions. The test crashes with a
2711 // segmentation fault when writing into it. 2710 // segmentation fault when writing into it.
2712 ISOLATE_UNIT_TEST_CASE(CodeImmutability) { 2711 ISOLATE_UNIT_TEST_CASE(CodeImmutability) {
2713 bool stack_trace_collection_enabled =
2714 MallocHooks::stack_trace_collection_enabled();
2715 MallocHooks::set_stack_trace_collection_enabled(false);
2716 extern void GenerateIncrement(Assembler * assembler); 2712 extern void GenerateIncrement(Assembler * assembler);
2717 Assembler _assembler_; 2713 Assembler _assembler_;
2718 GenerateIncrement(&_assembler_); 2714 GenerateIncrement(&_assembler_);
2719 const Function& function = Function::Handle(CreateFunction("Test_Code")); 2715 const Function& function = Function::Handle(CreateFunction("Test_Code"));
2720 Code& code = Code::Handle(Code::FinalizeCode(function, &_assembler_)); 2716 Code& code = Code::Handle(Code::FinalizeCode(function, &_assembler_));
2721 function.AttachCode(code); 2717 function.AttachCode(code);
2722 Instructions& instructions = Instructions::Handle(code.instructions()); 2718 Instructions& instructions = Instructions::Handle(code.instructions());
2723 uword payload_start = instructions.PayloadStart(); 2719 uword payload_start = instructions.PayloadStart();
2724 EXPECT_EQ(instructions.raw(), Instructions::FromPayloadStart(payload_start)); 2720 EXPECT_EQ(instructions.raw(), Instructions::FromPayloadStart(payload_start));
2725 // Try writing into the generated code, expected to crash. 2721 // Try writing into the generated code, expected to crash.
2726 *(reinterpret_cast<char*>(payload_start) + 1) = 1; 2722 *(reinterpret_cast<char*>(payload_start) + 1) = 1;
2727 if (!FLAG_write_protect_code) { 2723 if (!FLAG_write_protect_code) {
2728 // Since this test is expected to crash, crash if write protection of code 2724 // Since this test is expected to crash, crash if write protection of code
2729 // is switched off. 2725 // is switched off.
2730 // TODO(regis, fschneider): Should this be FATAL() instead? 2726 // TODO(regis, fschneider): Should this be FATAL() instead?
2731 OS::DebugBreak(); 2727 OS::DebugBreak();
2732 } 2728 }
2733 MallocHooks::set_stack_trace_collection_enabled(
2734 stack_trace_collection_enabled);
2735 } 2729 }
2736 2730
2737 2731
2738 // Test for Embedded String object in the instructions. 2732 // Test for Embedded String object in the instructions.
2739 ISOLATE_UNIT_TEST_CASE(EmbedStringInCode) { 2733 ISOLATE_UNIT_TEST_CASE(EmbedStringInCode) {
2740 extern void GenerateEmbedStringInCode(Assembler * assembler, const char* str); 2734 extern void GenerateEmbedStringInCode(Assembler * assembler, const char* str);
2741 const char* kHello = "Hello World!"; 2735 const char* kHello = "Hello World!";
2742 word expected_length = static_cast<word>(strlen(kHello)); 2736 word expected_length = static_cast<word>(strlen(kHello));
2743 Assembler _assembler_; 2737 Assembler _assembler_;
2744 GenerateEmbedStringInCode(&_assembler_, kHello); 2738 GenerateEmbedStringInCode(&_assembler_, kHello);
(...skipping 1956 matching lines...) Expand 10 before | Expand all | Expand 10 after
4701 // utf32->utf16 conversion. 4695 // utf32->utf16 conversion.
4702 int32_t char_codes[] = {0, 0x0a, 0x0d, 0x7f, 0xff, 4696 int32_t char_codes[] = {0, 0x0a, 0x0d, 0x7f, 0xff,
4703 0xffff, 0xd800, 0xdc00, 0xdbff, 0xdfff}; 4697 0xffff, 0xd800, 0xdc00, 0xdbff, 0xdfff};
4704 4698
4705 const String& str = 4699 const String& str =
4706 String::Handle(String::FromUTF32(char_codes, ARRAY_SIZE(char_codes))); 4700 String::Handle(String::FromUTF32(char_codes, ARRAY_SIZE(char_codes)));
4707 EXPECT(str.Equals(char_codes, ARRAY_SIZE(char_codes))); 4701 EXPECT(str.Equals(char_codes, ARRAY_SIZE(char_codes)));
4708 } 4702 }
4709 4703
4710 } // namespace dart 4704 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/malloc_hooks_unsupported.cc ('k') | runtime/vm/os.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698