- Revision
- 201834
- Author
- barraclo...@apple.com
- Date
- 2016-06-08 14:49:32 -0700 (Wed, 08 Jun 2016)
Log Message
Remove removeDirect
https://bugs.webkit.org/show_bug.cgi?id=158516
Reviewed by Ryosuke Niwa.
removeDirect is typically used as a subroutine of deleteProperty, but is also available to
call directly. Having this functionality factored out to a separate routine is a bad idea
on a couple of fronts:
- for the main use within deleteProperty there is redundancy (presence of the property
was being checked twice) and inconsistency (the two functions returned different results
in the case of a nonexistent property; the result from removeDirect was never observed).
- all uses of removeDirect are in practical terms incorrect. removeDirect had the
advantage of ignoring the configurable (DontDelete) attributes, but this is achievable
using the DeletePropertyMode setting - and the disadvantage of failing delete static
table properties. Last uses were one that was removed in bug #158295 (where failure to
delete static properties was a problem), and as addressed in this patch removeDirect is
being used to implement runtime enabled features. This only works because we currently
force reification of all properties on the DOM prototype objects, so in effect there are
no static properties. In order to make the code robust such that runtime enabled
features would still work even if we were not reifying static properties (a change we
may want to make) we should be calling deleteProperty in this case too.
Source/_javascript_Core:
* runtime/JSObject.cpp:
(JSC::JSObject::deleteProperty):
- incorporated removeDirect functionality, added comments & ASSERT.
(JSC::JSObject::removeDirect): Deleted.
- removed.
* runtime/JSObject.h:
- removed removeDirect.
Source/WebCore:
* bindings/scripts/CodeGeneratorJS.pm:
(GenerateImplementation):
- changed to call deleteProperty instead of removeDirect.
* bindings/scripts/test/JS/JSTestObj.cpp:
(WebCore::JSTestObjPrototype::finishCreation):
- updated bindings test results.
Modified Paths
Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (201833 => 201834)
--- trunk/Source/_javascript_Core/ChangeLog 2016-06-08 21:17:54 UTC (rev 201833)
+++ trunk/Source/_javascript_Core/ChangeLog 2016-06-08 21:49:32 UTC (rev 201834)
@@ -1,3 +1,37 @@
+2016-06-08 Gavin Barraclough <barraclo...@apple.com>
+
+ Remove removeDirect
+ https://bugs.webkit.org/show_bug.cgi?id=158516
+
+ Reviewed by Ryosuke Niwa.
+
+ removeDirect is typically used as a subroutine of deleteProperty, but is also available to
+ call directly. Having this functionality factored out to a separate routine is a bad idea
+ on a couple of fronts:
+
+ - for the main use within deleteProperty there is redundancy (presence of the property
+ was being checked twice) and inconsistency (the two functions returned different results
+ in the case of a nonexistent property; the result from removeDirect was never observed).
+
+ - all uses of removeDirect are in practical terms incorrect. removeDirect had the
+ advantage of ignoring the configurable (DontDelete) attributes, but this is achievable
+ using the DeletePropertyMode setting - and the disadvantage of failing delete static
+ table properties. Last uses were one that was removed in bug #158295 (where failure to
+ delete static properties was a problem), and as addressed in this patch removeDirect is
+ being used to implement runtime enabled features. This only works because we currently
+ force reification of all properties on the DOM prototype objects, so in effect there are
+ no static properties. In order to make the code robust such that runtime enabled
+ features would still work even if we were not reifying static properties (a change we
+ may want to make) we should be calling deleteProperty in this case too.
+
+ * runtime/JSObject.cpp:
+ (JSC::JSObject::deleteProperty):
+ - incorporated removeDirect functionality, added comments & ASSERT.
+ (JSC::JSObject::removeDirect): Deleted.
+ - removed.
+ * runtime/JSObject.h:
+ - removed removeDirect.
+
2016-06-08 Mark Lam <mark....@apple.com>
Simplify Interpreter::StackFrame.
Modified: trunk/Source/_javascript_Core/runtime/JSObject.cpp (201833 => 201834)
--- trunk/Source/_javascript_Core/runtime/JSObject.cpp 2016-06-08 21:17:54 UTC (rev 201833)
+++ trunk/Source/_javascript_Core/runtime/JSObject.cpp 2016-06-08 21:49:32 UTC (rev 201834)
@@ -1496,19 +1496,36 @@
if (Optional<uint32_t> index = parseIndex(propertyName))
return thisObject->methodTable(vm)->deletePropertyByIndex(thisObject, exec, index.value());
+ unsigned attributes;
+
if (!thisObject->staticFunctionsReified()) {
if (auto* entry = thisObject->findPropertyHashEntry(propertyName)) {
- if (entry->attributes() & DontDelete && vm.deletePropertyMode() != VM::DeletePropertyMode::IgnoreConfigurable)
+ // If the static table contains a non-configurable (DontDelete) property then we can return early;
+ // if there is a property in the storage array it too must be non-configurable (the language does
+ // not allow repacement of a non-configurable property with a configurable one).
+ if (entry->attributes() & DontDelete && vm.deletePropertyMode() != VM::DeletePropertyMode::IgnoreConfigurable) {
+ ASSERT(!isValidOffset(thisObject->structure(vm)->get(vm, propertyName, attributes)) || attributes & DontDelete);
return false;
+ }
thisObject->reifyAllStaticProperties(exec);
}
}
- unsigned attributes;
- if (isValidOffset(thisObject->structure(vm)->get(vm, propertyName, attributes))) {
+ Structure* structure = thisObject->structure(vm);
+
+ bool propertyIsPresent = isValidOffset(structure->get(vm, propertyName, attributes));
+ if (propertyIsPresent) {
if (attributes & DontDelete && vm.deletePropertyMode() != VM::DeletePropertyMode::IgnoreConfigurable)
return false;
- thisObject->removeDirect(vm, propertyName);
+
+ PropertyOffset offset;
+ if (structure->isUncacheableDictionary())
+ offset = structure->removePropertyWithoutTransition(vm, propertyName);
+ else
+ thisObject->setStructure(vm, Structure::removePropertyTransition(vm, structure, propertyName, offset));
+
+ if (offset != invalidOffset)
+ thisObject->putDirectUndefined(offset);
}
return true;
@@ -1978,28 +1995,6 @@
structure(vm)->setStaticFunctionsReified(true);
}
-bool JSObject::removeDirect(VM& vm, PropertyName propertyName)
-{
- Structure* structure = this->structure(vm);
- if (!isValidOffset(structure->get(vm, propertyName)))
- return false;
-
- PropertyOffset offset;
- if (structure->isUncacheableDictionary()) {
- offset = structure->removePropertyWithoutTransition(vm, propertyName);
- if (offset == invalidOffset)
- return false;
- putDirectUndefined(offset);
- return true;
- }
-
- setStructure(vm, Structure::removePropertyTransition(vm, structure, propertyName, offset));
- if (offset == invalidOffset)
- return false;
- putDirectUndefined(offset);
- return true;
-}
-
NEVER_INLINE void JSObject::fillGetterPropertySlot(PropertySlot& slot, JSValue getterSetter, unsigned attributes, PropertyOffset offset)
{
if (structure()->isUncacheableDictionary()) {
Modified: trunk/Source/_javascript_Core/runtime/JSObject.h (201833 => 201834)
--- trunk/Source/_javascript_Core/runtime/JSObject.h 2016-06-08 21:17:54 UTC (rev 201833)
+++ trunk/Source/_javascript_Core/runtime/JSObject.h 2016-06-08 21:49:32 UTC (rev 201834)
@@ -622,7 +622,6 @@
void transitionTo(VM&, Structure*);
- JS_EXPORT_PRIVATE bool removeDirect(VM&, PropertyName); // Return true if anything is removed.
bool hasCustomProperties() { return structure()->didTransition(); }
bool hasGetterSetterProperties() { return structure()->hasGetterSetterProperties(); }
bool hasCustomGetterSetterProperties() { return structure()->hasCustomGetterSetterProperties(); }
Modified: trunk/Source/WebCore/ChangeLog (201833 => 201834)
--- trunk/Source/WebCore/ChangeLog 2016-06-08 21:17:54 UTC (rev 201833)
+++ trunk/Source/WebCore/ChangeLog 2016-06-08 21:49:32 UTC (rev 201834)
@@ -1,3 +1,36 @@
+2016-06-08 Gavin Barraclough <barraclo...@apple.com>
+
+ Remove removeDirect
+ https://bugs.webkit.org/show_bug.cgi?id=158516
+
+ Reviewed by Ryosuke Niwa.
+
+ removeDirect is typically used as a subroutine of deleteProperty, but is also available to
+ call directly. Having this functionality factored out to a separate routine is a bad idea
+ on a couple of fronts:
+
+ - for the main use within deleteProperty there is redundancy (presence of the property
+ was being checked twice) and inconsistency (the two functions returned different results
+ in the case of a nonexistent property; the result from removeDirect was never observed).
+
+ - all uses of removeDirect are in practical terms incorrect. removeDirect had the
+ advantage of ignoring the configurable (DontDelete) attributes, but this is achievable
+ using the DeletePropertyMode setting - and the disadvantage of failing delete static
+ table properties. Last uses were one that was removed in bug #158295 (where failure to
+ delete static properties was a problem), and as addressed in this patch removeDirect is
+ being used to implement runtime enabled features. This only works because we currently
+ force reification of all properties on the DOM prototype objects, so in effect there are
+ no static properties. In order to make the code robust such that runtime enabled
+ features would still work even if we were not reifying static properties (a change we
+ may want to make) we should be calling deleteProperty in this case too.
+
+ * bindings/scripts/CodeGeneratorJS.pm:
+ (GenerateImplementation):
+ - changed to call deleteProperty instead of removeDirect.
+ * bindings/scripts/test/JS/JSTestObj.cpp:
+ (WebCore::JSTestObjPrototype::finishCreation):
+ - updated bindings test results.
+
2016-06-08 Nan Wang <n_w...@apple.com>
For keyboard users, activating a fragment URL should transfer focus and caret to the destination
Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (201833 => 201834)
--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm 2016-06-08 21:17:54 UTC (rev 201833)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm 2016-06-08 21:49:32 UTC (rev 201834)
@@ -2282,7 +2282,8 @@
my $name = $signature->name;
push(@implContent, " if (!${enable_function}()) {\n");
push(@implContent, " Identifier propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>(\"$name\"), strlen(\"$name\"));\n");
- push(@implContent, " removeDirect(vm, propertyName);\n");
+ push(@implContent, " VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable);\n");
+ push(@implContent, " JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName);\n");
push(@implContent, " }\n");
push(@implContent, "#endif\n") if $conditionalString;
}
Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp (201833 => 201834)
--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp 2016-06-08 21:17:54 UTC (rev 201833)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp 2016-06-08 21:49:32 UTC (rev 201834)
@@ -1310,13 +1310,15 @@
#if ENABLE(TEST_FEATURE)
if (!RuntimeEnabledFeatures::sharedFeatures().testFeatureEnabled()) {
Identifier propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("enabledAtRuntimeOperation"), strlen("enabledAtRuntimeOperation"));
- removeDirect(vm, propertyName);
+ VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable);
+ JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName);
}
#endif
#if ENABLE(TEST_FEATURE)
if (!RuntimeEnabledFeatures::sharedFeatures().testFeatureEnabled()) {
Identifier propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("enabledAtRuntimeAttribute"), strlen("enabledAtRuntimeAttribute"));
- removeDirect(vm, propertyName);
+ VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable);
+ JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName);
}
#endif
JSVMClientData& clientData = *static_cast<JSVMClientData*>(vm.clientData);