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

Unified Diff: src/accessors.cc

Issue 2449783006: Add a native data property that replaces itself with a real data property (Closed)
Patch Set: Created 4 years, 2 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
« no previous file with comments | « src/accessors.h ('k') | src/api.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/accessors.cc
diff --git a/src/accessors.cc b/src/accessors.cc
index 09a38e10063d12550292e5bf6bcb06a85c408e4f..c6f52fa95529700c59e27bcf0480fbfee77a071a 100644
--- a/src/accessors.cc
+++ b/src/accessors.cc
@@ -21,7 +21,8 @@ namespace internal {
Handle<AccessorInfo> Accessors::MakeAccessor(
Isolate* isolate, Handle<Name> name, AccessorNameGetterCallback getter,
- AccessorNameBooleanSetterCallback setter, PropertyAttributes attributes) {
+ AccessorNameBooleanSetterCallback setter, PropertyAttributes attributes,
+ bool replace_on_access) {
Factory* factory = isolate->factory();
Handle<AccessorInfo> info = factory->NewAccessorInfo();
info->set_property_attributes(attributes);
@@ -29,6 +30,8 @@ Handle<AccessorInfo> Accessors::MakeAccessor(
info->set_all_can_write(false);
info->set_is_special_data_property(true);
info->set_is_sloppy(false);
+ info->set_replace_on_access(replace_on_access);
+ DCHECK_IMPLIES(replace_on_access, setter == nullptr);
name = factory->InternalizeName(name);
info->set_name(*name);
Handle<Object> get = v8::FromCData(isolate, getter);
@@ -138,7 +141,7 @@ Handle<AccessorInfo> Accessors::ArgumentsIteratorInfo(
Isolate* isolate, PropertyAttributes attributes) {
Handle<Name> name = isolate->factory()->iterator_symbol();
return MakeAccessor(isolate, name, &ArgumentsIteratorGetter, nullptr,
- attributes);
+ attributes, true);
}
@@ -199,11 +202,9 @@ void Accessors::ArrayLengthSetter(
Handle<AccessorInfo> Accessors::ArrayLengthInfo(
Isolate* isolate, PropertyAttributes attributes) {
- return MakeAccessor(isolate,
- isolate->factory()->length_string(),
- &ArrayLengthGetter,
- &ArrayLengthSetter,
- attributes);
+ return MakeAccessor(isolate, isolate->factory()->length_string(),
+ &ArrayLengthGetter, &ArrayLengthSetter, attributes,
+ false);
}
//
@@ -247,7 +248,7 @@ void Accessors::ModuleNamespaceEntrySetter(
Handle<AccessorInfo> Accessors::ModuleNamespaceEntryInfo(
Isolate* isolate, Handle<String> name, PropertyAttributes attributes) {
return MakeAccessor(isolate, name, &ModuleNamespaceEntryGetter,
- &ModuleNamespaceEntrySetter, attributes);
+ &ModuleNamespaceEntrySetter, attributes, false);
}
@@ -283,7 +284,7 @@ void Accessors::StringLengthGetter(
Handle<AccessorInfo> Accessors::StringLengthInfo(
Isolate* isolate, PropertyAttributes attributes) {
return MakeAccessor(isolate, isolate->factory()->length_string(),
- &StringLengthGetter, nullptr, attributes);
+ &StringLengthGetter, nullptr, attributes, false);
}
@@ -310,7 +311,7 @@ Handle<AccessorInfo> Accessors::ScriptColumnOffsetInfo(
Handle<String> name(isolate->factory()->InternalizeOneByteString(
STATIC_CHAR_VECTOR("column_offset")));
return MakeAccessor(isolate, name, &ScriptColumnOffsetGetter, nullptr,
- attributes);
+ attributes, false);
}
@@ -335,7 +336,8 @@ Handle<AccessorInfo> Accessors::ScriptIdInfo(
Isolate* isolate, PropertyAttributes attributes) {
Handle<String> name(
isolate->factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("id")));
- return MakeAccessor(isolate, name, &ScriptIdGetter, nullptr, attributes);
+ return MakeAccessor(isolate, name, &ScriptIdGetter, nullptr, attributes,
+ false);
}
@@ -359,7 +361,7 @@ void Accessors::ScriptNameGetter(
Handle<AccessorInfo> Accessors::ScriptNameInfo(
Isolate* isolate, PropertyAttributes attributes) {
return MakeAccessor(isolate, isolate->factory()->name_string(),
- &ScriptNameGetter, nullptr, attributes);
+ &ScriptNameGetter, nullptr, attributes, false);
}
@@ -383,7 +385,7 @@ void Accessors::ScriptSourceGetter(
Handle<AccessorInfo> Accessors::ScriptSourceInfo(
Isolate* isolate, PropertyAttributes attributes) {
return MakeAccessor(isolate, isolate->factory()->source_string(),
- &ScriptSourceGetter, nullptr, attributes);
+ &ScriptSourceGetter, nullptr, attributes, false);
}
@@ -410,7 +412,7 @@ Handle<AccessorInfo> Accessors::ScriptLineOffsetInfo(
Handle<String> name(isolate->factory()->InternalizeOneByteString(
STATIC_CHAR_VECTOR("line_offset")));
return MakeAccessor(isolate, name, &ScriptLineOffsetGetter, nullptr,
- attributes);
+ attributes, false);
}
@@ -436,7 +438,8 @@ Handle<AccessorInfo> Accessors::ScriptTypeInfo(
Isolate* isolate, PropertyAttributes attributes) {
Handle<String> name(
isolate->factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("type")));
- return MakeAccessor(isolate, name, &ScriptTypeGetter, nullptr, attributes);
+ return MakeAccessor(isolate, name, &ScriptTypeGetter, nullptr, attributes,
+ false);
}
@@ -463,7 +466,7 @@ Handle<AccessorInfo> Accessors::ScriptCompilationTypeInfo(
Handle<String> name(isolate->factory()->InternalizeOneByteString(
STATIC_CHAR_VECTOR("compilation_type")));
return MakeAccessor(isolate, name, &ScriptCompilationTypeGetter, nullptr,
- attributes);
+ attributes, false);
}
@@ -496,8 +499,8 @@ Handle<AccessorInfo> Accessors::ScriptLineEndsInfo(
Isolate* isolate, PropertyAttributes attributes) {
Handle<String> name(isolate->factory()->InternalizeOneByteString(
STATIC_CHAR_VECTOR("line_ends")));
- return MakeAccessor(isolate, name, &ScriptLineEndsGetter, nullptr,
- attributes);
+ return MakeAccessor(isolate, name, &ScriptLineEndsGetter, nullptr, attributes,
+ false);
}
@@ -521,7 +524,7 @@ void Accessors::ScriptSourceUrlGetter(
Handle<AccessorInfo> Accessors::ScriptSourceUrlInfo(
Isolate* isolate, PropertyAttributes attributes) {
return MakeAccessor(isolate, isolate->factory()->source_url_string(),
- &ScriptSourceUrlGetter, nullptr, attributes);
+ &ScriptSourceUrlGetter, nullptr, attributes, false);
}
@@ -546,7 +549,8 @@ void Accessors::ScriptSourceMappingUrlGetter(
Handle<AccessorInfo> Accessors::ScriptSourceMappingUrlInfo(
Isolate* isolate, PropertyAttributes attributes) {
return MakeAccessor(isolate, isolate->factory()->source_mapping_url_string(),
- &ScriptSourceMappingUrlGetter, nullptr, attributes);
+ &ScriptSourceMappingUrlGetter, nullptr, attributes,
+ false);
}
@@ -574,7 +578,7 @@ Handle<AccessorInfo> Accessors::ScriptIsEmbedderDebugScriptInfo(
Handle<String> name(isolate->factory()->InternalizeOneByteString(
STATIC_CHAR_VECTOR("is_debugger_script")));
return MakeAccessor(isolate, name, &ScriptIsEmbedderDebugScriptGetter,
- nullptr, attributes);
+ nullptr, attributes, false);
}
@@ -600,7 +604,7 @@ Handle<AccessorInfo> Accessors::ScriptContextDataInfo(
Handle<String> name(isolate->factory()->InternalizeOneByteString(
STATIC_CHAR_VECTOR("context_data")));
return MakeAccessor(isolate, name, &ScriptContextDataGetter, nullptr,
- attributes);
+ attributes, false);
}
@@ -636,7 +640,7 @@ Handle<AccessorInfo> Accessors::ScriptEvalFromScriptInfo(
Handle<String> name(isolate->factory()->InternalizeOneByteString(
STATIC_CHAR_VECTOR("eval_from_script")));
return MakeAccessor(isolate, name, &ScriptEvalFromScriptGetter, nullptr,
- attributes);
+ attributes, false);
}
@@ -666,7 +670,7 @@ Handle<AccessorInfo> Accessors::ScriptEvalFromScriptPositionInfo(
Handle<String> name(isolate->factory()->InternalizeOneByteString(
STATIC_CHAR_VECTOR("eval_from_script_position")));
return MakeAccessor(isolate, name, &ScriptEvalFromScriptPositionGetter,
- nullptr, attributes);
+ nullptr, attributes, false);
}
@@ -703,7 +707,7 @@ Handle<AccessorInfo> Accessors::ScriptEvalFromFunctionNameInfo(
Handle<String> name(isolate->factory()->InternalizeOneByteString(
STATIC_CHAR_VECTOR("eval_from_function_name")));
return MakeAccessor(isolate, name, &ScriptEvalFromFunctionNameGetter, nullptr,
- attributes);
+ attributes, false);
}
@@ -768,11 +772,9 @@ void Accessors::FunctionPrototypeSetter(
Handle<AccessorInfo> Accessors::FunctionPrototypeInfo(
Isolate* isolate, PropertyAttributes attributes) {
- return MakeAccessor(isolate,
- isolate->factory()->prototype_string(),
- &FunctionPrototypeGetter,
- &FunctionPrototypeSetter,
- attributes);
+ return MakeAccessor(isolate, isolate->factory()->prototype_string(),
+ &FunctionPrototypeGetter, &FunctionPrototypeSetter,
+ attributes, false);
}
@@ -800,8 +802,7 @@ void Accessors::FunctionLengthGetter(
Handle<AccessorInfo> Accessors::FunctionLengthInfo(
Isolate* isolate, PropertyAttributes attributes) {
return MakeAccessor(isolate, isolate->factory()->length_string(),
- &FunctionLengthGetter, &ReconfigureToDataProperty,
- attributes);
+ &FunctionLengthGetter, nullptr, attributes, true);
Toon Verwaest 2016/10/28 14:05:21 This technically all works, but it won't give good
}
@@ -824,8 +825,7 @@ void Accessors::FunctionNameGetter(
Handle<AccessorInfo> Accessors::FunctionNameInfo(
Isolate* isolate, PropertyAttributes attributes) {
return MakeAccessor(isolate, isolate->factory()->name_string(),
- &FunctionNameGetter, &ReconfigureToDataProperty,
- attributes);
+ &FunctionNameGetter, nullptr, attributes, true);
}
@@ -972,7 +972,7 @@ void Accessors::FunctionArgumentsGetter(
Handle<AccessorInfo> Accessors::FunctionArgumentsInfo(
Isolate* isolate, PropertyAttributes attributes) {
return MakeAccessor(isolate, isolate->factory()->arguments_string(),
- &FunctionArgumentsGetter, nullptr, attributes);
+ &FunctionArgumentsGetter, nullptr, attributes, false);
}
@@ -1105,7 +1105,7 @@ void Accessors::FunctionCallerGetter(
Handle<AccessorInfo> Accessors::FunctionCallerInfo(
Isolate* isolate, PropertyAttributes attributes) {
return MakeAccessor(isolate, isolate->factory()->caller_string(),
- &FunctionCallerGetter, nullptr, attributes);
+ &FunctionCallerGetter, nullptr, attributes, false);
}
@@ -1142,8 +1142,7 @@ void Accessors::BoundFunctionLengthGetter(
Handle<AccessorInfo> Accessors::BoundFunctionLengthInfo(
Isolate* isolate, PropertyAttributes attributes) {
return MakeAccessor(isolate, isolate->factory()->length_string(),
- &BoundFunctionLengthGetter, &ReconfigureToDataProperty,
- attributes);
+ &BoundFunctionLengthGetter, nullptr, attributes, true);
}
//
@@ -1169,8 +1168,7 @@ void Accessors::BoundFunctionNameGetter(
Handle<AccessorInfo> Accessors::BoundFunctionNameInfo(
Isolate* isolate, PropertyAttributes attributes) {
return MakeAccessor(isolate, isolate->factory()->name_string(),
- &BoundFunctionNameGetter, &ReconfigureToDataProperty,
- attributes);
+ &BoundFunctionNameGetter, nullptr, attributes, true);
}
//
@@ -1285,7 +1283,7 @@ Handle<AccessorInfo> Accessors::ErrorStackInfo(Isolate* isolate,
PropertyAttributes attributes) {
Handle<AccessorInfo> info =
MakeAccessor(isolate, isolate->factory()->stack_string(),
- &ErrorStackGetter, &ErrorStackSetter, attributes);
+ &ErrorStackGetter, &ErrorStackSetter, attributes, false);
return info;
}
« no previous file with comments | « src/accessors.h ('k') | src/api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698