Commit 4c972d66 authored by Toon Verwaest's avatar Toon Verwaest Committed by Commit Bot

Cleanup: Remove unnecessary ContextExtension wrapper

Bug: v8:7066
Change-Id: Icfcb40b2048997c158fba5f3e250145bed4ca1e3
Reviewed-on: https://chromium-review.googlesource.com/1042386
Commit-Queue: Toon Verwaest <verwaest@chromium.org>
Reviewed-by: 's avatarMichael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#52981}
parent b9c81f51
......@@ -851,25 +851,6 @@ FieldAccess AccessBuilder::ForContextSlot(size_t index) {
return access;
}
// static
FieldAccess AccessBuilder::ForContextExtensionScopeInfo() {
FieldAccess access = {
kTaggedBase, ContextExtension::kScopeInfoOffset,
Handle<Name>(), MaybeHandle<Map>(),
Type::OtherInternal(), MachineType::AnyTagged(),
kFullWriteBarrier};
return access;
}
// static
FieldAccess AccessBuilder::ForContextExtensionExtension() {
FieldAccess access = {kTaggedBase, ContextExtension::kExtensionOffset,
Handle<Name>(), MaybeHandle<Map>(),
Type::Any(), MachineType::AnyTagged(),
kFullWriteBarrier};
return access;
}
// static
ElementAccess AccessBuilder::ForFixedArrayElement() {
ElementAccess access = {kTaggedBase, FixedArray::kHeaderSize, Type::Any(),
......
......@@ -273,10 +273,6 @@ class V8_EXPORT_PRIVATE AccessBuilder final
// Provides access to Context slots.
static FieldAccess ForContextSlot(size_t index);
// Provides access to ContextExtension fields.
static FieldAccess ForContextExtensionScopeInfo();
static FieldAccess ForContextExtensionExtension();
// Provides access to FixedArray elements.
static ElementAccess ForFixedArrayElement();
static ElementAccess ForFixedArrayElement(
......
......@@ -1330,19 +1330,12 @@ Reduction JSCreateLowering::ReduceJSCreateFunctionContext(Node* node) {
Reduction JSCreateLowering::ReduceJSCreateWithContext(Node* node) {
DCHECK_EQ(IrOpcode::kJSCreateWithContext, node->opcode());
Handle<ScopeInfo> scope_info = ScopeInfoOf(node->op());
Node* object = NodeProperties::GetValueInput(node, 0);
Node* extension = NodeProperties::GetValueInput(node, 0);
Node* effect = NodeProperties::GetEffectInput(node);
Node* control = NodeProperties::GetControlInput(node);
Node* context = NodeProperties::GetContextInput(node);
AllocationBuilder aa(jsgraph(), effect, control);
aa.Allocate(ContextExtension::kSize);
aa.Store(AccessBuilder::ForMap(), factory()->context_extension_map());
aa.Store(AccessBuilder::ForContextExtensionScopeInfo(), scope_info);
aa.Store(AccessBuilder::ForContextExtensionExtension(), object);
Node* extension = aa.Finish();
AllocationBuilder a(jsgraph(), extension, control);
AllocationBuilder a(jsgraph(), effect, control);
STATIC_ASSERT(Context::MIN_CONTEXT_SLOTS == 4); // Ensure fully covered.
a.AllocateContext(Context::MIN_CONTEXT_SLOTS, factory()->with_context_map());
a.Store(AccessBuilder::ForContextSlot(Context::SCOPE_INFO_INDEX), scope_info);
......@@ -1360,27 +1353,19 @@ Reduction JSCreateLowering::ReduceJSCreateCatchContext(Node* node) {
const CreateCatchContextParameters& parameters =
CreateCatchContextParametersOf(node->op());
Handle<ScopeInfo> scope_info = parameters.scope_info();
Handle<String> catch_name = parameters.catch_name();
Node* exception = NodeProperties::GetValueInput(node, 0);
Node* effect = NodeProperties::GetEffectInput(node);
Node* control = NodeProperties::GetControlInput(node);
Node* context = NodeProperties::GetContextInput(node);
AllocationBuilder aa(jsgraph(), effect, control);
aa.Allocate(ContextExtension::kSize);
aa.Store(AccessBuilder::ForMap(), factory()->context_extension_map());
aa.Store(AccessBuilder::ForContextExtensionScopeInfo(),
parameters.scope_info());
aa.Store(AccessBuilder::ForContextExtensionExtension(),
parameters.catch_name());
Node* extension = aa.Finish();
AllocationBuilder a(jsgraph(), extension, control);
AllocationBuilder a(jsgraph(), effect, control);
STATIC_ASSERT(Context::MIN_CONTEXT_SLOTS == 4); // Ensure fully covered.
a.AllocateContext(Context::MIN_CONTEXT_SLOTS + 1,
factory()->catch_context_map());
a.Store(AccessBuilder::ForContextSlot(Context::SCOPE_INFO_INDEX), scope_info);
a.Store(AccessBuilder::ForContextSlot(Context::PREVIOUS_INDEX), context);
a.Store(AccessBuilder::ForContextSlot(Context::EXTENSION_INDEX), extension);
a.Store(AccessBuilder::ForContextSlot(Context::EXTENSION_INDEX), catch_name);
a.Store(AccessBuilder::ForContextSlot(Context::NATIVE_CONTEXT_INDEX),
jsgraph()->HeapConstant(native_context()));
a.Store(AccessBuilder::ForContextSlot(Context::THROWN_OBJECT_INDEX),
......
......@@ -327,7 +327,6 @@ Type::bitset BitsetType::Lub(i::Map* map) {
case WASM_SHARED_MODULE_DATA_TYPE:
case LOAD_HANDLER_TYPE:
case STORE_HANDLER_TYPE:
case CONTEXT_EXTENSION_TYPE:
case ASYNC_GENERATOR_REQUEST_TYPE:
case CODE_DATA_CONTAINER_TYPE:
case CALLBACK_TASK_TYPE:
......
......@@ -93,10 +93,6 @@ JSObject* Context::extension_object() {
IsEvalContext());
HeapObject* object = extension();
if (object->IsTheHole(GetIsolate())) return nullptr;
if (IsBlockContext()) {
if (!object->IsContextExtension()) return nullptr;
object = JSObject::cast(ContextExtension::cast(object)->extension());
}
DCHECK(object->IsJSContextExtensionObject() ||
(IsNativeContext() && object->IsJSGlobalObject()));
return JSObject::cast(object);
......@@ -105,9 +101,7 @@ JSObject* Context::extension_object() {
JSReceiver* Context::extension_receiver() {
DCHECK(IsNativeContext() || IsWithContext() || IsEvalContext() ||
IsFunctionContext() || IsBlockContext());
return IsWithContext() ? JSReceiver::cast(
ContextExtension::cast(extension())->extension())
: extension_object();
return IsWithContext() ? JSReceiver::cast(extension()) : extension_object();
}
ScopeInfo* Context::scope_info() {
......@@ -124,7 +118,7 @@ Module* Context::module() {
String* Context::catch_name() {
DCHECK(IsCatchContext());
return String::cast(ContextExtension::cast(extension())->extension());
return String::cast(extension());
}
......@@ -378,16 +372,13 @@ Handle<Object> Context::Lookup(Handle<String> name, ContextLookupFlags flags,
} else if (context->IsDebugEvaluateContext()) {
// Check materialized locals.
Object* ext = context->get(EXTENSION_INDEX);
if (ext->IsContextExtension()) {
Object* obj = ContextExtension::cast(ext)->extension();
if (obj->IsJSReceiver()) {
Handle<JSReceiver> extension(JSReceiver::cast(obj));
LookupIterator it(extension, name, extension);
Maybe<bool> found = JSReceiver::HasProperty(&it);
if (found.FromMaybe(false)) {
*attributes = NONE;
return extension;
}
if (ext->IsJSReceiver()) {
Handle<JSReceiver> extension(JSReceiver::cast(ext));
LookupIterator it(extension, name, extension);
Maybe<bool> found = JSReceiver::HasProperty(&it);
if (found.FromMaybe(false)) {
*attributes = NONE;
return extension;
}
}
// Check the original context, but do not follow its context chain.
......
......@@ -382,18 +382,15 @@ class ScriptContextTable : public FixedArray {
//
// [ extension ] Additional data.
//
// For catch contexts, it contains a ContextExtension object
// consisting of the ScopeInfo and the name of the catch
// For catch contexts, it contains the name of the catch
// variable.
//
// For module contexts, it contains the module object.
//
// For block contexts, it may contain a ContextExtension
// object consisting of the ScopeInfo and an "extension
// object" (see below).
// For block contexts, it may contain an "extension object"
// (see below).
//
// For with contexts, it contains a ContextExtension object
// consisting of the ScopeInfo and an "extension object".
// For with contexts, it contains an "extension object".
//
// An "extension object" is used to dynamically extend a
// context with additional variables, namely in the
......
......@@ -3419,7 +3419,6 @@ void TranslatedState::InitializeCapturedObjectAt(
case BOILERPLATE_DESCRIPTION_TYPE:
case HASH_TABLE_TYPE:
case PROPERTY_ARRAY_TYPE:
case CONTEXT_EXTENSION_TYPE:
InitializeObjectWithTaggedFieldsAt(frame, &value_index, slot, map,
no_allocation);
break;
......@@ -3586,14 +3585,6 @@ void TranslatedState::EnsureCapturedObjectAllocatedAt(
&value_index, worklist);
}
case CONTEXT_EXTENSION_TYPE: {
CHECK_EQ(map->instance_size(), slot->GetChildrenCount() * kPointerSize);
slot->set_storage(AllocateStorageFor(slot));
// Make sure all the remaining children (after the map) are allocated.
return EnsureChildrenAllocated(slot->GetChildrenCount() - 1, frame,
&value_index, worklist);
}
default:
CHECK(map->IsJSObjectMap());
EnsureJSObjectAllocated(slot, map);
......
......@@ -155,15 +155,6 @@ Handle<Tuple3> Factory::NewTuple3(Handle<Object> value1, Handle<Object> value2,
return result;
}
Handle<ContextExtension> Factory::NewContextExtension(
Handle<ScopeInfo> scope_info, Handle<Object> extension) {
Handle<ContextExtension> result = Handle<ContextExtension>::cast(
NewStruct(CONTEXT_EXTENSION_TYPE, TENURED));
result->set_scope_info(*scope_info);
result->set_extension(*extension);
return result;
}
Handle<ConstantElementsPair> Factory::NewConstantElementsPair(
ElementsKind elements_kind, Handle<FixedArrayBase> constant_values) {
Handle<ConstantElementsPair> result =
......@@ -1343,12 +1334,11 @@ Handle<Context> Factory::NewCatchContext(Handle<Context> previous,
Handle<String> name,
Handle<Object> thrown_object) {
STATIC_ASSERT(Context::MIN_CONTEXT_SLOTS == Context::THROWN_OBJECT_INDEX);
Handle<ContextExtension> extension = NewContextExtension(scope_info, name);
Handle<Context> context = NewFixedArrayWithMap<Context>(
Heap::kCatchContextMapRootIndex, Context::MIN_CONTEXT_SLOTS + 1);
context->set_scope_info(*scope_info);
context->set_previous(*previous);
context->set_extension(*extension);
context->set_extension(*name);
context->set_native_context(previous->native_context());
context->set(Context::THROWN_OBJECT_INDEX, *thrown_object);
return context;
......@@ -1361,15 +1351,15 @@ Handle<Context> Factory::NewDebugEvaluateContext(Handle<Context> previous,
Handle<StringSet> whitelist) {
STATIC_ASSERT(Context::WHITE_LIST_INDEX == Context::MIN_CONTEXT_SLOTS + 1);
DCHECK(scope_info->IsDebugEvaluateScope());
Handle<ContextExtension> context_extension = NewContextExtension(
scope_info, extension.is_null() ? Handle<Object>::cast(undefined_value())
: Handle<Object>::cast(extension));
Handle<HeapObject> ext = extension.is_null()
? Handle<HeapObject>::cast(the_hole_value())
: Handle<HeapObject>::cast(extension);
Handle<Context> c = NewFixedArrayWithMap<Context>(
Heap::kDebugEvaluateContextMapRootIndex, Context::MIN_CONTEXT_SLOTS + 2);
c->set_scope_info(*scope_info);
c->set_previous(*previous);
c->set_native_context(previous->native_context());
c->set_extension(*context_extension);
c->set_extension(*ext);
if (!wrapped.is_null()) c->set(Context::WRAPPED_CONTEXT_INDEX, *wrapped);
if (!whitelist.is_null()) c->set(Context::WHITE_LIST_INDEX, *whitelist);
return c;
......@@ -1378,13 +1368,11 @@ Handle<Context> Factory::NewDebugEvaluateContext(Handle<Context> previous,
Handle<Context> Factory::NewWithContext(Handle<Context> previous,
Handle<ScopeInfo> scope_info,
Handle<JSReceiver> extension) {
Handle<ContextExtension> context_extension =
NewContextExtension(scope_info, extension);
Handle<Context> context = NewFixedArrayWithMap<Context>(
Heap::kWithContextMapRootIndex, Context::MIN_CONTEXT_SLOTS);
context->set_scope_info(*scope_info);
context->set_previous(*previous);
context->set_extension(*context_extension);
context->set_extension(*extension);
context->set_native_context(previous->native_context());
return context;
}
......
......@@ -186,10 +186,6 @@ class V8_EXPORT_PRIVATE Factory {
Handle<Tuple3> NewTuple3(Handle<Object> value1, Handle<Object> value2,
Handle<Object> value3, PretenureFlag pretenure);
// Create a new ContextExtension struct.
Handle<ContextExtension> NewContextExtension(Handle<ScopeInfo> scope_info,
Handle<Object> extension);
// Create a new ConstantElementsPair struct.
Handle<ConstantElementsPair> NewConstantElementsPair(
ElementsKind elements_kind, Handle<FixedArrayBase> constant_values);
......
......@@ -716,8 +716,7 @@ int IncrementalMarking::VisitObject(Map* map, HeapObject* obj) {
// unsafe layout change.
// 4. The object is materizalized by the deoptimizer.
DCHECK(obj->IsHashTable() || obj->IsPropertyArray() ||
obj->IsContextExtension() || obj->IsFixedArray() ||
obj->IsJSObject() || obj->IsString());
obj->IsFixedArray() || obj->IsJSObject() || obj->IsString());
}
DCHECK(marking_state()->IsBlack(obj));
WhiteToGreyAndPush(map);
......
......@@ -1611,12 +1611,6 @@ void StoreHandler::StoreHandlerVerify() {
// TODO(ishell): check handler integrity
}
void ContextExtension::ContextExtensionVerify() {
CHECK(IsContextExtension());
VerifyObjectField(kScopeInfoOffset);
VerifyObjectField(kExtensionOffset);
}
void AccessorInfo::AccessorInfoVerify() {
CHECK(IsAccessorInfo());
VerifyPointer(name());
......
......@@ -571,7 +571,6 @@ CAST_ACCESSOR(BigInt)
CAST_ACCESSOR(BoilerplateDescription)
CAST_ACCESSOR(Cell)
CAST_ACCESSOR(ConstantElementsPair)
CAST_ACCESSOR(ContextExtension)
CAST_ACCESSOR(DescriptorArray)
CAST_ACCESSOR(EnumCache)
CAST_ACCESSOR(FeedbackCell)
......@@ -2324,9 +2323,6 @@ ACCESSORS(Tuple2, value1, Object, kValue1Offset)
ACCESSORS(Tuple2, value2, Object, kValue2Offset)
ACCESSORS(Tuple3, value3, Object, kValue3Offset)
ACCESSORS(ContextExtension, scope_info, ScopeInfo, kScopeInfoOffset)
ACCESSORS(ContextExtension, extension, Object, kExtensionOffset)
SMI_ACCESSORS(ConstantElementsPair, elements_kind, kElementsKindOffset)
ACCESSORS(ConstantElementsPair, constant_values, FixedArrayBase,
kConstantValuesOffset)
......
......@@ -1645,13 +1645,6 @@ void StoreHandler::StoreHandlerPrint(std::ostream& os) { // NOLINT
os << "\n";
}
void ContextExtension::ContextExtensionPrint(std::ostream& os) { // NOLINT
HeapObject::PrintHeader(os, "ContextExtension");
os << "\n - scope_info: " << Brief(scope_info());
os << "\n - extension: " << Brief(extension());
os << "\n";
}
void AccessorPair::AccessorPairPrint(std::ostream& os) { // NOLINT
HeapObject::PrintHeader(os, "AccessorPair");
os << "\n - getter: " << Brief(getter());
......
......@@ -382,7 +382,6 @@ const int kStubMinorKeyBits = kSmiValueSize - kStubMajorKeyBits - 1;
V(ALLOCATION_MEMENTO_TYPE) \
V(ALLOCATION_SITE_TYPE) \
V(ASYNC_GENERATOR_REQUEST_TYPE) \
V(CONTEXT_EXTENSION_TYPE) \
V(DEBUG_INFO_TYPE) \
V(FUNCTION_TEMPLATE_INFO_TYPE) \
V(INTERCEPTOR_INFO_TYPE) \
......@@ -557,7 +556,6 @@ const int kStubMinorKeyBits = kSmiValueSize - kStubMajorKeyBits - 1;
V(ALLOCATION_MEMENTO, AllocationMemento, allocation_memento) \
V(ALLOCATION_SITE, AllocationSite, allocation_site) \
V(ASYNC_GENERATOR_REQUEST, AsyncGeneratorRequest, async_generator_request) \
V(CONTEXT_EXTENSION, ContextExtension, context_extension) \
V(DEBUG_INFO, DebugInfo, debug_info) \
V(FUNCTION_TEMPLATE_INFO, FunctionTemplateInfo, function_template_info) \
V(INTERCEPTOR_INFO, InterceptorInfo, interceptor_info) \
......@@ -752,7 +750,6 @@ enum InstanceType : uint16_t {
ALLOCATION_MEMENTO_TYPE,
ALLOCATION_SITE_TYPE,
ASYNC_GENERATOR_REQUEST_TYPE,
CONTEXT_EXTENSION_TYPE,
DEBUG_INFO_TYPE,
FUNCTION_TEMPLATE_INFO_TYPE,
INTERCEPTOR_INFO_TYPE,
......@@ -2988,32 +2985,6 @@ class PrototypeInfo : public Struct {
DISALLOW_IMPLICIT_CONSTRUCTORS(PrototypeInfo);
};
// Pair used to store both a ScopeInfo and an extension object in the extension
// slot of a block, catch, or with context. Needed in the rare case where a
// declaration block scope (a "varblock" as used to desugar parameter
// destructuring) also contains a sloppy direct eval, or for with and catch
// scopes. (In no other case both are needed at the same time.)
class ContextExtension : public Struct {
public:
// [scope_info]: Scope info.
DECL_ACCESSORS(scope_info, ScopeInfo)
// [extension]: Extension object.
DECL_ACCESSORS(extension, Object)
DECL_CAST(ContextExtension)
// Dispatched behavior.
DECL_PRINTER(ContextExtension)
DECL_VERIFIER(ContextExtension)
static const int kScopeInfoOffset = HeapObject::kHeaderSize;
static const int kExtensionOffset = kScopeInfoOffset + kPointerSize;
static const int kSize = kExtensionOffset + kPointerSize;
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(ContextExtension);
};
// List of builtin functions we want to identify to improve code
// generation.
//
......
......@@ -297,14 +297,7 @@ Object* DeclareEvalHelper(Isolate* isolate, Handle<String> name,
object =
isolate->factory()->NewJSObject(isolate->context_extension_function());
if (context->IsBlockContext()) {
Handle<ContextExtension> extension =
isolate->factory()->NewContextExtension(handle(context->scope_info()),
object);
context->set_extension(*extension);
} else {
context->set_extension(*object);
}
context->set_extension(*object);
}
RETURN_FAILURE_ON_EXCEPTION(isolate, JSObject::SetOwnPropertyIgnoreAttributes(
......
This diff is collapsed.
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