| 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 <utility> | 5 #include <utility> |
| 6 | 6 |
| 7 #include "src/v8.h" | 7 #include "src/v8.h" |
| 8 | 8 |
| 9 #include "src/compiler/pipeline.h" | 9 #include "src/compiler/pipeline.h" |
| 10 #include "src/execution.h" | 10 #include "src/execution.h" |
| 11 #include "src/handles.h" | 11 #include "src/handles.h" |
| 12 #include "src/interpreter/bytecode-array-builder.h" | 12 #include "src/interpreter/bytecode-array-builder.h" |
| 13 #include "src/interpreter/interpreter.h" | 13 #include "src/interpreter/interpreter.h" |
| 14 #include "src/parser.h" | 14 #include "src/parser.h" |
| 15 #include "test/cctest/cctest.h" | 15 #include "test/cctest/cctest.h" |
| 16 | 16 |
| 17 namespace v8 { | 17 namespace v8 { |
| 18 namespace internal { | 18 namespace internal { |
| 19 namespace compiler { | 19 namespace compiler { |
| 20 | 20 |
| 21 | 21 |
| 22 static const char kFunctionName[] = "f"; | 22 static const char kFunctionName[] = "f"; |
| 23 | 23 |
| 24 | 24 |
| 25 static MaybeHandle<Object> CallFunction(Isolate* isolate, | 25 static MaybeHandle<Object> CallFunction(Isolate* isolate, |
| 26 Handle<JSFunction> function) { | 26 Handle<JSFunction> function) { |
| 27 return Execution::Call(isolate, function, | 27 return Execution::Call(isolate, function, |
| 28 isolate->factory()->undefined_value(), 0, nullptr); | 28 isolate->factory()->undefined_value(), 0, nullptr, |
| 29 false); |
| 29 } | 30 } |
| 30 | 31 |
| 31 | 32 |
| 32 template <class... A> | 33 template <class... A> |
| 33 static MaybeHandle<Object> CallFunction(Isolate* isolate, | 34 static MaybeHandle<Object> CallFunction(Isolate* isolate, |
| 34 Handle<JSFunction> function, | 35 Handle<JSFunction> function, |
| 35 A... args) { | 36 A... args) { |
| 36 Handle<Object> argv[] = {args...}; | 37 Handle<Object> argv[] = {args...}; |
| 37 return Execution::Call(isolate, function, | 38 return Execution::Call(isolate, function, |
| 38 isolate->factory()->undefined_value(), sizeof...(args), | 39 isolate->factory()->undefined_value(), sizeof...(args), |
| 39 argv); | 40 argv, false); |
| 40 } | 41 } |
| 41 | 42 |
| 42 | 43 |
| 43 template <class... A> | 44 template <class... A> |
| 44 class BytecodeGraphCallable { | 45 class BytecodeGraphCallable { |
| 45 public: | 46 public: |
| 46 BytecodeGraphCallable(Isolate* isolate, Handle<JSFunction> function) | 47 BytecodeGraphCallable(Isolate* isolate, Handle<JSFunction> function) |
| 47 : isolate_(isolate), function_(function) {} | 48 : isolate_(isolate), function_(function) {} |
| 48 virtual ~BytecodeGraphCallable() {} | 49 virtual ~BytecodeGraphCallable() {} |
| 49 | 50 |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 snippets[i].code_snippet, kFunctionName); | 250 snippets[i].code_snippet, kFunctionName); |
| 250 | 251 |
| 251 BytecodeGraphTester tester(isolate, zone, script.start()); | 252 BytecodeGraphTester tester(isolate, zone, script.start()); |
| 252 auto callable = tester.GetCallable<Handle<Object>, Handle<Object>>(); | 253 auto callable = tester.GetCallable<Handle<Object>, Handle<Object>>(); |
| 253 Handle<Object> return_value = | 254 Handle<Object> return_value = |
| 254 callable(snippets[i].parameter(0), snippets[i].parameter(1)) | 255 callable(snippets[i].parameter(0), snippets[i].parameter(1)) |
| 255 .ToHandleChecked(); | 256 .ToHandleChecked(); |
| 256 CHECK(return_value->SameValue(*snippets[i].return_value())); | 257 CHECK(return_value->SameValue(*snippets[i].return_value())); |
| 257 } | 258 } |
| 258 } | 259 } |
| OLD | NEW |