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

Side by Side Diff: vm/find_code_object_test.cc

Issue 10783035: Create frequently used symbols in the vm isolate (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 5 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 | « vm/exceptions.cc ('k') | vm/flow_graph_builder.cc » ('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/compiler.h" 7 #include "vm/compiler.h"
8 #include "vm/object.h" 8 #include "vm/object.h"
9 #include "vm/pages.h" 9 #include "vm/pages.h"
10 #include "vm/stack_frame.h" 10 #include "vm/stack_frame.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 // Compiler only implemented on IA32 and x64 now. 16 // Compiler only implemented on IA32 and x64 now.
16 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64) 17 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64)
17 18
18 TEST_CASE(FindCodeObject) { 19 TEST_CASE(FindCodeObject) {
19 #if defined(TARGET_ARCH_IA32) 20 #if defined(TARGET_ARCH_IA32)
20 const int kLoopCount = 50000; 21 const int kLoopCount = 50000;
(...skipping 27 matching lines...) Expand all
48 "static foo%d([int i=1,int j=2,int k=3]){return i+j+k;}", i); 49 "static foo%d([int i=1,int j=2,int k=3]){return i+j+k;}", i);
49 written += OS::SNPrint((scriptChars + written), 50 written += OS::SNPrint((scriptChars + written),
50 (kScriptSize - written), 51 (kScriptSize - written),
51 "%s", 52 "%s",
52 buffer); 53 buffer);
53 } 54 }
54 OS::SNPrint((scriptChars + written), (kScriptSize - written), "}"); 55 OS::SNPrint((scriptChars + written), (kScriptSize - written), "}");
55 source = String::New(scriptChars); 56 source = String::New(scriptChars);
56 script = Script::New(url, source, RawScript::kSourceTag); 57 script = Script::New(url, source, RawScript::kSourceTag);
57 EXPECT(CompilerTest::TestCompileScript(lib, script)); 58 EXPECT(CompilerTest::TestCompileScript(lib, script));
58 clsA = lib.LookupClass(String::Handle(String::NewSymbol("A"))); 59 clsA = lib.LookupClass(String::Handle(Symbols::New("A")));
59 EXPECT(!clsA.IsNull()); 60 EXPECT(!clsA.IsNull());
60 ClassFinalizer::FinalizePendingClasses(); 61 ClassFinalizer::FinalizePendingClasses();
61 for (int i = 0; i < kNumFunctions; i++) { 62 for (int i = 0; i < kNumFunctions; i++) {
62 OS::SNPrint(buffer, 256, "foo%d", i); 63 OS::SNPrint(buffer, 256, "foo%d", i);
63 function_name = String::New(buffer); 64 function_name = String::New(buffer);
64 function = clsA.LookupStaticFunction(function_name); 65 function = clsA.LookupStaticFunction(function_name);
65 EXPECT(!function.IsNull()); 66 EXPECT(!function.IsNull());
66 EXPECT(CompilerTest::TestCompileFunction(function)); 67 EXPECT(CompilerTest::TestCompileFunction(function));
67 EXPECT(function.HasCode()); 68 EXPECT(function.HasCode());
68 } 69 }
(...skipping 27 matching lines...) Expand all
96 written += OS::SNPrint((scriptChars + written), 97 written += OS::SNPrint((scriptChars + written),
97 (kScriptSize - written), 98 (kScriptSize - written),
98 "%s", 99 "%s",
99 buffer); 100 buffer);
100 } 101 }
101 OS::SNPrint((scriptChars + written), (kScriptSize - written), "}"); 102 OS::SNPrint((scriptChars + written), (kScriptSize - written), "}");
102 url = String::New("dart-test:FindCodeObject"); 103 url = String::New("dart-test:FindCodeObject");
103 source = String::New(scriptChars); 104 source = String::New(scriptChars);
104 script = Script::New(url, source, RawScript::kSourceTag); 105 script = Script::New(url, source, RawScript::kSourceTag);
105 EXPECT(CompilerTest::TestCompileScript(lib, script)); 106 EXPECT(CompilerTest::TestCompileScript(lib, script));
106 clsB = lib.LookupClass(String::Handle(String::NewSymbol("B"))); 107 clsB = lib.LookupClass(String::Handle(Symbols::New("B")));
107 EXPECT(!clsB.IsNull()); 108 EXPECT(!clsB.IsNull());
108 ClassFinalizer::FinalizePendingClasses(); 109 ClassFinalizer::FinalizePendingClasses();
109 for (int i = 0; i < kNumFunctions; i++) { 110 for (int i = 0; i < kNumFunctions; i++) {
110 OS::SNPrint(buffer, 256, "moo%d", i); 111 OS::SNPrint(buffer, 256, "moo%d", i);
111 function_name = String::New(buffer); 112 function_name = String::New(buffer);
112 function = clsB.LookupStaticFunction(function_name); 113 function = clsB.LookupStaticFunction(function_name);
113 EXPECT(!function.IsNull()); 114 EXPECT(!function.IsNull());
114 EXPECT(CompilerTest::TestCompileFunction(function)); 115 EXPECT(CompilerTest::TestCompileFunction(function));
115 EXPECT(function.HasCode()); 116 EXPECT(function.HasCode());
116 } 117 }
(...skipping 30 matching lines...) Expand all
147 EXPECT(code.Size() > PageSpace::kPageSize); 148 EXPECT(code.Size() > PageSpace::kPageSize);
148 EXPECT(Code::LookupCode(pc) == code.raw()); 149 EXPECT(Code::LookupCode(pc) == code.raw());
149 EXPECT(code.Size() > (1 * MB)); 150 EXPECT(code.Size() > (1 * MB));
150 pc = code.EntryPoint() + (1 * MB); 151 pc = code.EntryPoint() + (1 * MB);
151 EXPECT(Code::LookupCode(pc) == code.raw()); 152 EXPECT(Code::LookupCode(pc) == code.raw());
152 } 153 }
153 154
154 #endif // TARGET_ARCH_IA32 || TARGET_ARCH_X64 155 #endif // TARGET_ARCH_IA32 || TARGET_ARCH_X64
155 156
156 } // namespace dart 157 } // namespace dart
OLDNEW
« no previous file with comments | « vm/exceptions.cc ('k') | vm/flow_graph_builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698