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

Unified Diff: src/api.cc

Issue 1474543004: Implement Fast Accessor Builder (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Review feedback: Seperate types for value + label ids. Created 5 years, 1 month 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/api.cc
diff --git a/src/api.cc b/src/api.cc
index 8203614ef27f4b42afdc951e1c3beb2bed4aa7ce..0058a713ff7faf6efe9f126e64643a483633cdd4 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -23,6 +23,7 @@
#include "src/char-predicates-inl.h"
#include "src/code-stubs.h"
#include "src/compiler.h"
+#include "src/compiler/fast-accessor-assembler.h"
#include "src/context-measure.h"
#include "src/contexts.h"
#include "src/conversions-inl.h"
@@ -997,7 +998,7 @@ void FunctionTemplate::Inherit(v8::Local<FunctionTemplate> value) {
static Local<FunctionTemplate> FunctionTemplateNew(
i::Isolate* isolate, FunctionCallback callback,
- v8::Local<Value> fast_handler, v8::Local<Value> data,
+ experimental::FastAccessorBuilder* fast_handler, v8::Local<Value> data,
v8::Local<Signature> signature, int length, bool do_not_cache) {
i::Handle<i::Struct> struct_obj =
isolate->factory()->NewStruct(i::FUNCTION_TEMPLATE_INFO_TYPE);
@@ -1038,14 +1039,15 @@ Local<FunctionTemplate> FunctionTemplate::New(Isolate* isolate,
DCHECK(!i_isolate->serializer_enabled());
LOG_API(i_isolate, "FunctionTemplate::New");
ENTER_V8(i_isolate);
- return FunctionTemplateNew(i_isolate, callback, v8::Local<Value>(), data,
- signature, length, false);
+ return FunctionTemplateNew(i_isolate, callback, nullptr, data, signature,
+ length, false);
}
Local<FunctionTemplate> FunctionTemplate::NewWithFastHandler(
- Isolate* isolate, FunctionCallback callback, v8::Local<Value> fast_handler,
- v8::Local<Value> data, v8::Local<Signature> signature, int length) {
+ Isolate* isolate, FunctionCallback callback,
+ experimental::FastAccessorBuilder* fast_handler, v8::Local<Value> data,
+ v8::Local<Signature> signature, int length) {
// TODO(vogelheim): 'fast_handler' should have a more specific type than
// Local<Value>.
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
@@ -1110,9 +1112,9 @@ int TypeSwitch::match(v8::Local<Value> value) {
} while (false)
-void FunctionTemplate::SetCallHandler(FunctionCallback callback,
- v8::Local<Value> data,
- v8::Local<Value> fast_handler) {
+void FunctionTemplate::SetCallHandler(
+ FunctionCallback callback, v8::Local<Value> data,
+ experimental::FastAccessorBuilder* fast_handler) {
auto info = Utils::OpenHandle(this);
EnsureNotInstantiated(info, "v8::FunctionTemplate::SetCallHandler");
i::Isolate* isolate = info->GetIsolate();
@@ -1123,10 +1125,13 @@ void FunctionTemplate::SetCallHandler(FunctionCallback callback,
i::Handle<i::CallHandlerInfo> obj =
i::Handle<i::CallHandlerInfo>::cast(struct_obj);
SET_FIELD_WRAPPED(obj, set_callback, callback);
- if (!fast_handler.IsEmpty()) {
- i::Handle<i::Object> code = Utils::OpenHandle(*fast_handler);
- CHECK(code->IsCode());
+ if (fast_handler != nullptr) {
+ auto faa = *reinterpret_cast<internal::compiler::FastAccessorAssembler**>(
+ fast_handler);
+ i::Handle<i::Code> code = faa->Build();
+ CHECK(!code.is_null());
obj->set_fast_handler(*code);
+ delete fast_handler;
}
if (data.IsEmpty()) {
data = v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate));
@@ -4390,7 +4395,7 @@ MaybeLocal<Function> Function::New(Local<Context> context,
i::Isolate* isolate = Utils::OpenHandle(*context)->GetIsolate();
LOG_API(isolate, "Function::New");
ENTER_V8(isolate);
- return FunctionTemplateNew(isolate, callback, Local<Value>(), data,
+ return FunctionTemplateNew(isolate, callback, nullptr, data,
Local<Signature>(), length, true)
->GetFunction(context);
}
@@ -8369,6 +8374,60 @@ void Testing::DeoptimizeAll() {
}
+namespace experimental {
+
+
+FastAccessorBuilder::FastAccessorBuilder() : impl_(nullptr) {}
+
+
+FastAccessorBuilder::~FastAccessorBuilder() {
+ CHECK_NOT_NULL(impl_);
+ delete reinterpret_cast<internal::compiler::FastAccessorAssembler*>(impl_);
+}
+
+
+FastAccessorBuilder* FastAccessorBuilder::New(Isolate* isolate) {
+ i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
+ internal::compiler::FastAccessorAssembler* faa =
+ new internal::compiler::FastAccessorAssembler(i_isolate);
+ FastAccessorBuilder* fab = new FastAccessorBuilder;
+ fab->impl_ = faa;
+ return fab;
+}
+
+FastAccessorBuilder::ValueId FastAccessorBuilder::IntegerConstant(
+ int const_value) {
+ return reinterpret_cast<internal::compiler::FastAccessorAssembler*>(impl_)
+ ->IntegerConstant(const_value);
+}
+
+
+void FastAccessorBuilder::ReturnValue(ValueId value) {
+ reinterpret_cast<internal::compiler::FastAccessorAssembler*>(impl_)
+ ->ReturnValue(value);
+}
+
+
+FastAccessorBuilder::ValueId FastAccessorBuilder::GetCallTarget() {
+ return reinterpret_cast<internal::compiler::FastAccessorAssembler*>(impl_)
+ ->GetCallTarget();
+}
+
+FastAccessorBuilder::ValueId FastAccessorBuilder::GetParameter(
+ size_t parameter_no) {
+ return reinterpret_cast<internal::compiler::FastAccessorAssembler*>(impl_)
+ ->GetParameter(parameter_no);
+}
+
+FastAccessorBuilder::ValueId FastAccessorBuilder::GetInternalField(
+ ValueId value, int field_no) {
+ return reinterpret_cast<internal::compiler::FastAccessorAssembler*>(impl_)
+ ->GetInternalField(value, field_no);
+}
+
+} // namespace experimental
+
+
namespace internal {

Powered by Google App Engine
This is Rietveld 408576698