OLD | NEW |
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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 MaybeHandle<Object> result = ft.Call(); | 68 MaybeHandle<Object> result = ft.Call(); |
69 CHECK_EQ(0.5, Handle<HeapNumber>::cast(result.ToHandleChecked())->value()); | 69 CHECK_EQ(0.5, Handle<HeapNumber>::cast(result.ToHandleChecked())->value()); |
70 } | 70 } |
71 | 71 |
72 | 72 |
73 TEST(SimpleCallRuntime1Arg) { | 73 TEST(SimpleCallRuntime1Arg) { |
74 Isolate* isolate(CcTest::InitIsolateOnce()); | 74 Isolate* isolate(CcTest::InitIsolateOnce()); |
75 VoidDescriptor descriptor(isolate); | 75 VoidDescriptor descriptor(isolate); |
76 CodeStubAssemblerTester m(isolate, descriptor); | 76 CodeStubAssemblerTester m(isolate, descriptor); |
77 Node* context = m.HeapConstant(Handle<Context>(isolate->native_context())); | 77 Node* context = m.HeapConstant(Handle<Context>(isolate->native_context())); |
78 Node* b = m.SmiTag(m.Int32Constant(256)); | 78 Node* b = m.SmiTag(m.Int32Constant(-1)); |
79 m.Return(m.CallRuntime(Runtime::kRoundNumber, context, b)); | 79 m.Return(m.CallRuntime(Runtime::kMathClz32, context, b)); |
80 Handle<Code> code = m.GenerateCode(); | 80 Handle<Code> code = m.GenerateCode(); |
81 FunctionTester ft(descriptor, code); | 81 FunctionTester ft(descriptor, code); |
82 MaybeHandle<Object> result = ft.Call(); | 82 MaybeHandle<Object> result = ft.Call(); |
83 CHECK_EQ(256, Handle<Smi>::cast(result.ToHandleChecked())->value()); | 83 CHECK_EQ(0, Handle<Smi>::cast(result.ToHandleChecked())->value()); |
84 } | 84 } |
85 | 85 |
86 | 86 |
87 TEST(SimpleTailCallRuntime1Arg) { | 87 TEST(SimpleTailCallRuntime1Arg) { |
88 Isolate* isolate(CcTest::InitIsolateOnce()); | 88 Isolate* isolate(CcTest::InitIsolateOnce()); |
89 VoidDescriptor descriptor(isolate); | 89 VoidDescriptor descriptor(isolate); |
90 CodeStubAssemblerTester m(isolate, descriptor); | 90 CodeStubAssemblerTester m(isolate, descriptor); |
91 Node* context = m.HeapConstant(Handle<Context>(isolate->native_context())); | 91 Node* context = m.HeapConstant(Handle<Context>(isolate->native_context())); |
92 Node* b = m.SmiTag(m.Int32Constant(256)); | 92 Node* b = m.SmiTag(m.Int32Constant(-1)); |
93 m.TailCallRuntime(Runtime::kRoundNumber, context, b); | 93 m.TailCallRuntime(Runtime::kMathClz32, context, b); |
94 Handle<Code> code = m.GenerateCode(); | 94 Handle<Code> code = m.GenerateCode(); |
95 FunctionTester ft(descriptor, code); | 95 FunctionTester ft(descriptor, code); |
96 MaybeHandle<Object> result = ft.Call(); | 96 MaybeHandle<Object> result = ft.Call(); |
97 CHECK_EQ(256, Handle<Smi>::cast(result.ToHandleChecked())->value()); | 97 CHECK_EQ(0, Handle<Smi>::cast(result.ToHandleChecked())->value()); |
98 } | 98 } |
99 | 99 |
100 | 100 |
101 TEST(SimpleCallRuntime2Arg) { | 101 TEST(SimpleCallRuntime2Arg) { |
102 Isolate* isolate(CcTest::InitIsolateOnce()); | 102 Isolate* isolate(CcTest::InitIsolateOnce()); |
103 VoidDescriptor descriptor(isolate); | 103 VoidDescriptor descriptor(isolate); |
104 CodeStubAssemblerTester m(isolate, descriptor); | 104 CodeStubAssemblerTester m(isolate, descriptor); |
105 Node* context = m.HeapConstant(Handle<Context>(isolate->native_context())); | 105 Node* context = m.HeapConstant(Handle<Context>(isolate->native_context())); |
106 Node* a = m.SmiTag(m.Int32Constant(2)); | 106 Node* a = m.SmiTag(m.Int32Constant(2)); |
107 Node* b = m.SmiTag(m.Int32Constant(4)); | 107 Node* b = m.SmiTag(m.Int32Constant(4)); |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 m.Goto(&l2); | 357 m.Goto(&l2); |
358 m.Bind(&l2); | 358 m.Bind(&l2); |
359 m.Goto(&default_label); | 359 m.Goto(&default_label); |
360 m.Bind(&default_label); | 360 m.Bind(&default_label); |
361 USE(m.GenerateCode()); | 361 USE(m.GenerateCode()); |
362 } | 362 } |
363 | 363 |
364 } // namespace compiler | 364 } // namespace compiler |
365 } // namespace internal | 365 } // namespace internal |
366 } // namespace v8 | 366 } // namespace v8 |
OLD | NEW |