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

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

Issue 2481873005: clang-format runtime/vm (Closed)
Patch Set: Merge Created 4 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
« no previous file with comments | « runtime/vm/exceptions_test.cc ('k') | runtime/vm/flag_list.h » ('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"
(...skipping 30 matching lines...) Expand all
41 Class& clsB = Class::Handle(); 41 Class& clsB = Class::Handle();
42 String& function_name = String::Handle(); 42 String& function_name = String::Handle();
43 Function& function = Function::Handle(); 43 Function& function = Function::Handle();
44 char buffer[256]; 44 char buffer[256];
45 45
46 lib = Library::CoreLibrary(); 46 lib = Library::CoreLibrary();
47 47
48 // Load up class A with 1024 functions. 48 // Load up class A with 1024 functions.
49 int written = OS::SNPrint(scriptChars, kScriptSize, "class A {"); 49 int written = OS::SNPrint(scriptChars, kScriptSize, "class A {");
50 for (int i = 0; i < kNumFunctions; i++) { 50 for (int i = 0; i < kNumFunctions; i++) {
51 OS::SNPrint(buffer, 51 OS::SNPrint(buffer, 256,
52 256,
53 "static foo%d([int i=1,int j=2,int k=3]){return i+j+k;}", i); 52 "static foo%d([int i=1,int j=2,int k=3]){return i+j+k;}", i);
54 written += OS::SNPrint((scriptChars + written), 53 written += OS::SNPrint((scriptChars + written), (kScriptSize - written),
55 (kScriptSize - written), 54 "%s", buffer);
56 "%s",
57 buffer);
58 } 55 }
59 OS::SNPrint((scriptChars + written), (kScriptSize - written), "}"); 56 OS::SNPrint((scriptChars + written), (kScriptSize - written), "}");
60 source = String::New(scriptChars); 57 source = String::New(scriptChars);
61 script = Script::New(url, source, RawScript::kScriptTag); 58 script = Script::New(url, source, RawScript::kScriptTag);
62 EXPECT(CompilerTest::TestCompileScript(lib, script)); 59 EXPECT(CompilerTest::TestCompileScript(lib, script));
63 clsA = lib.LookupClass(String::Handle(Symbols::New(thread, "A"))); 60 clsA = lib.LookupClass(String::Handle(Symbols::New(thread, "A")));
64 EXPECT(!clsA.IsNull()); 61 EXPECT(!clsA.IsNull());
65 ClassFinalizer::ProcessPendingClasses(); 62 ClassFinalizer::ProcessPendingClasses();
66 for (int i = 0; i < kNumFunctions; i++) { 63 for (int i = 0; i < kNumFunctions; i++) {
67 OS::SNPrint(buffer, 256, "foo%d", i); 64 OS::SNPrint(buffer, 256, "foo%d", i);
68 function_name = String::New(buffer); 65 function_name = String::New(buffer);
69 function = clsA.LookupStaticFunction(function_name); 66 function = clsA.LookupStaticFunction(function_name);
70 EXPECT(!function.IsNull()); 67 EXPECT(!function.IsNull());
71 EXPECT(CompilerTest::TestCompileFunction(function)); 68 EXPECT(CompilerTest::TestCompileFunction(function));
72 const Code& code = Code::ZoneHandle(function.CurrentCode()); 69 const Code& code = Code::ZoneHandle(function.CurrentCode());
73 EXPECT(!code.IsNull()) 70 EXPECT(!code.IsNull())
74 EXPECT(function.HasCode()); 71 EXPECT(function.HasCode());
75 } 72 }
76 73
77 // Now load up class B with 1024 functions. 74 // Now load up class B with 1024 functions.
78 written = OS::SNPrint(scriptChars, kScriptSize, "class B {"); 75 written = OS::SNPrint(scriptChars, kScriptSize, "class B {");
79 // Create one large function. 76 // Create one large function.
80 OS::SNPrint(buffer, sizeof(buffer), "static moo0([var i=1]) { "); 77 OS::SNPrint(buffer, sizeof(buffer), "static moo0([var i=1]) { ");
81 written += OS::SNPrint((scriptChars + written), 78 written += OS::SNPrint((scriptChars + written), (kScriptSize - written), "%s",
82 (kScriptSize - written),
83 "%s",
84 buffer); 79 buffer);
85 // Generate a large function so that the code for this function when 80 // Generate a large function so that the code for this function when
86 // compiled will reside in a large page. 81 // compiled will reside in a large page.
87 for (int i = 0; i < kLoopCount; i++) { 82 for (int i = 0; i < kLoopCount; i++) {
88 OS::SNPrint(buffer, sizeof(buffer), "i = i+i;"); 83 OS::SNPrint(buffer, sizeof(buffer), "i = i+i;");
89 written += OS::SNPrint((scriptChars + written), 84 written += OS::SNPrint((scriptChars + written), (kScriptSize - written),
90 (kScriptSize - written), 85 "%s", buffer);
91 "%s",
92 buffer);
93 } 86 }
94 OS::SNPrint(buffer, sizeof(buffer), "return i; }"); 87 OS::SNPrint(buffer, sizeof(buffer), "return i; }");
95 written += OS::SNPrint((scriptChars + written), 88 written += OS::SNPrint((scriptChars + written), (kScriptSize - written), "%s",
96 (kScriptSize - written),
97 "%s",
98 buffer); 89 buffer);
99 for (int i = 1; i < kNumFunctions; i++) { 90 for (int i = 1; i < kNumFunctions; i++) {
100 OS::SNPrint(buffer, 91 OS::SNPrint(buffer, 256,
101 256,
102 "static moo%d([int i=1,int j=2,int k=3]){return i+j+k;}", i); 92 "static moo%d([int i=1,int j=2,int k=3]){return i+j+k;}", i);
103 written += OS::SNPrint((scriptChars + written), 93 written += OS::SNPrint((scriptChars + written), (kScriptSize - written),
104 (kScriptSize - written), 94 "%s", buffer);
105 "%s",
106 buffer);
107 } 95 }
108 OS::SNPrint((scriptChars + written), (kScriptSize - written), "}"); 96 OS::SNPrint((scriptChars + written), (kScriptSize - written), "}");
109 url = String::New("dart-test:FindCodeObject"); 97 url = String::New("dart-test:FindCodeObject");
110 source = String::New(scriptChars); 98 source = String::New(scriptChars);
111 script = Script::New(url, source, RawScript::kScriptTag); 99 script = Script::New(url, source, RawScript::kScriptTag);
112 EXPECT(CompilerTest::TestCompileScript(lib, script)); 100 EXPECT(CompilerTest::TestCompileScript(lib, script));
113 clsB = lib.LookupClass(String::Handle(Symbols::New(thread, "B"))); 101 clsB = lib.LookupClass(String::Handle(Symbols::New(thread, "B")));
114 EXPECT(!clsB.IsNull()); 102 EXPECT(!clsB.IsNull());
115 ClassFinalizer::ProcessPendingClasses(); 103 ClassFinalizer::ProcessPendingClasses();
116 for (int i = 0; i < kNumFunctions; i++) { 104 for (int i = 0; i < kNumFunctions; i++) {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 EXPECT(code.Size() > 16); 142 EXPECT(code.Size() > 16);
155 pc = code.PayloadStart() + 16; 143 pc = code.PayloadStart() + 16;
156 EXPECT(code.Size() > (PageSpace::kPageSizeInWords << kWordSizeLog2)); 144 EXPECT(code.Size() > (PageSpace::kPageSizeInWords << kWordSizeLog2));
157 EXPECT(Code::LookupCode(pc) == code.raw()); 145 EXPECT(Code::LookupCode(pc) == code.raw());
158 EXPECT(code.Size() > (1 * MB)); 146 EXPECT(code.Size() > (1 * MB));
159 pc = code.PayloadStart() + (1 * MB); 147 pc = code.PayloadStart() + (1 * MB);
160 EXPECT(Code::LookupCode(pc) == code.raw()); 148 EXPECT(Code::LookupCode(pc) == code.raw());
161 } 149 }
162 150
163 } // namespace dart 151 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/exceptions_test.cc ('k') | runtime/vm/flag_list.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698