Commit 042449fd authored by Yang Guo's avatar Yang Guo Committed by V8 LUCI CQ

Introduce NewSlowJSObjectWithNullProto for debugger use

NewJSObjectWithNullProto has use cases outside of the debugger. We
previously changed it to create dictionary mode objects, which affects
the performance of non-debugger use cases. This change partially
reverts that change by differentiating between use cases.

Fixed: chromium:1266160
Change-Id: I875073bdc062cf187ef24da62324f743169d2e29
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3257706
Auto-Submit: Yang Guo <yangguo@chromium.org>
Commit-Queue: Toon Verwaest <verwaest@chromium.org>
Reviewed-by: 's avatarToon Verwaest <verwaest@chromium.org>
Cr-Commit-Position: refs/heads/main@{#77671}
parent f8117f35
......@@ -142,7 +142,7 @@ MaybeHandle<Object> DebugEvaluate::WithTopmostArguments(Isolate* isolate,
Context::cast(it.frame()->context()).native_context(), isolate);
// Materialize arguments as property on an extension object.
Handle<JSObject> materialized = factory->NewJSObjectWithNullProto();
Handle<JSObject> materialized = factory->NewSlowJSObjectWithNullProto();
Handle<String> arguments_str = factory->arguments_string();
JSObject::SetOwnPropertyIgnoreAttributes(
materialized, arguments_str,
......
......@@ -556,7 +556,7 @@ Handle<JSObject> ScopeIterator::ScopeObject(Mode mode) {
return WithContextExtension();
}
Handle<JSObject> scope = isolate_->factory()->NewJSObjectWithNullProto();
Handle<JSObject> scope = isolate_->factory()->NewSlowJSObjectWithNullProto();
auto visitor = [=](Handle<String> name, Handle<Object> value,
ScopeType scope_type) {
if (value->IsTheHole(isolate_)) {
......@@ -901,7 +901,7 @@ bool ScopeIterator::VisitLocals(const Visitor& visitor, Mode mode,
Handle<JSObject> ScopeIterator::WithContextExtension() {
DCHECK(context_->IsWithContext());
if (context_->extension_receiver().IsJSProxy()) {
return isolate_->factory()->NewJSObjectWithNullProto();
return isolate_->factory()->NewSlowJSObjectWithNullProto();
}
return handle(JSObject::cast(context_->extension_receiver()), isolate_);
}
......
......@@ -628,7 +628,7 @@ class ContextProxy {
public:
static Handle<JSObject> Create(WasmFrame* frame) {
Isolate* isolate = frame->isolate();
auto object = isolate->factory()->NewJSObjectWithNullProto();
auto object = isolate->factory()->NewSlowJSObjectWithNullProto();
Handle<WasmInstanceObject> instance(frame->wasm_instance(), isolate);
JSObject::AddProperty(isolate, object, "instance", instance, FROZEN);
Handle<WasmModuleObject> module_object(instance->module_object(), isolate);
......@@ -692,7 +692,7 @@ class DebugWasmScopeIterator final : public debug::ScopeIterator {
case debug::ScopeIterator::ScopeTypeModule: {
Handle<WasmInstanceObject> instance(frame_->wasm_instance(), isolate);
Handle<JSObject> object =
isolate->factory()->NewJSObjectWithNullProto();
isolate->factory()->NewSlowJSObjectWithNullProto();
JSObject::AddProperty(isolate, object, "instance", instance, FROZEN);
Handle<JSObject> module_object(instance->module_object(), isolate);
JSObject::AddProperty(isolate, object, "module", module_object, FROZEN);
......@@ -725,7 +725,7 @@ class DebugWasmScopeIterator final : public debug::ScopeIterator {
return Utils::ToLocal(LocalsProxy::Create(frame_));
}
case debug::ScopeIterator::ScopeTypeWasmExpressionStack: {
auto object = isolate->factory()->NewJSObjectWithNullProto();
auto object = isolate->factory()->NewSlowJSObjectWithNullProto();
auto stack = StackProxy::Create(frame_);
JSObject::AddProperty(isolate, object, "stack", stack, FROZEN);
return Utils::ToLocal(object);
......
......@@ -2302,12 +2302,21 @@ Handle<JSObject> Factory::NewJSObject(Handle<JSFunction> constructor,
return NewJSObjectFromMap(map, allocation);
}
Handle<JSObject> Factory::NewJSObjectWithNullProto() {
Handle<JSObject> Factory::NewSlowJSObjectWithNullProto() {
Handle<JSObject> result =
NewSlowJSObjectFromMap(isolate()->slow_object_with_null_prototype_map());
return result;
}
Handle<JSObject> Factory::NewJSObjectWithNullProto() {
Handle<JSObject> result = NewJSObject(isolate()->object_function());
Handle<Map> new_map = Map::Copy(
isolate(), Handle<Map>(result->map(), isolate()), "ObjectWithNullProto");
Map::SetPrototype(isolate(), new_map, null_value());
JSObject::MigrateToMap(isolate(), result, new_map);
return result;
}
Handle<JSGlobalObject> Factory::NewJSGlobalObject(
Handle<JSFunction> constructor) {
DCHECK(constructor->has_initial_map());
......
......@@ -489,6 +489,8 @@ class V8_EXPORT_PRIVATE Factory : public FactoryBase<Factory> {
AllocationType allocation = AllocationType::kYoung);
// JSObject without a prototype.
Handle<JSObject> NewJSObjectWithNullProto();
// JSObject without a prototype, in dictionary mode.
Handle<JSObject> NewSlowJSObjectWithNullProto();
// Global objects are pretenured and initialized based on a constructor.
Handle<JSGlobalObject> NewJSGlobalObject(Handle<JSFunction> constructor);
......
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