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 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 parameter_count_with_receiver - 1); // Implicit undefined receiver. | 312 parameter_count_with_receiver - 1); // Implicit undefined receiver. |
313 return function; | 313 return function; |
314 } | 314 } |
315 | 315 |
316 } // namespace | 316 } // namespace |
317 | 317 |
318 TEST(JSFunction) { | 318 TEST(JSFunction) { |
319 const int kNumParams = 3; // Receiver, left, right. | 319 const int kNumParams = 3; // Receiver, left, right. |
320 Isolate* isolate(CcTest::InitIsolateOnce()); | 320 Isolate* isolate(CcTest::InitIsolateOnce()); |
321 CodeStubAssemblerTester m(isolate, kNumParams); | 321 CodeStubAssemblerTester m(isolate, kNumParams); |
322 m.Return(m.SmiTag( | 322 m.Return(m.SmiTag(m.Int32Add(m.SmiToWord32(m.Parameter(1)), |
323 m.Int32Add(m.SmiToInt32(m.Parameter(1)), m.SmiToInt32(m.Parameter(2))))); | 323 m.SmiToWord32(m.Parameter(2))))); |
324 Handle<Code> code = m.GenerateCode(); | 324 Handle<Code> code = m.GenerateCode(); |
325 Handle<JSFunction> function = CreateFunctionFromCode(kNumParams, code); | 325 Handle<JSFunction> function = CreateFunctionFromCode(kNumParams, code); |
326 Handle<Object> args[] = {Handle<Smi>(Smi::FromInt(23), isolate), | 326 Handle<Object> args[] = {Handle<Smi>(Smi::FromInt(23), isolate), |
327 Handle<Smi>(Smi::FromInt(34), isolate)}; | 327 Handle<Smi>(Smi::FromInt(34), isolate)}; |
328 MaybeHandle<Object> result = | 328 MaybeHandle<Object> result = |
329 Execution::Call(isolate, function, isolate->factory()->undefined_value(), | 329 Execution::Call(isolate, function, isolate->factory()->undefined_value(), |
330 arraysize(args), args); | 330 arraysize(args), args); |
331 CHECK_EQ(57, Handle<Smi>::cast(result.ToHandleChecked())->value()); | 331 CHECK_EQ(57, Handle<Smi>::cast(result.ToHandleChecked())->value()); |
332 } | 332 } |
333 | 333 |
(...skipping 23 matching lines...) Expand all 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 |