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

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

Issue 2135153002: Fix FastAccessorAssembler inverted jump conditions (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 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
« no previous file with comments | « src/fast-accessor-assembler.cc ('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 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 // CheckNotZeroOrReturnNull: 182 // CheckNotZeroOrReturnNull:
183 CompileRun(FN_WARMUP("nullcheck", "return obj.nullcheck")); 183 CompileRun(FN_WARMUP("nullcheck", "return obj.nullcheck"));
184 obj->SetAlignedPointerInInternalField(0, /* anything != nullptr */ isolate); 184 obj->SetAlignedPointerInInternalField(0, /* anything != nullptr */ isolate);
185 ExpectInt32("nullcheck()", 5); 185 ExpectInt32("nullcheck()", 5);
186 obj->SetAlignedPointerInInternalField(0, nullptr); 186 obj->SetAlignedPointerInInternalField(0, nullptr);
187 ExpectNull("nullcheck()"); 187 ExpectNull("nullcheck()");
188 188
189 // CheckFlagSetOrReturnNull: 189 // CheckFlagSetOrReturnNull:
190 CompileRun(FN_WARMUP("maskcheck", "return obj.maskcheck")); 190 CompileRun(FN_WARMUP("maskcheck", "return obj.maskcheck"));
191 obj->SetAlignedPointerInInternalField(1, reinterpret_cast<void*>(0xf0)); 191 obj->SetAlignedPointerInInternalField(1, reinterpret_cast<void*>(0xf0));
192 ExpectNull("maskcheck()");
193 obj->SetAlignedPointerInInternalField(1, reinterpret_cast<void*>(0xfe));
192 ExpectInt32("maskcheck()", 42); 194 ExpectInt32("maskcheck()", 42);
193 obj->SetAlignedPointerInInternalField(1, reinterpret_cast<void*>(0xfe));
194 ExpectNull("maskcheck()");
195 } 195 }
196 196
197 197
198 // "Fast" accessor with simple control flow via explicit labels. 198 // "Fast" accessor with simple control flow via explicit labels.
199 TEST(FastAccessorControlFlowWithLabels) { 199 TEST(FastAccessorControlFlowWithLabels) {
200 // Crankshaft support for fast accessors is not implemented; crankshafted 200 // Crankshaft support for fast accessors is not implemented; crankshafted
201 // code uses the slow accessor which breaks this test's expectations. 201 // code uses the slow accessor which breaks this test's expectations.
202 v8::internal::FLAG_always_opt = false; 202 v8::internal::FLAG_always_opt = false;
203 LocalContext env; 203 LocalContext env;
204 v8::Isolate* isolate = env->GetIsolate(); 204 v8::Isolate* isolate = env->GetIsolate();
205 v8::HandleScope scope(isolate); 205 v8::HandleScope scope(isolate);
206 206
207 v8::Local<v8::ObjectTemplate> foo = v8::ObjectTemplate::New(isolate); 207 v8::Local<v8::ObjectTemplate> foo = v8::ObjectTemplate::New(isolate);
208 foo->SetInternalFieldCount(1); 208 foo->SetInternalFieldCount(1);
209 { 209 {
210 // accessor isnull: 0 for nullptr, else 1. 210 // accessor isnull: 0 for nullptr, else 1.
211 auto builder = v8::experimental::FastAccessorBuilder::New(isolate); 211 auto builder = v8::experimental::FastAccessorBuilder::New(isolate);
212 auto label = builder->MakeLabel(); 212 auto label = builder->MakeLabel();
213 auto val = builder->LoadInternalField(builder->GetReceiver(), 0); 213 auto val = builder->LoadInternalField(builder->GetReceiver(), 0);
214 builder->CheckNotZeroOrJump(val, label); 214 builder->CheckNotZeroOrJump(val, label);
215 builder->ReturnValue(builder->IntegerConstant(1));
216 builder->SetLabel(label);
215 builder->ReturnValue(builder->IntegerConstant(0)); 217 builder->ReturnValue(builder->IntegerConstant(0));
216 builder->SetLabel(label);
217 builder->ReturnValue(builder->IntegerConstant(1));
218 foo->SetAccessorProperty(v8_str("isnull"), 218 foo->SetAccessorProperty(v8_str("isnull"),
219 v8::FunctionTemplate::NewWithFastHandler( 219 v8::FunctionTemplate::NewWithFastHandler(
220 isolate, NativePropertyAccessor, builder)); 220 isolate, NativePropertyAccessor, builder));
221 } 221 }
222 222
223 // Create an instance. 223 // Create an instance.
224 v8::Local<v8::Object> obj = foo->NewInstance(env.local()).ToLocalChecked(); 224 v8::Local<v8::Object> obj = foo->NewInstance(env.local()).ToLocalChecked();
225 CHECK(env->Global()->Set(env.local(), v8_str("obj"), obj).FromJust()); 225 CHECK(env->Global()->Set(env.local(), v8_str("obj"), obj).FromJust());
226 226
227 // CheckNotZeroOrReturnNull: 227 // CheckNotZeroOrReturnNull:
(...skipping 27 matching lines...) Expand all
255 { 255 {
256 // accessor intisnonzero 256 // accessor intisnonzero
257 int intval_offset = 257 int intval_offset =
258 static_cast<int>(reinterpret_cast<intptr_t>(&val.intval) - 258 static_cast<int>(reinterpret_cast<intptr_t>(&val.intval) -
259 reinterpret_cast<intptr_t>(&val)); 259 reinterpret_cast<intptr_t>(&val));
260 auto builder = v8::experimental::FastAccessorBuilder::New(isolate); 260 auto builder = v8::experimental::FastAccessorBuilder::New(isolate);
261 auto label = builder->MakeLabel(); 261 auto label = builder->MakeLabel();
262 auto val = builder->LoadValue( 262 auto val = builder->LoadValue(
263 builder->LoadInternalField(builder->GetReceiver(), 0), intval_offset); 263 builder->LoadInternalField(builder->GetReceiver(), 0), intval_offset);
264 builder->CheckNotZeroOrJump(val, label); 264 builder->CheckNotZeroOrJump(val, label);
265 builder->ReturnValue(builder->IntegerConstant(1));
266 builder->SetLabel(label);
265 builder->ReturnValue(builder->IntegerConstant(0)); 267 builder->ReturnValue(builder->IntegerConstant(0));
266 builder->SetLabel(label);
267 builder->ReturnValue(builder->IntegerConstant(1));
268 foo->SetAccessorProperty(v8_str("nonzero"), 268 foo->SetAccessorProperty(v8_str("nonzero"),
269 v8::FunctionTemplate::NewWithFastHandler( 269 v8::FunctionTemplate::NewWithFastHandler(
270 isolate, NativePropertyAccessor, builder)); 270 isolate, NativePropertyAccessor, builder));
271 } 271 }
272 { 272 {
273 // accessor loadval 273 // accessor loadval
274 int v8val_offset = static_cast<int>(reinterpret_cast<intptr_t>(&val.v8val) - 274 int v8val_offset = static_cast<int>(reinterpret_cast<intptr_t>(&val.v8val) -
275 reinterpret_cast<intptr_t>(&val)); 275 reinterpret_cast<intptr_t>(&val));
276 auto builder = v8::experimental::FastAccessorBuilder::New(isolate); 276 auto builder = v8::experimental::FastAccessorBuilder::New(isolate);
277 builder->ReturnValue(builder->LoadObject( 277 builder->ReturnValue(builder->LoadObject(
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 // Callbacks: 355 // Callbacks:
356 CompileRun(FN_WARMUP("callbackint", "return obj.int")); 356 CompileRun(FN_WARMUP("callbackint", "return obj.int"));
357 ExpectInt32("callbackint()", 12345); 357 ExpectInt32("callbackint()", 12345);
358 358
359 CompileRun(FN_WARMUP("callbackstr", "return obj.str")); 359 CompileRun(FN_WARMUP("callbackstr", "return obj.str"));
360 ExpectString("callbackstr()", kApiCallbackStringValue); 360 ExpectString("callbackstr()", kApiCallbackStringValue);
361 361
362 CompileRun(FN_WARMUP("callbackparam", "return obj.param")); 362 CompileRun(FN_WARMUP("callbackparam", "return obj.param"));
363 ExpectInt32("callbackparam()", 1000); 363 ExpectInt32("callbackparam()", 1000);
364 } 364 }
OLDNEW
« no previous file with comments | « src/fast-accessor-assembler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698