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

Side by Side Diff: vm/code_index_table_test.cc

Issue 10030001: Resubmit change 6302 after fixing the compiler warning on older GCC compiler versions: (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 8 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
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_index_table.h"
8 #include "vm/compiler.h" 7 #include "vm/compiler.h"
9 #include "vm/object.h" 8 #include "vm/object.h"
10 #include "vm/pages.h" 9 #include "vm/pages.h"
10 #include "vm/stack_frame.h"
11 #include "vm/unit_test.h" 11 #include "vm/unit_test.h"
12 12
13 namespace dart { 13 namespace dart {
14 14
15 // Compiler only implemented on IA32 and x64 now. 15 // Compiler only implemented on IA32 and x64 now.
16 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64) 16 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64)
17 17
18 TEST_CASE(CodeIndexTable) { 18 TEST_CASE(CodeIndexTable) {
19 #if defined(TARGET_ARCH_IA32) 19 #if defined(TARGET_ARCH_IA32)
20 const int kLoopCount = 50000; 20 const int kLoopCount = 50000;
21 #else 21 #else
22 const int kLoopCount = 25000; 22 const int kLoopCount = 25000;
23 #endif 23 #endif
24 const int kScriptSize = 512 * KB; 24 const int kScriptSize = 512 * KB;
25 const int kNumFunctions = 1024; 25 const int kNumFunctions = 1024;
26 char scriptChars[kScriptSize]; 26 char scriptChars[kScriptSize];
27 String& url = String::Handle(String::New("dart-test:CodeIndexTable")); 27 String& url = String::Handle(String::New("dart-test:CodeIndexTable"));
28 String& source = String::Handle(); 28 String& source = String::Handle();
29 Script& script = Script::Handle(); 29 Script& script = Script::Handle();
30 Library& lib = Library::Handle(); 30 Library& lib = Library::Handle();
31 Class& clsA = Class::Handle(); 31 Class& clsA = Class::Handle();
32 Class& clsB = Class::Handle(); 32 Class& clsB = Class::Handle();
33 String& function_name = String::Handle(); 33 String& function_name = String::Handle();
34 Function& function = Function::Handle(); 34 Function& function = Function::Handle();
35 char buffer[256]; 35 char buffer[256];
36 36
37 // Get access to the code index table. 37 // Get access to the code index table.
38 ASSERT(Isolate::Current() != NULL); 38 Isolate* isolate = Isolate::Current();
39 CodeIndexTable* code_index_table = Isolate::Current()->code_index_table(); 39 ASSERT(isolate != NULL);
40 ASSERT(code_index_table != NULL);
41 40
42 lib = Library::CoreLibrary(); 41 lib = Library::CoreLibrary();
43 42
44 // Load up class A with 1024 functions. 43 // Load up class A with 1024 functions.
45 int written = OS::SNPrint(scriptChars, kScriptSize, "class A {"); 44 int written = OS::SNPrint(scriptChars, kScriptSize, "class A {");
46 for (int i = 0; i < kNumFunctions; i++) { 45 for (int i = 0; i < kNumFunctions; i++) {
47 OS::SNPrint(buffer, 46 OS::SNPrint(buffer,
48 256, 47 256,
49 "static foo%d([int i=1,int j=2,int k=3]){return i+j+k;}", i); 48 "static foo%d([int i=1,int j=2,int k=3]){return i+j+k;}", i);
50 written += OS::SNPrint((scriptChars + written), 49 written += OS::SNPrint((scriptChars + written),
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 // Now try and access these functions using the code index table. 118 // Now try and access these functions using the code index table.
120 Code& code = Code::Handle(); 119 Code& code = Code::Handle();
121 uword pc; 120 uword pc;
122 OS::SNPrint(buffer, 256, "foo%d", 123); 121 OS::SNPrint(buffer, 256, "foo%d", 123);
123 function_name = String::New(buffer); 122 function_name = String::New(buffer);
124 function = clsA.LookupStaticFunction(function_name); 123 function = clsA.LookupStaticFunction(function_name);
125 EXPECT(!function.IsNull()); 124 EXPECT(!function.IsNull());
126 code = function.CurrentCode(); 125 code = function.CurrentCode();
127 EXPECT(code.Size() > 16); 126 EXPECT(code.Size() > 16);
128 pc = code.EntryPoint() + 16; 127 pc = code.EntryPoint() + 16;
129 EXPECT(code_index_table->LookupCode(pc) == code.raw()); 128 EXPECT(StackFrame::LookupCode(isolate, pc) == code.raw());
130 129
131 OS::SNPrint(buffer, 256, "moo%d", 54); 130 OS::SNPrint(buffer, 256, "moo%d", 54);
132 function_name = String::New(buffer); 131 function_name = String::New(buffer);
133 function = clsB.LookupStaticFunction(function_name); 132 function = clsB.LookupStaticFunction(function_name);
134 EXPECT(!function.IsNull()); 133 EXPECT(!function.IsNull());
135 code = function.CurrentCode(); 134 code = function.CurrentCode();
136 EXPECT(code.Size() > 16); 135 EXPECT(code.Size() > 16);
137 pc = code.EntryPoint() + 16; 136 pc = code.EntryPoint() + 16;
138 EXPECT(code_index_table->LookupCode(pc) == code.raw()); 137 EXPECT(StackFrame::LookupCode(isolate, pc) == code.raw());
139 138
140 // Lookup the large function 139 // Lookup the large function
141 OS::SNPrint(buffer, 256, "moo%d", 0); 140 OS::SNPrint(buffer, 256, "moo%d", 0);
142 function_name = String::New(buffer); 141 function_name = String::New(buffer);
143 function = clsB.LookupStaticFunction(function_name); 142 function = clsB.LookupStaticFunction(function_name);
144 EXPECT(!function.IsNull()); 143 EXPECT(!function.IsNull());
145 code = function.CurrentCode(); 144 code = function.CurrentCode();
146 EXPECT(code.Size() > 16); 145 EXPECT(code.Size() > 16);
147 pc = code.EntryPoint() + 16; 146 pc = code.EntryPoint() + 16;
148 EXPECT(code.Size() > PageSpace::kPageSize); 147 EXPECT(code.Size() > PageSpace::kPageSize);
149 EXPECT(code_index_table->LookupCode(pc) == code.raw()); 148 EXPECT(StackFrame::LookupCode(isolate, pc) == code.raw());
150 EXPECT(code.Size() > (1 * MB)); 149 EXPECT(code.Size() > (1 * MB));
151 pc = code.EntryPoint() + (1 * MB); 150 pc = code.EntryPoint() + (1 * MB);
152 EXPECT(code_index_table->LookupCode(pc) == code.raw()); 151 EXPECT(StackFrame::LookupCode(isolate, pc) == code.raw());
153 } 152 }
154 153
155 #endif // TARGET_ARCH_IA32 || TARGET_ARCH_X64 154 #endif // TARGET_ARCH_IA32 || TARGET_ARCH_X64
156 155
157 } // namespace dart 156 } // namespace dart
OLDNEW
« no previous file with comments | « vm/code_generator.cc ('k') | vm/compiler.cc » ('j') | vm/stack_frame.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698