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

Side by Side Diff: vm/code_index_table_test.cc

Issue 10025003: Revert change 6302 until the compiler warning is addressed. (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
« no previous file with comments | « vm/code_generator.cc ('k') | vm/compiler.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/code_index_table.h"
7 #include "vm/compiler.h" 8 #include "vm/compiler.h"
8 #include "vm/object.h" 9 #include "vm/object.h"
9 #include "vm/pages.h" 10 #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 Isolate* isolate = Isolate::Current(); 38 ASSERT(Isolate::Current() != NULL);
39 ASSERT(isolate != NULL); 39 CodeIndexTable* code_index_table = Isolate::Current()->code_index_table();
40 ASSERT(code_index_table != NULL);
40 41
41 lib = Library::CoreLibrary(); 42 lib = Library::CoreLibrary();
42 43
43 // Load up class A with 1024 functions. 44 // Load up class A with 1024 functions.
44 int written = OS::SNPrint(scriptChars, kScriptSize, "class A {"); 45 int written = OS::SNPrint(scriptChars, kScriptSize, "class A {");
45 for (int i = 0; i < kNumFunctions; i++) { 46 for (int i = 0; i < kNumFunctions; i++) {
46 OS::SNPrint(buffer, 47 OS::SNPrint(buffer,
47 256, 48 256,
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),
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 // Now try and access these functions using the code index table. 119 // Now try and access these functions using the code index table.
119 Code& code = Code::Handle(); 120 Code& code = Code::Handle();
120 uword pc; 121 uword pc;
121 OS::SNPrint(buffer, 256, "foo%d", 123); 122 OS::SNPrint(buffer, 256, "foo%d", 123);
122 function_name = String::New(buffer); 123 function_name = String::New(buffer);
123 function = clsA.LookupStaticFunction(function_name); 124 function = clsA.LookupStaticFunction(function_name);
124 EXPECT(!function.IsNull()); 125 EXPECT(!function.IsNull());
125 code = function.CurrentCode(); 126 code = function.CurrentCode();
126 EXPECT(code.Size() > 16); 127 EXPECT(code.Size() > 16);
127 pc = code.EntryPoint() + 16; 128 pc = code.EntryPoint() + 16;
128 EXPECT(StackFrame::LookupCode(isolate, pc) == code.raw()); 129 EXPECT(code_index_table->LookupCode(pc) == code.raw());
129 130
130 OS::SNPrint(buffer, 256, "moo%d", 54); 131 OS::SNPrint(buffer, 256, "moo%d", 54);
131 function_name = String::New(buffer); 132 function_name = String::New(buffer);
132 function = clsB.LookupStaticFunction(function_name); 133 function = clsB.LookupStaticFunction(function_name);
133 EXPECT(!function.IsNull()); 134 EXPECT(!function.IsNull());
134 code = function.CurrentCode(); 135 code = function.CurrentCode();
135 EXPECT(code.Size() > 16); 136 EXPECT(code.Size() > 16);
136 pc = code.EntryPoint() + 16; 137 pc = code.EntryPoint() + 16;
137 EXPECT(StackFrame::LookupCode(isolate, pc) == code.raw()); 138 EXPECT(code_index_table->LookupCode(pc) == code.raw());
138 139
139 // Lookup the large function 140 // Lookup the large function
140 OS::SNPrint(buffer, 256, "moo%d", 0); 141 OS::SNPrint(buffer, 256, "moo%d", 0);
141 function_name = String::New(buffer); 142 function_name = String::New(buffer);
142 function = clsB.LookupStaticFunction(function_name); 143 function = clsB.LookupStaticFunction(function_name);
143 EXPECT(!function.IsNull()); 144 EXPECT(!function.IsNull());
144 code = function.CurrentCode(); 145 code = function.CurrentCode();
145 EXPECT(code.Size() > 16); 146 EXPECT(code.Size() > 16);
146 pc = code.EntryPoint() + 16; 147 pc = code.EntryPoint() + 16;
147 EXPECT(code.Size() > PageSpace::kPageSize); 148 EXPECT(code.Size() > PageSpace::kPageSize);
148 EXPECT(StackFrame::LookupCode(isolate, pc) == code.raw()); 149 EXPECT(code_index_table->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(StackFrame::LookupCode(isolate, pc) == code.raw()); 152 EXPECT(code_index_table->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/code_generator.cc ('k') | vm/compiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698