summaryrefslogtreecommitdiff
path: root/deps/v8/src/runtime/runtime-object.cc
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/runtime/runtime-object.cc')
-rw-r--r--deps/v8/src/runtime/runtime-object.cc69
1 files changed, 9 insertions, 60 deletions
diff --git a/deps/v8/src/runtime/runtime-object.cc b/deps/v8/src/runtime/runtime-object.cc
index 02d1a8e157..e38bed3620 100644
--- a/deps/v8/src/runtime/runtime-object.cc
+++ b/deps/v8/src/runtime/runtime-object.cc
@@ -100,6 +100,13 @@ bool DeleteObjectPropertyFast(Isolate* isolate, Handle<JSReceiver> receiver,
// (3) The property to be deleted must be deletable.
PropertyDetails details = descriptors->GetDetails(descriptor);
if (!details.IsConfigurable()) return false;
+ // TODO(bmeurer): This optimization is unsound if the property is currently
+ // marked as constant, as there's no way that we can learn that it is not
+ // constant when we later follow the same transition again with a different
+ // value on the same object. As a quick-fix we just disable the optimization
+ // in case of constant fields. We might want to restructure the code here to
+ // update the {map} instead and deoptimize all code that depends on it.
+ if (details.constness() == PropertyConstness::kConst) return false;
// (4) The map must have a back pointer.
Object backpointer = map->GetBackPointer();
if (!backpointer->IsMap()) return false;
@@ -128,8 +135,8 @@ bool DeleteObjectPropertyFast(Isolate* isolate, Handle<JSReceiver> receiver,
// Slot clearing is the reason why this entire function cannot currently
// be implemented in the DeleteProperty stub.
if (index.is_inobject() && !map->IsUnboxedDoubleField(index)) {
- isolate->heap()->ClearRecordedSlot(
- *receiver, HeapObject::RawField(*receiver, index.offset()));
+ isolate->heap()->ClearRecordedSlot(*receiver,
+ receiver->RawField(index.offset()));
}
}
}
@@ -994,64 +1001,6 @@ RUNTIME_FUNCTION(Runtime_CopyDataPropertiesWithExcludedProperties) {
return *target;
}
-namespace {
-
-inline void TrySetNative(Handle<Object> maybe_func) {
- if (!maybe_func->IsJSFunction()) return;
- JSFunction::cast(*maybe_func)->shared()->set_native(true);
-}
-
-inline void TrySetNativeAndLength(Handle<Object> maybe_func, int length) {
- if (!maybe_func->IsJSFunction()) return;
- SharedFunctionInfo shared = JSFunction::cast(*maybe_func)->shared();
- shared->set_native(true);
- if (length >= 0) {
- shared->set_length(length);
- }
-}
-
-} // namespace
-
-RUNTIME_FUNCTION(Runtime_DefineMethodsInternal) {
- HandleScope scope(isolate);
- DCHECK_EQ(3, args.length());
- CHECK(isolate->bootstrapper()->IsActive());
- CONVERT_ARG_HANDLE_CHECKED(JSObject, target, 0);
- CONVERT_ARG_HANDLE_CHECKED(JSFunction, source_class, 1);
- CONVERT_SMI_ARG_CHECKED(length, 2);
-
- DCHECK(source_class->prototype()->IsJSObject());
- Handle<JSObject> source(JSObject::cast(source_class->prototype()), isolate);
-
- Handle<FixedArray> keys;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, keys,
- KeyAccumulator::GetKeys(source, KeyCollectionMode::kOwnOnly,
- ALL_PROPERTIES,
- GetKeysConversion::kConvertToString));
-
- for (int i = 0; i < keys->length(); ++i) {
- Handle<Name> key = Handle<Name>::cast(FixedArray::get(*keys, i, isolate));
- if (*key == ReadOnlyRoots(isolate).constructor_string()) continue;
-
- PropertyDescriptor descriptor;
- Maybe<bool> did_get_descriptor =
- JSReceiver::GetOwnPropertyDescriptor(isolate, source, key, &descriptor);
- CHECK(did_get_descriptor.FromJust());
- if (descriptor.has_value()) {
- TrySetNativeAndLength(descriptor.value(), length);
- } else {
- if (descriptor.has_get()) TrySetNative(descriptor.get());
- if (descriptor.has_set()) TrySetNative(descriptor.set());
- }
-
- Maybe<bool> success = JSReceiver::DefineOwnProperty(
- isolate, target, key, &descriptor, Just(kDontThrow));
- CHECK(success.FromJust());
- }
- return ReadOnlyRoots(isolate).undefined_value();
-}
-
RUNTIME_FUNCTION(Runtime_DefineSetterPropertyUnchecked) {
HandleScope scope(isolate);
DCHECK_EQ(4, args.length());