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

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

Issue 557913002: Allow invalidation and recompilation of instance allocation stubs. Requested in order to implement… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/code_generator.cc ('k') | runtime/vm/object.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/assert.h" 5 #include "platform/assert.h"
6 #include "vm/class_finalizer.h" 6 #include "vm/class_finalizer.h"
7 #include "vm/code_patcher.h"
7 #include "vm/compiler.h" 8 #include "vm/compiler.h"
8 #include "vm/dart_api_impl.h" 9 #include "vm/dart_api_impl.h"
9 #include "vm/object.h" 10 #include "vm/object.h"
10 #include "vm/symbols.h" 11 #include "vm/symbols.h"
11 #include "vm/unit_test.h" 12 #include "vm/unit_test.h"
12 13
13 namespace dart { 14 namespace dart {
14 15
15 TEST_CASE(CompileScript) { 16 TEST_CASE(CompileScript) {
16 const char* kScriptChars = 17 const char* kScriptChars =
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 EXPECT(!function_moo.IsNull()); 62 EXPECT(!function_moo.IsNull());
62 63
63 EXPECT(CompilerTest::TestCompileFunction(function_moo)); 64 EXPECT(CompilerTest::TestCompileFunction(function_moo));
64 EXPECT(function_moo.HasCode()); 65 EXPECT(function_moo.HasCode());
65 function_source = function_moo.GetSource(); 66 function_source = function_moo.GetSource();
66 EXPECT_STREQ("static moo() {\n // A.foo();\n }\n", 67 EXPECT_STREQ("static moo() {\n // A.foo();\n }\n",
67 function_source.ToCString()); 68 function_source.ToCString());
68 } 69 }
69 70
70 71
72 TEST_CASE(RegenerateAllocStubs) {
73 const char* kScriptChars =
74 "class A {\n"
75 "}\n"
76 "unOpt() => new A(); \n"
77 "optIt() => new A(); \n"
78 "main() {\n"
79 " return unOpt();\n"
80 "}\n";
81
82 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
83 Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL);
84 EXPECT_VALID(result);
85 RawLibrary* raw_library = Library::RawCast(Api::UnwrapHandle(lib));
86 Library& lib_handle = Library::ZoneHandle(raw_library);
87 Class& cls = Class::Handle(
88 lib_handle.LookupClass(String::Handle(Symbols::New("A"))));
89 EXPECT(!cls.IsNull());
90
91 Isolate* isolate = Isolate::Current();
92 StubCode* stub_code = isolate->stub_code();
93 const Code& stub = Code::Handle(isolate,
94 stub_code->GetAllocationStubForClass(cls));
95 Class& owner = Class::Handle();
96 owner ^= stub.owner();
97 owner.DisableAllocationStub();
98 result = Dart_Invoke(lib, NewString("main"), 0, NULL);
99 EXPECT_VALID(result);
100 }
101
102
71 TEST_CASE(EvalExpression) { 103 TEST_CASE(EvalExpression) {
72 const char* kScriptChars = 104 const char* kScriptChars =
73 "int ten = 2 * 5; \n" 105 "int ten = 2 * 5; \n"
74 "get dot => '.'; \n" 106 "get dot => '.'; \n"
75 "class A { \n" 107 "class A { \n"
76 " var apa = 'Herr Nilsson'; \n" 108 " var apa = 'Herr Nilsson'; \n"
77 " calc(x) => '${x*ten}'; \n" 109 " calc(x) => '${x*ten}'; \n"
78 "} \n" 110 "} \n"
79 "makeObj() => new A(); \n"; 111 "makeObj() => new A(); \n";
80 112
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 val = lib.Evaluate(expression, Array::empty_array(), Array::empty_array()); 159 val = lib.Evaluate(expression, Array::empty_array(), Array::empty_array());
128 } 160 }
129 161
130 EXPECT(!val.IsNull()); 162 EXPECT(!val.IsNull());
131 EXPECT(!val.IsError()); 163 EXPECT(!val.IsError());
132 EXPECT(val.IsInteger()); 164 EXPECT(val.IsInteger());
133 EXPECT_EQ(7, Integer::Cast(val).AsInt64Value()); 165 EXPECT_EQ(7, Integer::Cast(val).AsInt64Value());
134 } 166 }
135 167
136 } // namespace dart 168 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/code_generator.cc ('k') | runtime/vm/object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698