Chromium Code Reviews| Index: runtime/vm/compiler_test.cc |
| =================================================================== |
| --- runtime/vm/compiler_test.cc (revision 40064) |
| +++ runtime/vm/compiler_test.cc (working copy) |
| @@ -4,6 +4,7 @@ |
| #include "platform/assert.h" |
| #include "vm/class_finalizer.h" |
| +#include "vm/code_patcher.h" |
| #include "vm/compiler.h" |
| #include "vm/dart_api_impl.h" |
| #include "vm/object.h" |
| @@ -68,6 +69,37 @@ |
| } |
| +TEST_CASE(RegenerateAllocStubs) { |
| + const char* kScriptChars = |
| + "class A {\n" |
| + "}\n" |
| + "unOpt() => new A(); \n" |
| + "optIt() => new A(); \n" |
| + "main() {\n" |
| + " return unOpt();\n" |
| + "}\n"; |
| + |
| + Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); |
| + Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); |
| + EXPECT_VALID(result); |
| + RawLibrary* raw_library = Library::RawCast(Api::UnwrapHandle(lib)); |
| + Library& lib_handle = Library::ZoneHandle(raw_library); |
| + Class& cls = Class::Handle( |
| + lib_handle.LookupClass(String::Handle(Symbols::New("A")))); |
| + EXPECT(!cls.IsNull()); |
| + |
| + Isolate* isolate = Isolate::Current(); |
| + StubCode* stub_code = isolate->stub_code(); |
| + const Code& stub = Code::Handle(isolate, |
| + stub_code->GetAllocationStubForClass(cls)); |
| + Class& owner = Class::Handle(); |
| + owner ^= stub.owner(); |
|
koda
2014/09/10 15:33:22
Expect the owner to be cls.
|
| + owner.DisableAllocationStub(); |
| + result = Dart_Invoke(lib, NewString("main"), 0, NULL); |
| + EXPECT_VALID(result); |
|
koda
2014/09/10 15:33:22
Expect the result to be an A instance.
|
| +} |
| + |
| + |
| TEST_CASE(EvalExpression) { |
| const char* kScriptChars = |
| "int ten = 2 * 5; \n" |