Commit 50d54ee2 authored by jochen's avatar jochen Committed by Commit bot

Rename SloppyBlockWithEvalContextExtension to ContextExtension

The plan is to also use it for With and Catch scopes, so all kinds of
contexts have a pointer back to their ScopeInfo

R=neis@chromium.org,marja@chromium.org
BUG=v8:5215

Review-Url: https://codereview.chromium.org/2301913002
Cr-Commit-Position: refs/heads/master@{#39092}
parent 69debbb5
...@@ -64,8 +64,8 @@ bool Context::is_declaration_context() { ...@@ -64,8 +64,8 @@ bool Context::is_declaration_context() {
Object* ext = extension(); Object* ext = extension();
// If we have the special extension, we immediately know it must be a // If we have the special extension, we immediately know it must be a
// declaration scope. That's just a small performance shortcut. // declaration scope. That's just a small performance shortcut.
return ext->IsSloppyBlockWithEvalContextExtension() return ext->IsContextExtension() ||
|| ScopeInfo::cast(ext)->is_declaration_scope(); ScopeInfo::cast(ext)->is_declaration_scope();
} }
...@@ -93,8 +93,8 @@ JSObject* Context::extension_object() { ...@@ -93,8 +93,8 @@ JSObject* Context::extension_object() {
HeapObject* object = extension(); HeapObject* object = extension();
if (object->IsTheHole(GetIsolate())) return nullptr; if (object->IsTheHole(GetIsolate())) return nullptr;
if (IsBlockContext()) { if (IsBlockContext()) {
if (!object->IsSloppyBlockWithEvalContextExtension()) return nullptr; if (!object->IsContextExtension()) return nullptr;
object = SloppyBlockWithEvalContextExtension::cast(object)->extension(); object = JSObject::cast(ContextExtension::cast(object)->extension());
} }
DCHECK(object->IsJSContextExtensionObject() || DCHECK(object->IsJSContextExtensionObject() ||
(IsNativeContext() && object->IsJSGlobalObject())); (IsNativeContext() && object->IsJSGlobalObject()));
...@@ -112,9 +112,9 @@ JSReceiver* Context::extension_receiver() { ...@@ -112,9 +112,9 @@ JSReceiver* Context::extension_receiver() {
ScopeInfo* Context::scope_info() { ScopeInfo* Context::scope_info() {
DCHECK(IsModuleContext() || IsScriptContext() || IsBlockContext()); DCHECK(IsModuleContext() || IsScriptContext() || IsBlockContext());
HeapObject* object = extension(); HeapObject* object = extension();
if (object->IsSloppyBlockWithEvalContextExtension()) { if (object->IsContextExtension()) {
DCHECK(IsBlockContext()); DCHECK(IsBlockContext());
object = SloppyBlockWithEvalContextExtension::cast(object)->scope_info(); object = ContextExtension::cast(object)->scope_info();
} }
return ScopeInfo::cast(object); return ScopeInfo::cast(object);
} }
......
...@@ -298,8 +298,8 @@ class ScriptContextTable : public FixedArray { ...@@ -298,8 +298,8 @@ class ScriptContextTable : public FixedArray {
// //
// [ previous ] A pointer to the previous context. // [ previous ] A pointer to the previous context.
// //
// [ extension ] A pointer to an extension JSObject, or "the hole". Used to // [ extension ] A pointer to a ContextExtension object, or "the hole". Used
// implement 'with' statements and dynamic declarations // to implement 'with' statements and dynamic declarations
// (through 'eval'). The object in a 'with' statement is // (through 'eval'). The object in a 'with' statement is
// stored in the extension slot of a 'with' context. // stored in the extension slot of a 'with' context.
// Dynamically declared variables/functions are also added // Dynamically declared variables/functions are also added
...@@ -308,8 +308,8 @@ class ScriptContextTable : public FixedArray { ...@@ -308,8 +308,8 @@ class ScriptContextTable : public FixedArray {
// For script and block contexts, contains the respective // For script and block contexts, contains the respective
// ScopeInfo. For block contexts representing sloppy declaration // ScopeInfo. For block contexts representing sloppy declaration
// block scopes, it may also be a struct being a // block scopes, it may also be a struct being a
// SloppyBlockWithEvalContextExtension, pairing the ScopeInfo // ContextExtension, pairing the ScopeInfo with an extension
// with an extension object. // object.
// //
// [ native_context ] A pointer to the native context. // [ native_context ] A pointer to the native context.
// //
......
...@@ -102,14 +102,11 @@ Handle<PrototypeInfo> Factory::NewPrototypeInfo() { ...@@ -102,14 +102,11 @@ Handle<PrototypeInfo> Factory::NewPrototypeInfo() {
return result; return result;
} }
Handle<ContextExtension> Factory::NewContextExtension(
Handle<SloppyBlockWithEvalContextExtension> Handle<ScopeInfo> scope_info, Handle<Object> extension) {
Factory::NewSloppyBlockWithEvalContextExtension(
Handle<ScopeInfo> scope_info, Handle<JSObject> extension) {
DCHECK(scope_info->is_declaration_scope()); DCHECK(scope_info->is_declaration_scope());
Handle<SloppyBlockWithEvalContextExtension> result = Handle<ContextExtension> result =
Handle<SloppyBlockWithEvalContextExtension>::cast( Handle<ContextExtension>::cast(NewStruct(CONTEXT_EXTENSION_TYPE));
NewStruct(SLOPPY_BLOCK_WITH_EVAL_CONTEXT_EXTENSION_TYPE));
result->set_scope_info(*scope_info); result->set_scope_info(*scope_info);
result->set_extension(*extension); result->set_extension(*extension);
return result; return result;
......
...@@ -64,10 +64,9 @@ class Factory final { ...@@ -64,10 +64,9 @@ class Factory final {
// Create a new PrototypeInfo struct. // Create a new PrototypeInfo struct.
Handle<PrototypeInfo> NewPrototypeInfo(); Handle<PrototypeInfo> NewPrototypeInfo();
// Create a new SloppyBlockWithEvalContextExtension struct. // Create a new ContextExtension struct.
Handle<SloppyBlockWithEvalContextExtension> Handle<ContextExtension> NewContextExtension(Handle<ScopeInfo> scope_info,
NewSloppyBlockWithEvalContextExtension(Handle<ScopeInfo> scope_info, Handle<Object> extension);
Handle<JSObject> extension);
// Create a pre-tenured empty AccessorPair. // Create a pre-tenured empty AccessorPair.
Handle<AccessorPair> NewAccessorPair(); Handle<AccessorPair> NewAccessorPair();
......
...@@ -911,10 +911,8 @@ void PrototypeInfo::PrototypeInfoVerify() { ...@@ -911,10 +911,8 @@ void PrototypeInfo::PrototypeInfoVerify() {
CHECK(validity_cell()->IsCell() || validity_cell()->IsSmi()); CHECK(validity_cell()->IsCell() || validity_cell()->IsSmi());
} }
void ContextExtension::ContextExtensionVerify() {
void SloppyBlockWithEvalContextExtension:: CHECK(IsContextExtension());
SloppyBlockWithEvalContextExtensionVerify() {
CHECK(IsSloppyBlockWithEvalContextExtension());
VerifyObjectField(kScopeInfoOffset); VerifyObjectField(kScopeInfoOffset);
VerifyObjectField(kExtensionOffset); VerifyObjectField(kExtensionOffset);
} }
......
...@@ -5692,10 +5692,8 @@ ACCESSORS(PrototypeInfo, validity_cell, Object, kValidityCellOffset) ...@@ -5692,10 +5692,8 @@ ACCESSORS(PrototypeInfo, validity_cell, Object, kValidityCellOffset)
SMI_ACCESSORS(PrototypeInfo, bit_field, kBitFieldOffset) SMI_ACCESSORS(PrototypeInfo, bit_field, kBitFieldOffset)
BOOL_ACCESSORS(PrototypeInfo, bit_field, should_be_fast_map, kShouldBeFastBit) BOOL_ACCESSORS(PrototypeInfo, bit_field, should_be_fast_map, kShouldBeFastBit)
ACCESSORS(SloppyBlockWithEvalContextExtension, scope_info, ScopeInfo, ACCESSORS(ContextExtension, scope_info, ScopeInfo, kScopeInfoOffset)
kScopeInfoOffset) ACCESSORS(ContextExtension, extension, Object, kExtensionOffset)
ACCESSORS(SloppyBlockWithEvalContextExtension, extension, JSObject,
kExtensionOffset)
ACCESSORS(AccessorPair, getter, Object, kGetterOffset) ACCESSORS(AccessorPair, getter, Object, kGetterOffset)
ACCESSORS(AccessorPair, setter, Object, kSetterOffset) ACCESSORS(AccessorPair, setter, Object, kSetterOffset)
......
...@@ -1136,10 +1136,8 @@ void PrototypeInfo::PrototypeInfoPrint(std::ostream& os) { // NOLINT ...@@ -1136,10 +1136,8 @@ void PrototypeInfo::PrototypeInfoPrint(std::ostream& os) { // NOLINT
os << "\n"; os << "\n";
} }
void ContextExtension::ContextExtensionPrint(std::ostream& os) { // NOLINT
void SloppyBlockWithEvalContextExtension:: HeapObject::PrintHeader(os, "ContextExtension");
SloppyBlockWithEvalContextExtensionPrint(std::ostream& os) { // NOLINT
HeapObject::PrintHeader(os, "SloppyBlockWithEvalContextExtension");
os << "\n - scope_info: " << Brief(scope_info()); os << "\n - scope_info: " << Brief(scope_info());
os << "\n - extension: " << Brief(extension()); os << "\n - extension: " << Brief(extension());
os << "\n"; os << "\n";
......
...@@ -395,7 +395,7 @@ const int kStubMinorKeyBits = kSmiValueSize - kStubMajorKeyBits - 1; ...@@ -395,7 +395,7 @@ const int kStubMinorKeyBits = kSmiValueSize - kStubMajorKeyBits - 1;
V(ALIASED_ARGUMENTS_ENTRY_TYPE) \ V(ALIASED_ARGUMENTS_ENTRY_TYPE) \
V(BOX_TYPE) \ V(BOX_TYPE) \
V(PROTOTYPE_INFO_TYPE) \ V(PROTOTYPE_INFO_TYPE) \
V(SLOPPY_BLOCK_WITH_EVAL_CONTEXT_EXTENSION_TYPE) \ V(CONTEXT_EXTENSION_TYPE) \
\ \
V(FIXED_ARRAY_TYPE) \ V(FIXED_ARRAY_TYPE) \
V(FIXED_DOUBLE_ARRAY_TYPE) \ V(FIXED_DOUBLE_ARRAY_TYPE) \
...@@ -513,9 +513,7 @@ const int kStubMinorKeyBits = kSmiValueSize - kStubMajorKeyBits - 1; ...@@ -513,9 +513,7 @@ const int kStubMinorKeyBits = kSmiValueSize - kStubMajorKeyBits - 1;
V(DEBUG_INFO, DebugInfo, debug_info) \ V(DEBUG_INFO, DebugInfo, debug_info) \
V(BREAK_POINT_INFO, BreakPointInfo, break_point_info) \ V(BREAK_POINT_INFO, BreakPointInfo, break_point_info) \
V(PROTOTYPE_INFO, PrototypeInfo, prototype_info) \ V(PROTOTYPE_INFO, PrototypeInfo, prototype_info) \
V(SLOPPY_BLOCK_WITH_EVAL_CONTEXT_EXTENSION, \ V(CONTEXT_EXTENSION, ContextExtension, context_extension)
SloppyBlockWithEvalContextExtension, \
sloppy_block_with_eval_context_extension)
// We use the full 8 bits of the instance_type field to encode heap object // We use the full 8 bits of the instance_type field to encode heap object
// instance types. The high-order bit (bit 7) is set if the object is not a // instance types. The high-order bit (bit 7) is set if the object is not a
...@@ -689,7 +687,7 @@ enum InstanceType { ...@@ -689,7 +687,7 @@ enum InstanceType {
TRANSITION_ARRAY_TYPE, TRANSITION_ARRAY_TYPE,
PROPERTY_CELL_TYPE, PROPERTY_CELL_TYPE,
PROTOTYPE_INFO_TYPE, PROTOTYPE_INFO_TYPE,
SLOPPY_BLOCK_WITH_EVAL_CONTEXT_EXTENSION_TYPE, CONTEXT_EXTENSION_TYPE,
// All the following types are subtypes of JSReceiver, which corresponds to // All the following types are subtypes of JSReceiver, which corresponds to
// objects in the JS sense. The first and the last type in this range are // objects in the JS sense. The first and the last type in this range are
...@@ -6653,28 +6651,29 @@ class PrototypeInfo : public Struct { ...@@ -6653,28 +6651,29 @@ class PrototypeInfo : public Struct {
// Pair used to store both a ScopeInfo and an extension object in the extension // Pair used to store both a ScopeInfo and an extension object in the extension
// slot of a block context. Needed in the rare case where a declaration block // slot of a block, catch, or with context. Needed in the rare case where a
// scope (a "varblock" as used to desugar parameter destructuring) also contains // declaration block scope (a "varblock" as used to desugar parameter
// a sloppy direct eval. (In no other case both are needed at the same time.) // destructuring) also contains a sloppy direct eval, or for with and catch
class SloppyBlockWithEvalContextExtension : public Struct { // scopes. (In no other case both are needed at the same time.)
class ContextExtension : public Struct {
public: public:
// [scope_info]: Scope info. // [scope_info]: Scope info.
DECL_ACCESSORS(scope_info, ScopeInfo) DECL_ACCESSORS(scope_info, ScopeInfo)
// [extension]: Extension object. // [extension]: Extension object.
DECL_ACCESSORS(extension, JSObject) DECL_ACCESSORS(extension, Object)
DECLARE_CAST(SloppyBlockWithEvalContextExtension) DECLARE_CAST(ContextExtension)
// Dispatched behavior. // Dispatched behavior.
DECLARE_PRINTER(SloppyBlockWithEvalContextExtension) DECLARE_PRINTER(ContextExtension)
DECLARE_VERIFIER(SloppyBlockWithEvalContextExtension) DECLARE_VERIFIER(ContextExtension)
static const int kScopeInfoOffset = HeapObject::kHeaderSize; static const int kScopeInfoOffset = HeapObject::kHeaderSize;
static const int kExtensionOffset = kScopeInfoOffset + kPointerSize; static const int kExtensionOffset = kScopeInfoOffset + kPointerSize;
static const int kSize = kExtensionOffset + kPointerSize; static const int kSize = kExtensionOffset + kPointerSize;
private: private:
DISALLOW_IMPLICIT_CONSTRUCTORS(SloppyBlockWithEvalContextExtension); DISALLOW_IMPLICIT_CONSTRUCTORS(ContextExtension);
}; };
......
...@@ -294,9 +294,8 @@ Object* DeclareEvalHelper(Isolate* isolate, Handle<String> name, ...@@ -294,9 +294,8 @@ Object* DeclareEvalHelper(Isolate* isolate, Handle<String> name,
DCHECK(context->IsBlockContext()); DCHECK(context->IsBlockContext());
object = isolate->factory()->NewJSObject( object = isolate->factory()->NewJSObject(
isolate->context_extension_function()); isolate->context_extension_function());
Handle<HeapObject> extension = Handle<HeapObject> extension = isolate->factory()->NewContextExtension(
isolate->factory()->NewSloppyBlockWithEvalContextExtension( handle(context->scope_info()), object);
handle(context->scope_info()), object);
context->set_extension(*extension); context->set_extension(*extension);
} else { } else {
object = handle(context->extension_object(), isolate); object = handle(context->extension_object(), isolate);
......
...@@ -278,7 +278,7 @@ Type::bitset BitsetType::Lub(i::Map* map) { ...@@ -278,7 +278,7 @@ Type::bitset BitsetType::Lub(i::Map* map) {
case CELL_TYPE: case CELL_TYPE:
case WEAK_CELL_TYPE: case WEAK_CELL_TYPE:
case PROTOTYPE_INFO_TYPE: case PROTOTYPE_INFO_TYPE:
case SLOPPY_BLOCK_WITH_EVAL_CONTEXT_EXTENSION_TYPE: case CONTEXT_EXTENSION_TYPE:
UNREACHABLE(); UNREACHABLE();
return kNone; return kNone;
} }
......
...@@ -89,7 +89,7 @@ INSTANCE_TYPES = { ...@@ -89,7 +89,7 @@ INSTANCE_TYPES = {
163: "ALIASED_ARGUMENTS_ENTRY_TYPE", 163: "ALIASED_ARGUMENTS_ENTRY_TYPE",
164: "BOX_TYPE", 164: "BOX_TYPE",
173: "PROTOTYPE_INFO_TYPE", 173: "PROTOTYPE_INFO_TYPE",
174: "SLOPPY_BLOCK_WITH_EVAL_CONTEXT_EXTENSION_TYPE", 174: "CONTEXT_EXTENSION_TYPE",
167: "FIXED_ARRAY_TYPE", 167: "FIXED_ARRAY_TYPE",
148: "FIXED_DOUBLE_ARRAY_TYPE", 148: "FIXED_DOUBLE_ARRAY_TYPE",
168: "SHARED_FUNCTION_INFO_TYPE", 168: "SHARED_FUNCTION_INFO_TYPE",
...@@ -232,7 +232,7 @@ KNOWN_MAPS = { ...@@ -232,7 +232,7 @@ KNOWN_MAPS = {
0x09231: (165, "DebugInfoMap"), 0x09231: (165, "DebugInfoMap"),
0x0925d: (166, "BreakPointInfoMap"), 0x0925d: (166, "BreakPointInfoMap"),
0x09289: (173, "PrototypeInfoMap"), 0x09289: (173, "PrototypeInfoMap"),
0x092b5: (174, "SloppyBlockWithEvalContextExtensionMap"), 0x092b5: (174, "ContextExtensionMap"),
} }
# List of known V8 objects. # List of known V8 objects.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment