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

Side by Side Diff: test/cctest/ffi/test-ffi.cc

Issue 2607993003: FFI Compiler based on code stub assembler (Closed)
Patch Set: Move FFIAssembler from .h to .cc Created 3 years, 11 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 | « test/cctest/ffi/OWNERS ('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
(Empty)
1 // Copyright 2017 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "src/codegen.h"
6 #include "src/ffi/ffi-compiler.h"
7 #include "test/cctest/cctest.h"
8
9 namespace v8 {
10 namespace internal {
11 namespace ffi {
12
13 static void hello_world() { printf("hello world from native code\n"); }
14
15 TEST(Run_FFI_Hello) {
16 Isolate* isolate = CcTest::InitIsolateOnce();
17 HandleScope scope(isolate);
18
19 Handle<String> name =
20 isolate->factory()->InternalizeUtf8String("hello_world");
21 Handle<Object> undefined = isolate->factory()->undefined_value();
22
23 AccountingAllocator allocator;
24 Zone zone(&allocator, ZONE_NAME);
25 FFISignature::Builder sig_builder(&zone, 0, 0);
26 NativeFunction func = {sig_builder.Build(),
27 reinterpret_cast<uint8_t*>(hello_world)};
28
29 Handle<JSFunction> jsfunc = CompileJSToNativeWrapper(isolate, name, func);
30
31 Handle<Object> result =
32 Execution::Call(isolate, jsfunc, undefined, 0, nullptr).ToHandleChecked();
33
34 CHECK(result->IsUndefined(isolate));
35 }
36
37 } // namespace ffi
38 } // namespace internal
39 } // namespace v8
OLDNEW
« no previous file with comments | « test/cctest/ffi/OWNERS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698