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

Side by Side Diff: test/cctest/test-api-fast-accessor-builder.cc

Issue 1669213003: [crankshaft] Replace stub cache harvesting with a bit of type propagation (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebased Created 4 years, 10 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
« no previous file with comments | « src/flag-definitions.h ('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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stdlib.h> 5 #include <stdlib.h>
6 6
7 #include "include/v8.h" 7 #include "include/v8.h"
8 #include "include/v8-experimental.h" 8 #include "include/v8-experimental.h"
9 9
10 #include "src/api.h" 10 #include "src/api.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 builder->ReturnValue( 105 builder->ReturnValue(
106 builder->LoadInternalField(builder->GetReceiver(), field_no)); 106 builder->LoadInternalField(builder->GetReceiver(), field_no));
107 templ->SetAccessorProperty(v8_str(name), 107 templ->SetAccessorProperty(v8_str(name),
108 v8::FunctionTemplate::NewWithFastHandler( 108 v8::FunctionTemplate::NewWithFastHandler(
109 isolate, NativePropertyAccessor, builder)); 109 isolate, NativePropertyAccessor, builder));
110 } 110 }
111 111
112 112
113 // "Fast" accessor that accesses an internal field. 113 // "Fast" accessor that accesses an internal field.
114 TEST(FastAccessorWithInternalField) { 114 TEST(FastAccessorWithInternalField) {
115 // Crankshaft support for fast accessors is not implemented; crankshafted
116 // code uses the slow accessor which breaks this test's expectations.
117 v8::internal::FLAG_always_opt = false;
115 LocalContext env; 118 LocalContext env;
116 v8::Isolate* isolate = env->GetIsolate(); 119 v8::Isolate* isolate = env->GetIsolate();
117 v8::HandleScope scope(isolate); 120 v8::HandleScope scope(isolate);
118 121
119 v8::Local<v8::ObjectTemplate> foo = v8::ObjectTemplate::New(isolate); 122 v8::Local<v8::ObjectTemplate> foo = v8::ObjectTemplate::New(isolate);
120 foo->SetInternalFieldCount(3); 123 foo->SetInternalFieldCount(3);
121 AddInternalFieldAccessor(isolate, foo, "field0", 0); 124 AddInternalFieldAccessor(isolate, foo, "field0", 0);
122 AddInternalFieldAccessor(isolate, foo, "field1", 1); 125 AddInternalFieldAccessor(isolate, foo, "field1", 1);
123 AddInternalFieldAccessor(isolate, foo, "field2", 2); 126 AddInternalFieldAccessor(isolate, foo, "field2", 2);
124 127
(...skipping 10 matching lines...) Expand all
135 138
136 // Access fields. 139 // Access fields.
137 ExpectString("field0()", "Hi there!"); 140 ExpectString("field0()", "Hi there!");
138 ExpectInt32("field1()", 4321); 141 ExpectInt32("field1()", 4321);
139 ExpectUndefined("field2()"); 142 ExpectUndefined("field2()");
140 } 143 }
141 144
142 145
143 // "Fast" accessor with control flow via ...OrReturnNull methods. 146 // "Fast" accessor with control flow via ...OrReturnNull methods.
144 TEST(FastAccessorOrReturnNull) { 147 TEST(FastAccessorOrReturnNull) {
148 // Crankshaft support for fast accessors is not implemented; crankshafted
149 // code uses the slow accessor which breaks this test's expectations.
150 v8::internal::FLAG_always_opt = false;
145 LocalContext env; 151 LocalContext env;
146 v8::Isolate* isolate = env->GetIsolate(); 152 v8::Isolate* isolate = env->GetIsolate();
147 v8::HandleScope scope(isolate); 153 v8::HandleScope scope(isolate);
148 154
149 v8::Local<v8::ObjectTemplate> foo = v8::ObjectTemplate::New(isolate); 155 v8::Local<v8::ObjectTemplate> foo = v8::ObjectTemplate::New(isolate);
150 foo->SetInternalFieldCount(2); 156 foo->SetInternalFieldCount(2);
151 { 157 {
152 // accessor "nullcheck": Return null if field 0 is non-null object; else 5. 158 // accessor "nullcheck": Return null if field 0 is non-null object; else 5.
153 auto builder = v8::experimental::FastAccessorBuilder::New(isolate); 159 auto builder = v8::experimental::FastAccessorBuilder::New(isolate);
154 auto val = builder->LoadInternalField(builder->GetReceiver(), 0); 160 auto val = builder->LoadInternalField(builder->GetReceiver(), 0);
(...skipping 29 matching lines...) Expand all
184 CompileRun(FN_WARMUP("maskcheck", "return obj.maskcheck")); 190 CompileRun(FN_WARMUP("maskcheck", "return obj.maskcheck"));
185 obj->SetAlignedPointerInInternalField(1, reinterpret_cast<void*>(0xf0)); 191 obj->SetAlignedPointerInInternalField(1, reinterpret_cast<void*>(0xf0));
186 ExpectInt32("maskcheck()", 42); 192 ExpectInt32("maskcheck()", 42);
187 obj->SetAlignedPointerInInternalField(1, reinterpret_cast<void*>(0xfe)); 193 obj->SetAlignedPointerInInternalField(1, reinterpret_cast<void*>(0xfe));
188 ExpectNull("maskcheck()"); 194 ExpectNull("maskcheck()");
189 } 195 }
190 196
191 197
192 // "Fast" accessor with simple control flow via explicit labels. 198 // "Fast" accessor with simple control flow via explicit labels.
193 TEST(FastAccessorControlFlowWithLabels) { 199 TEST(FastAccessorControlFlowWithLabels) {
200 // Crankshaft support for fast accessors is not implemented; crankshafted
201 // code uses the slow accessor which breaks this test's expectations.
202 v8::internal::FLAG_always_opt = false;
194 LocalContext env; 203 LocalContext env;
195 v8::Isolate* isolate = env->GetIsolate(); 204 v8::Isolate* isolate = env->GetIsolate();
196 v8::HandleScope scope(isolate); 205 v8::HandleScope scope(isolate);
197 206
198 v8::Local<v8::ObjectTemplate> foo = v8::ObjectTemplate::New(isolate); 207 v8::Local<v8::ObjectTemplate> foo = v8::ObjectTemplate::New(isolate);
199 foo->SetInternalFieldCount(1); 208 foo->SetInternalFieldCount(1);
200 { 209 {
201 // accessor isnull: 0 for nullptr, else 1. 210 // accessor isnull: 0 for nullptr, else 1.
202 auto builder = v8::experimental::FastAccessorBuilder::New(isolate); 211 auto builder = v8::experimental::FastAccessorBuilder::New(isolate);
203 auto label = builder->MakeLabel(); 212 auto label = builder->MakeLabel();
(...skipping 15 matching lines...) Expand all
219 CompileRun(FN_WARMUP("isnull", "return obj.isnull")); 228 CompileRun(FN_WARMUP("isnull", "return obj.isnull"));
220 obj->SetAlignedPointerInInternalField(0, /* anything != nullptr */ isolate); 229 obj->SetAlignedPointerInInternalField(0, /* anything != nullptr */ isolate);
221 ExpectInt32("isnull()", 1); 230 ExpectInt32("isnull()", 1);
222 obj->SetAlignedPointerInInternalField(0, nullptr); 231 obj->SetAlignedPointerInInternalField(0, nullptr);
223 ExpectInt32("isnull()", 0); 232 ExpectInt32("isnull()", 0);
224 } 233 }
225 234
226 235
227 // "Fast" accessor, loading things. 236 // "Fast" accessor, loading things.
228 TEST(FastAccessorLoad) { 237 TEST(FastAccessorLoad) {
238 // Crankshaft support for fast accessors is not implemented; crankshafted
239 // code uses the slow accessor which breaks this test's expectations.
240 v8::internal::FLAG_always_opt = false;
229 LocalContext env; 241 LocalContext env;
230 v8::Isolate* isolate = env->GetIsolate(); 242 v8::Isolate* isolate = env->GetIsolate();
231 v8::HandleScope scope(isolate); 243 v8::HandleScope scope(isolate);
232 244
233 v8::Local<v8::ObjectTemplate> foo = v8::ObjectTemplate::New(isolate); 245 v8::Local<v8::ObjectTemplate> foo = v8::ObjectTemplate::New(isolate);
234 foo->SetInternalFieldCount(1); 246 foo->SetInternalFieldCount(1);
235 247
236 // Internal field 0 is a pointer to a C++ data structure that we wish to load 248 // Internal field 0 is a pointer to a C++ data structure that we wish to load
237 // field values from. 249 // field values from.
238 struct { 250 struct {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 } 310 }
299 311
300 void ApiCallbackParam(const v8::FunctionCallbackInfo<v8::Value>& info) { 312 void ApiCallbackParam(const v8::FunctionCallbackInfo<v8::Value>& info) {
301 CHECK_EQ(1, info.Length()); 313 CHECK_EQ(1, info.Length());
302 CHECK(info[0]->IsNumber()); 314 CHECK(info[0]->IsNumber());
303 info.GetReturnValue().Set(info[0]); 315 info.GetReturnValue().Set(info[0]);
304 } 316 }
305 317
306 // "Fast" accessor, callback to embedder 318 // "Fast" accessor, callback to embedder
307 TEST(FastAccessorCallback) { 319 TEST(FastAccessorCallback) {
320 // Crankshaft support for fast accessors is not implemented; crankshafted
321 // code uses the slow accessor which breaks this test's expectations.
322 v8::internal::FLAG_always_opt = false;
308 LocalContext env; 323 LocalContext env;
309 v8::Isolate* isolate = env->GetIsolate(); 324 v8::Isolate* isolate = env->GetIsolate();
310 v8::HandleScope scope(isolate); 325 v8::HandleScope scope(isolate);
311 326
312 v8::Local<v8::ObjectTemplate> foo = v8::ObjectTemplate::New(isolate); 327 v8::Local<v8::ObjectTemplate> foo = v8::ObjectTemplate::New(isolate);
313 { 328 {
314 auto builder = v8::experimental::FastAccessorBuilder::New(isolate); 329 auto builder = v8::experimental::FastAccessorBuilder::New(isolate);
315 builder->ReturnValue( 330 builder->ReturnValue(
316 builder->Call(&ApiCallbackInt, builder->IntegerConstant(999))); 331 builder->Call(&ApiCallbackInt, builder->IntegerConstant(999)));
317 foo->SetAccessorProperty(v8_str("int"), 332 foo->SetAccessorProperty(v8_str("int"),
(...skipping 22 matching lines...) Expand all
340 // Callbacks: 355 // Callbacks:
341 CompileRun(FN_WARMUP("callbackint", "return obj.int")); 356 CompileRun(FN_WARMUP("callbackint", "return obj.int"));
342 ExpectInt32("callbackint()", 12345); 357 ExpectInt32("callbackint()", 12345);
343 358
344 CompileRun(FN_WARMUP("callbackstr", "return obj.str")); 359 CompileRun(FN_WARMUP("callbackstr", "return obj.str"));
345 ExpectString("callbackstr()", kApiCallbackStringValue); 360 ExpectString("callbackstr()", kApiCallbackStringValue);
346 361
347 CompileRun(FN_WARMUP("callbackparam", "return obj.param")); 362 CompileRun(FN_WARMUP("callbackparam", "return obj.param"));
348 ExpectInt32("callbackparam()", 1000); 363 ExpectInt32("callbackparam()", 1000);
349 } 364 }
OLDNEW
« no previous file with comments | « src/flag-definitions.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698