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

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

Issue 11365273: Upon script loading deoptimize only functions whose owner has been subclassed, as that is the only… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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 | Annotate | Revision Log
« runtime/vm/class_finalizer.cc ('K') | « runtime/vm/code_generator.cc ('k') | no next file » | 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 "include/dart_api.h" 5 #include "include/dart_api.h"
6 #include "platform/assert.h" 6 #include "platform/assert.h"
7 #include "platform/json.h" 7 #include "platform/json.h"
8 #include "platform/utils.h" 8 #include "platform/utils.h"
9 #include "vm/class_finalizer.h" 9 #include "vm/class_finalizer.h"
10 #include "vm/dart_api_impl.h" 10 #include "vm/dart_api_impl.h"
(...skipping 7146 matching lines...) Expand 10 before | Expand all | Expand 10 after
7157 EXPECT_EQ(2, isolate->heap()->PeerCount()); 7157 EXPECT_EQ(2, isolate->heap()->PeerCount());
7158 o2 = &o2; 7158 o2 = &o2;
7159 EXPECT_VALID(Dart_GetPeer(s2, &o2)); 7159 EXPECT_VALID(Dart_GetPeer(s2, &o2));
7160 EXPECT(o2 == reinterpret_cast<void*>(&p2)); 7160 EXPECT(o2 == reinterpret_cast<void*>(&p2));
7161 } 7161 }
7162 Dart_ExitScope(); 7162 Dart_ExitScope();
7163 isolate->heap()->CollectGarbage(Heap::kOld); 7163 isolate->heap()->CollectGarbage(Heap::kOld);
7164 EXPECT_EQ(0, isolate->heap()->PeerCount()); 7164 EXPECT_EQ(0, isolate->heap()->PeerCount());
7165 } 7165 }
7166 7166
7167
7168 TEST_CASE(LazyLoadDeoptimizes) {
7169 const char* kLoadFirst =
7170 "start(a) {\n"
7171 " var obj = (a == 1) ? createB() : new A();\n"
7172 " for (int i = 0; i < 4000; i++) {\n"
7173 " var res = obj.foo();\n"
7174 " if (a == 1) { if (res != 1) throw 'Error'; }\n"
7175 " else if (res != 2) throw 'Error'; \n"
7176 " }\n"
7177 "}\n"
7178 "\n"
7179 "createB() => new B();"
7180 "\n"
7181 "class A {\n"
7182 " foo() => goo();\n"
7183 " goo() => 2;\n"
7184 "}\n";
7185 const char* kLoadSecond =
7186 "class B extends A {\n"
7187 " goo() => 1;\n"
7188 "}\n";
7189 Dart_Handle result;
7190 // Create a test library and Load up a test script in it.
7191 Dart_Handle lib1 = TestCase::LoadTestScript(kLoadFirst, NULL);
7192 Dart_Handle dart_args[1];
7193 dart_args[0] = Dart_NewInteger(0);
7194 result = Dart_Invoke(lib1, NewString("start"), 1, dart_args);
7195 EXPECT_VALID(result);
7196
7197 Dart_Handle source = NewString(kLoadSecond);
7198 Dart_Handle url = NewString(TestCase::url());
7199 Dart_LoadSource(TestCase::lib(), url, source);
7200
7201 dart_args[0] = Dart_NewInteger(1);
7202 result = Dart_Invoke(lib1, NewString("start"), 1, dart_args);
7203 EXPECT_VALID(result);
7204 }
7205
7167 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). 7206 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64).
7168 7207
7169 } // namespace dart 7208 } // namespace dart
OLDNEW
« runtime/vm/class_finalizer.cc ('K') | « runtime/vm/code_generator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698