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

Unified Diff: src/api.cc

Issue 2741683004: [rename] Rename internal field to embedder field. (Closed)
Patch Set: DEPRECATE_SOON(GetInternalField) Created 3 years, 9 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/api.cc
diff --git a/src/api.cc b/src/api.cc
index 38668efba1c616cacd3cb8f98a86867163333d9c..d748585ee6276a7d03fa4174392ada6a8ee69ac9 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -496,7 +496,7 @@ struct SnapshotCreatorData {
Persistent<Context> default_context_;
PersistentValueVector<Context> contexts_;
PersistentValueVector<Template> templates_;
- std::vector<SerializeInternalFieldsCallback> internal_fields_serializers_;
+ std::vector<SerializeEmbedderFieldsCallback> embedder_fields_serializers_;
bool created_;
};
@@ -547,7 +547,7 @@ void SnapshotCreator::SetDefaultContext(Local<Context> context) {
}
size_t SnapshotCreator::AddContext(Local<Context> context,
- SerializeInternalFieldsCallback callback) {
+ SerializeEmbedderFieldsCallback callback) {
DCHECK(!context.IsEmpty());
SnapshotCreatorData* data = SnapshotCreatorData::cast(data_);
DCHECK(!data->created_);
@@ -555,7 +555,7 @@ size_t SnapshotCreator::AddContext(Local<Context> context,
CHECK_EQ(isolate, context->GetIsolate());
size_t index = static_cast<int>(data->contexts_.Size());
data->contexts_.Append(context);
- data->internal_fields_serializers_.push_back(callback);
+ data->embedder_fields_serializers_.push_back(callback);
return index;
}
@@ -637,16 +637,16 @@ StartupData SnapshotCreator::CreateBlob(
i::List<i::SnapshotData*> context_snapshots(num_additional_contexts + 1);
{
- // The default snapshot does not support internal fields.
+ // The default snapshot does not support embedder fields.
i::PartialSerializer partial_serializer(
- isolate, &startup_serializer, v8::SerializeInternalFieldsCallback());
+ isolate, &startup_serializer, v8::SerializeEmbedderFieldsCallback());
partial_serializer.Serialize(&default_context, false);
context_snapshots.Add(new i::SnapshotData(&partial_serializer));
}
for (int i = 0; i < num_additional_contexts; i++) {
i::PartialSerializer partial_serializer(
- isolate, &startup_serializer, data->internal_fields_serializers_[i]);
+ isolate, &startup_serializer, data->embedder_fields_serializers_[i]);
partial_serializer.Serialize(&contexts[i], true);
context_snapshots.Add(new i::SnapshotData(&partial_serializer));
}
@@ -906,19 +906,19 @@ void V8::RegisterExternallyReferencedObject(i::Object** object,
}
void V8::MakeWeak(i::Object** location, void* parameter,
- int internal_field_index1, int internal_field_index2,
+ int embedder_field_index1, int embedder_field_index2,
WeakCallbackInfo<void>::Callback weak_callback) {
WeakCallbackType type = WeakCallbackType::kParameter;
- if (internal_field_index1 == 0) {
- if (internal_field_index2 == 1) {
- type = WeakCallbackType::kInternalFields;
+ if (embedder_field_index1 == 0) {
+ if (embedder_field_index2 == 1) {
+ type = WeakCallbackType::kEmbedderFields;
} else {
- DCHECK_EQ(internal_field_index2, -1);
- type = WeakCallbackType::kInternalFields;
+ DCHECK_EQ(embedder_field_index2, -1);
+ type = WeakCallbackType::kEmbedderFields;
}
} else {
- DCHECK_EQ(internal_field_index1, -1);
- DCHECK_EQ(internal_field_index2, -1);
+ DCHECK_EQ(embedder_field_index1, -1);
+ DCHECK_EQ(embedder_field_index2, -1);
}
i::GlobalHandles::MakeWeak(location, parameter, weak_callback, type);
}
@@ -964,10 +964,9 @@ void V8::ToLocalEmpty() {
Utils::ApiCheck(false, "v8::ToLocalChecked", "Empty MaybeLocal.");
}
-
-void V8::InternalFieldOutOfBounds(int index) {
- Utils::ApiCheck(0 <= index && index < kInternalFieldsInWeakCallback,
- "WeakCallbackInfo::GetInternalField",
+void V8::EmbedderFieldOutOfBounds(int index) {
+ Utils::ApiCheck(0 <= index && index < kEmbedderFieldsInWeakCallback,
+ "WeakCallbackInfo::GetEmbedderField",
"Internal field out of bounds.");
}
@@ -1873,27 +1872,25 @@ void ObjectTemplate::SetCallAsFunctionHandler(FunctionCallback callback,
cons->set_instance_call_handler(*obj);
}
-
-int ObjectTemplate::InternalFieldCount() {
- return Utils::OpenHandle(this)->internal_field_count();
+int ObjectTemplate::EmbedderFieldCount() {
+ return Utils::OpenHandle(this)->embedder_field_count();
}
-
-void ObjectTemplate::SetInternalFieldCount(int value) {
+void ObjectTemplate::SetEmbedderFieldCount(int value) {
i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
if (!Utils::ApiCheck(i::Smi::IsValid(value),
- "v8::ObjectTemplate::SetInternalFieldCount()",
- "Invalid internal field count")) {
+ "v8::ObjectTemplate::SetEmbedderFieldCount()",
+ "Invalid embedder field count")) {
return;
}
ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate);
if (value > 0) {
- // The internal field count is set by the constructor function's
+ // The embedder field count is set by the constructor function's
// construct code, so we ensure that there is a constructor
// function to do the setting.
EnsureConstructor(isolate, this);
}
- Utils::OpenHandle(this)->set_internal_field_count(value);
+ Utils::OpenHandle(this)->set_embedder_field_count(value);
}
bool ObjectTemplate::IsImmutableProto() {
@@ -6049,76 +6046,71 @@ uint32_t Uint32::Value() const {
}
}
-
-int v8::Object::InternalFieldCount() {
+int v8::Object::EmbedderFieldCount() {
i::Handle<i::JSReceiver> self = Utils::OpenHandle(this);
if (!self->IsJSObject()) return 0;
- return i::Handle<i::JSObject>::cast(self)->GetInternalFieldCount();
+ return i::Handle<i::JSObject>::cast(self)->GetEmbedderFieldCount();
}
-
-static bool InternalFieldOK(i::Handle<i::JSReceiver> obj, int index,
+static bool EmbedderFieldOK(i::Handle<i::JSReceiver> obj, int index,
const char* location) {
return Utils::ApiCheck(
obj->IsJSObject() &&
- (index < i::Handle<i::JSObject>::cast(obj)->GetInternalFieldCount()),
+ (index < i::Handle<i::JSObject>::cast(obj)->GetEmbedderFieldCount()),
location, "Internal field out of bounds");
}
-
-Local<Value> v8::Object::SlowGetInternalField(int index) {
+Local<Value> v8::Object::SlowGetEmbedderField(int index) {
i::Handle<i::JSReceiver> obj = Utils::OpenHandle(this);
- const char* location = "v8::Object::GetInternalField()";
- if (!InternalFieldOK(obj, index, location)) return Local<Value>();
+ const char* location = "v8::Object::GetEmbedderField()";
+ if (!EmbedderFieldOK(obj, index, location)) return Local<Value>();
i::Handle<i::Object> value(
- i::Handle<i::JSObject>::cast(obj)->GetInternalField(index),
+ i::Handle<i::JSObject>::cast(obj)->GetEmbedderField(index),
obj->GetIsolate());
return Utils::ToLocal(value);
}
-
-void v8::Object::SetInternalField(int index, v8::Local<Value> value) {
+void v8::Object::SetEmbedderField(int index, v8::Local<Value> value) {
i::Handle<i::JSReceiver> obj = Utils::OpenHandle(this);
- const char* location = "v8::Object::SetInternalField()";
- if (!InternalFieldOK(obj, index, location)) return;
+ const char* location = "v8::Object::SetEmbedderField()";
+ if (!EmbedderFieldOK(obj, index, location)) return;
i::Handle<i::Object> val = Utils::OpenHandle(*value);
- i::Handle<i::JSObject>::cast(obj)->SetInternalField(index, *val);
+ i::Handle<i::JSObject>::cast(obj)->SetEmbedderField(index, *val);
}
-
-void* v8::Object::SlowGetAlignedPointerFromInternalField(int index) {
+void* v8::Object::SlowGetAlignedPointerFromEmbedderField(int index) {
i::Handle<i::JSReceiver> obj = Utils::OpenHandle(this);
- const char* location = "v8::Object::GetAlignedPointerFromInternalField()";
- if (!InternalFieldOK(obj, index, location)) return NULL;
+ const char* location = "v8::Object::GetAlignedPointerFromEmbedderField()";
+ if (!EmbedderFieldOK(obj, index, location)) return NULL;
return DecodeSmiToAligned(
- i::Handle<i::JSObject>::cast(obj)->GetInternalField(index), location);
+ i::Handle<i::JSObject>::cast(obj)->GetEmbedderField(index), location);
}
-void v8::Object::SetAlignedPointerInInternalField(int index, void* value) {
+void v8::Object::SetAlignedPointerInEmbedderField(int index, void* value) {
i::Handle<i::JSReceiver> obj = Utils::OpenHandle(this);
- const char* location = "v8::Object::SetAlignedPointerInInternalField()";
- if (!InternalFieldOK(obj, index, location)) return;
- i::Handle<i::JSObject>::cast(obj)
- ->SetInternalField(index, EncodeAlignedAsSmi(value, location));
- DCHECK_EQ(value, GetAlignedPointerFromInternalField(index));
+ const char* location = "v8::Object::SetAlignedPointerInEmbedderField()";
+ if (!EmbedderFieldOK(obj, index, location)) return;
+ i::Handle<i::JSObject>::cast(obj)->SetEmbedderField(
+ index, EncodeAlignedAsSmi(value, location));
+ DCHECK_EQ(value, GetAlignedPointerFromEmbedderField(index));
}
-void v8::Object::SetAlignedPointerInInternalFields(int argc, int indices[],
+void v8::Object::SetAlignedPointerInEmbedderFields(int argc, int indices[],
void* values[]) {
i::Handle<i::JSReceiver> obj = Utils::OpenHandle(this);
- const char* location = "v8::Object::SetAlignedPointerInInternalFields()";
+ const char* location = "v8::Object::SetAlignedPointerInEmbedderFields()";
i::DisallowHeapAllocation no_gc;
i::JSObject* object = i::JSObject::cast(*obj);
- int nof_internal_fields = object->GetInternalFieldCount();
+ int nof_embedder_fields = object->GetEmbedderFieldCount();
for (int i = 0; i < argc; i++) {
int index = indices[i];
- if (!Utils::ApiCheck(index < nof_internal_fields, location,
+ if (!Utils::ApiCheck(index < nof_embedder_fields, location,
"Internal field out of bounds")) {
return;
}
void* value = values[i];
- object->SetInternalField(index, EncodeAlignedAsSmi(value, location));
- DCHECK_EQ(value, GetAlignedPointerFromInternalField(index));
+ object->SetEmbedderField(index, EncodeAlignedAsSmi(value, location));
+ DCHECK_EQ(value, GetAlignedPointerFromEmbedderField(index));
}
}
@@ -6128,7 +6120,7 @@ static void* ExternalValue(i::Object* obj) {
obj->IsUndefined(i::HeapObject::cast(obj)->GetIsolate())) {
return NULL;
}
- i::Object* foreign = i::JSObject::cast(obj)->GetInternalField(0);
+ i::Object* foreign = i::JSObject::cast(obj)->GetEmbedderField(0);
return i::Foreign::cast(foreign)->foreign_address();
}
@@ -6234,10 +6226,10 @@ struct InvokeBootstrapper<i::Context> {
i::Isolate* isolate, i::MaybeHandle<i::JSGlobalProxy> maybe_global_proxy,
v8::Local<v8::ObjectTemplate> global_object_template,
v8::ExtensionConfiguration* extensions, size_t context_snapshot_index,
- v8::DeserializeInternalFieldsCallback internal_fields_deserializer) {
+ v8::DeserializeEmbedderFieldsCallback embedder_fields_deserializer) {
return isolate->bootstrapper()->CreateEnvironment(
maybe_global_proxy, global_object_template, extensions,
- context_snapshot_index, internal_fields_deserializer);
+ context_snapshot_index, embedder_fields_deserializer);
}
};
@@ -6247,7 +6239,7 @@ struct InvokeBootstrapper<i::JSGlobalProxy> {
i::Isolate* isolate, i::MaybeHandle<i::JSGlobalProxy> maybe_global_proxy,
v8::Local<v8::ObjectTemplate> global_object_template,
v8::ExtensionConfiguration* extensions, size_t context_snapshot_index,
- v8::DeserializeInternalFieldsCallback internal_fields_deserializer) {
+ v8::DeserializeEmbedderFieldsCallback embedder_fields_deserializer) {
USE(extensions);
USE(context_snapshot_index);
return isolate->bootstrapper()->NewRemoteContext(maybe_global_proxy,
@@ -6260,7 +6252,7 @@ static i::Handle<ObjectType> CreateEnvironment(
i::Isolate* isolate, v8::ExtensionConfiguration* extensions,
v8::MaybeLocal<ObjectTemplate> maybe_global_template,
v8::MaybeLocal<Value> maybe_global_proxy, size_t context_snapshot_index,
- v8::DeserializeInternalFieldsCallback internal_fields_deserializer) {
+ v8::DeserializeEmbedderFieldsCallback embedder_fields_deserializer) {
i::Handle<ObjectType> result;
{
@@ -6289,8 +6281,8 @@ static i::Handle<ObjectType> CreateEnvironment(
proxy_constructor->set_prototype_template(
*Utils::OpenHandle(*global_template));
- proxy_template->SetInternalFieldCount(
- global_template->InternalFieldCount());
+ proxy_template->SetEmbedderFieldCount(
+ global_template->EmbedderFieldCount());
// Migrate security handlers from global_template to
// proxy_template. Temporarily removing access check
@@ -6333,7 +6325,7 @@ static i::Handle<ObjectType> CreateEnvironment(
InvokeBootstrapper<ObjectType> invoke;
result =
invoke.Invoke(isolate, maybe_proxy, proxy_template, extensions,
- context_snapshot_index, internal_fields_deserializer);
+ context_snapshot_index, embedder_fields_deserializer);
// Restore the access check info and interceptors on the global template.
if (!maybe_global_template.IsEmpty()) {
@@ -6356,7 +6348,7 @@ Local<Context> NewContext(
v8::Isolate* external_isolate, v8::ExtensionConfiguration* extensions,
v8::MaybeLocal<ObjectTemplate> global_template,
v8::MaybeLocal<Value> global_object, size_t context_snapshot_index,
- v8::DeserializeInternalFieldsCallback internal_fields_deserializer) {
+ v8::DeserializeEmbedderFieldsCallback embedder_fields_deserializer) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(external_isolate);
TRACE_EVENT_CALL_STATS_SCOPED(isolate, "v8", "V8.NewContext");
LOG_API(isolate, Context, New);
@@ -6365,7 +6357,7 @@ Local<Context> NewContext(
if (extensions == NULL) extensions = &no_extensions;
i::Handle<i::Context> env = CreateEnvironment<i::Context>(
isolate, extensions, global_template, global_object,
- context_snapshot_index, internal_fields_deserializer);
+ context_snapshot_index, embedder_fields_deserializer);
if (env.is_null()) {
if (isolate->has_pending_exception()) isolate->clear_pending_exception();
return Local<Context>();
@@ -6378,12 +6370,12 @@ Local<Context> v8::Context::New(v8::Isolate* external_isolate,
v8::MaybeLocal<ObjectTemplate> global_template,
v8::MaybeLocal<Value> global_object) {
return NewContext(external_isolate, extensions, global_template,
- global_object, 0, DeserializeInternalFieldsCallback());
+ global_object, 0, DeserializeEmbedderFieldsCallback());
}
MaybeLocal<Context> v8::Context::FromSnapshot(
v8::Isolate* external_isolate, size_t context_snapshot_index,
- v8::DeserializeInternalFieldsCallback internal_fields_deserializer,
+ v8::DeserializeEmbedderFieldsCallback embedder_fields_deserializer,
v8::ExtensionConfiguration* extensions, MaybeLocal<Value> global_object) {
size_t index_including_default_context = context_snapshot_index + 1;
if (!i::Snapshot::HasContextSnapshot(
@@ -6393,7 +6385,7 @@ MaybeLocal<Context> v8::Context::FromSnapshot(
}
return NewContext(external_isolate, extensions, MaybeLocal<ObjectTemplate>(),
global_object, index_including_default_context,
- internal_fields_deserializer);
+ embedder_fields_deserializer);
}
MaybeLocal<Object> v8::Context::NewRemoteContext(
@@ -6416,7 +6408,7 @@ MaybeLocal<Object> v8::Context::NewRemoteContext(
i::Handle<i::JSGlobalProxy> global_proxy =
CreateEnvironment<i::JSGlobalProxy>(isolate, nullptr, global_template,
global_object, 0,
- DeserializeInternalFieldsCallback());
+ DeserializeEmbedderFieldsCallback());
if (global_proxy.is_null()) {
if (isolate->has_pending_exception()) isolate->clear_pending_exception();
return MaybeLocal<Object>();
@@ -7514,7 +7506,7 @@ Local<String> WasmCompiledModule::GetWasmWireBytes() {
i::Handle<i::JSObject> obj =
i::Handle<i::JSObject>::cast(Utils::OpenHandle(this));
i::Handle<i::WasmCompiledModule> compiled_part =
- i::handle(i::WasmCompiledModule::cast(obj->GetInternalField(0)));
+ i::handle(i::WasmCompiledModule::cast(obj->GetEmbedderField(0)));
i::Handle<i::String> wire_bytes(compiled_part->module_bytes());
return Local<String>::Cast(Utils::ToLocal(wire_bytes));
}
@@ -7523,7 +7515,7 @@ WasmCompiledModule::SerializedModule WasmCompiledModule::Serialize() {
i::Handle<i::JSObject> obj =
i::Handle<i::JSObject>::cast(Utils::OpenHandle(this));
i::Handle<i::WasmCompiledModule> compiled_part =
- i::handle(i::WasmCompiledModule::cast(obj->GetInternalField(0)));
+ i::handle(i::WasmCompiledModule::cast(obj->GetEmbedderField(0)));
std::unique_ptr<i::ScriptData> script_data =
i::WasmCompiledModuleSerializer::SerializeWasmModule(obj->GetIsolate(),
« include/v8-experimental.h ('K') | « samples/process.cc ('k') | src/api-experimental.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698