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

Unified Diff: src/compiler/ffi-compiler.h

Issue 2084663004: WIP: prototype ffi support Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: src/compiler/ffi-compiler.h
diff --git a/src/compiler/ffi-compiler.h b/src/compiler/ffi-compiler.h
new file mode 100644
index 0000000000000000000000000000000000000000..1abe4ac997a8ba2d44e46057dba044352ef55c52
--- /dev/null
+++ b/src/compiler/ffi-compiler.h
@@ -0,0 +1,117 @@
+// Copyright 2016 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef V8_COMPILER_FFI_COMPILER_H_
+#define V8_COMPILER_FFI_COMPILER_H_
+
+// Clients of this interface shouldn't depend on lots of compiler internals.
+// Do not include anything from src/compiler here!
+#include "src/compiler.h"
+#include "src/machine-type.h"
+#include "src/zone.h"
+
+namespace v8 {
+namespace internal {
+
+namespace compiler {
+// Forward declarations for some compiler data structures.
+class Node;
+class JSGraph;
+class Graph;
+class Operator;
+class SourcePositionTable;
+}
+
+namespace ffi {
+
+struct NativeFunction {
+ MachineSignature* sig;
+ uint8_t* start;
+};
+}
+
+namespace compiler {
+Handle<JSFunction> CompileJSToNativeWrapper(Isolate* isolate,
+ Handle<String> name,
+ ffi::NativeFunction func);
+
+class FFIGraphBuilder {
+ public:
+ FFIGraphBuilder(Zone* z, JSGraph* g);
+
+ Node** Buffer(size_t count) {
+ if (count > cur_bufsize_) {
+ size_t new_size = count + cur_bufsize_ + 5;
+ cur_buffer_ =
+ reinterpret_cast<Node**>(zone_->New(new_size * sizeof(Node*)));
+ cur_bufsize_ = new_size;
+ }
+ return cur_buffer_;
+ }
+
+ Node* Start(unsigned params);
+
+ void BuildJSToNativeWrapper(ffi::NativeFunction func);
+
+ Node* ToJS(Node* node, Node* context, MachineType type);
+ Node* FromJS(Node* node, Node* context, MachineType type);
+
+ static void PrintDebugName(Node* node);
+
+ Node* Control() { return *control_; }
+ Node* Effect() { return *effect_; }
+
+ // void set_module(wasm::ModuleEnv* module) { this->module_ = module; }
+
+ void set_control_ptr(Node** control) { this->control_ = control; }
+
+ void set_effect_ptr(Node** effect) { this->effect_ = effect; }
+
+ private:
+ static const int kDefaultBufferSize = 16;
+
+ Zone* zone_;
+ JSGraph* jsgraph_;
+ Node** control_;
+ Node** effect_;
+ Node** cur_buffer_;
+ size_t cur_bufsize_;
+ Node* def_buffer_[kDefaultBufferSize];
+
+ SetOncePointer<const Operator> allocate_heap_number_operator_;
+
+ // Internal helper methods.
+ JSGraph* jsgraph() { return jsgraph_; }
+ Graph* graph();
+
+ Node* BuildCCall(MachineSignature* sig, Node** args);
+
+ Node* BuildJavaScriptToNumber(Node* node, Node* context, Node* effect,
+ Node* control);
+ Node* BuildChangeInt32ToTagged(Node* value);
+ Node* BuildChangeFloat64ToTagged(Node* value);
+ Node* BuildChangeTaggedToFloat64(Node* value);
+ Node* BuildChangeTaggedToInt32(Node* value);
+
+ Node* BuildChangeInt32ToSmi(Node* value);
+ Node* BuildChangeSmiToInt32(Node* value);
+ Node* BuildChangeSmiToFloat64(Node* value);
+ Node* BuildTestNotSmi(Node* value);
+ Node* BuildSmiShiftBitsConstant();
+
+ Node* BuildAllocateHeapNumberWithValue(Node* value, Node* control);
+ Node* BuildLoadHeapNumberValue(Node* value, Node* control);
+ Node* BuildHeapNumberValueIndexConstant();
+
+ Node** Realloc(Node** buffer, size_t old_count, size_t new_count) {
+ Node** buf = Buffer(new_count);
+ if (buf != buffer) memcpy(buf, buffer, old_count * sizeof(Node*));
+ return buf;
+ }
+};
+} // namespace compiler
+} // namespace internal
+} // namespace v8
+
+#endif // V8_COMPILER_FFI_COMPILER_H_
« no previous file with comments | « BUILD.gn ('k') | src/compiler/ffi-compiler.cc » ('j') | src/compiler/ffi-compiler.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698