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

Side by Side Diff: test/cctest/compiler/test-code-stub-assembler.cc

Issue 1989363004: [turbofan] Add FixedArray peephole optimizations to CodeStubAssembler (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Final review feedback Created 4 years, 7 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
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 "src/interface-descriptors.h" 5 #include "src/interface-descriptors.h"
6 #include "src/isolate.h" 6 #include "src/isolate.h"
7 #include "test/cctest/compiler/function-tester.h" 7 #include "test/cctest/compiler/function-tester.h"
8 8
9 namespace v8 { 9 namespace v8 {
10 namespace internal { 10 namespace internal {
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 DCHECK_EQ(temp, var1.value()); 239 DCHECK_EQ(temp, var1.value());
240 m.Return(temp); 240 m.Return(temp);
241 } 241 }
242 242
243 TEST(FixedArrayAccessSmiIndex) { 243 TEST(FixedArrayAccessSmiIndex) {
244 Isolate* isolate(CcTest::InitIsolateOnce()); 244 Isolate* isolate(CcTest::InitIsolateOnce());
245 VoidDescriptor descriptor(isolate); 245 VoidDescriptor descriptor(isolate);
246 CodeStubAssemblerTester m(isolate, descriptor); 246 CodeStubAssemblerTester m(isolate, descriptor);
247 Handle<FixedArray> array = isolate->factory()->NewFixedArray(5); 247 Handle<FixedArray> array = isolate->factory()->NewFixedArray(5);
248 array->set(4, Smi::FromInt(733)); 248 array->set(4, Smi::FromInt(733));
249 m.Return(m.LoadFixedArrayElementSmiIndex(m.HeapConstant(array), 249 m.Return(m.LoadFixedArrayElement(m.HeapConstant(array),
250 m.SmiTag(m.Int32Constant(4)))); 250 m.SmiTag(m.Int32Constant(4)), 0,
251 CodeStubAssembler::SMI_PARAMETERS));
251 Handle<Code> code = m.GenerateCode(); 252 Handle<Code> code = m.GenerateCode();
252 FunctionTester ft(descriptor, code); 253 FunctionTester ft(descriptor, code);
253 MaybeHandle<Object> result = ft.Call(); 254 MaybeHandle<Object> result = ft.Call();
254 CHECK_EQ(733, Handle<Smi>::cast(result.ToHandleChecked())->value()); 255 CHECK_EQ(733, Handle<Smi>::cast(result.ToHandleChecked())->value());
255 } 256 }
256 257
257 TEST(LoadHeapNumberValue) { 258 TEST(LoadHeapNumberValue) {
258 Isolate* isolate(CcTest::InitIsolateOnce()); 259 Isolate* isolate(CcTest::InitIsolateOnce());
259 VoidDescriptor descriptor(isolate); 260 VoidDescriptor descriptor(isolate);
260 CodeStubAssemblerTester m(isolate, descriptor); 261 CodeStubAssemblerTester m(isolate, descriptor);
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 m.Bind(&l3); 355 m.Bind(&l3);
355 m.Switch(m.Int32Constant(2), &default_label, values, labels, 2); 356 m.Switch(m.Int32Constant(2), &default_label, values, labels, 2);
356 m.Bind(&l1); 357 m.Bind(&l1);
357 m.Goto(&l2); 358 m.Goto(&l2);
358 m.Bind(&l2); 359 m.Bind(&l2);
359 m.Goto(&default_label); 360 m.Goto(&default_label);
360 m.Bind(&default_label); 361 m.Bind(&default_label);
361 USE(m.GenerateCode()); 362 USE(m.GenerateCode());
362 } 363 }
363 364
365 TEST(TestToConstant) {
366 Isolate* isolate(CcTest::InitIsolateOnce());
367 VoidDescriptor descriptor(isolate);
368 CodeStubAssemblerTester m(isolate, descriptor);
369 int32_t value32;
370 int64_t value64;
371 Node* a = m.Int32Constant(5);
372 CHECK(m.ToInt32Constant(a, value32));
373 CHECK(m.ToInt64Constant(a, value64));
374
375 a = m.Int64Constant(static_cast<int64_t>(1) << 32);
376 CHECK(!m.ToInt32Constant(a, value32));
377 CHECK(m.ToInt64Constant(a, value64));
378
379 a = m.Int64Constant(13);
380 CHECK(m.ToInt32Constant(a, value32));
381 CHECK(m.ToInt64Constant(a, value64));
382
383 a = m.UndefinedConstant();
384 CHECK(!m.ToInt32Constant(a, value32));
385 CHECK(!m.ToInt64Constant(a, value64));
386
387 a = m.UndefinedConstant();
388 CHECK(!m.ToInt32Constant(a, value32));
389 CHECK(!m.ToInt64Constant(a, value64));
390 }
391
364 } // namespace compiler 392 } // namespace compiler
365 } // namespace internal 393 } // namespace internal
366 } // namespace v8 394 } // namespace v8
OLDNEW
« no previous file with comments | « src/interpreter/interpreter-assembler.cc ('k') | test/unittests/interpreter/interpreter-assembler-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698