Commit 6c9b264e authored by barraclough@apple.com's avatar barraclough@apple.com

Add support for private names

https://bugs.webkit.org/show_bug.cgi?id=86509

Reviewed by Oliver Hunt.

The spec isn't final, but we can start adding support to allow property maps
to contain keys that aren't identifiers.

Source/JavaScriptCore: 

* API/JSCallbackObjectFunctions.h:
(JSC::::getOwnPropertySlot):
(JSC::::put):
(JSC::::deleteProperty):
(JSC::::getStaticValue):
(JSC::::staticFunctionGetter):
(JSC::::callbackGetter):
    - Only expose public named properties over the JSC API.
* CMakeLists.txt:
* DerivedSources.make:
* DerivedSources.pri:
* GNUmakefile.list.am:
* JavaScriptCore.gypi:
* JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
* JavaScriptCore.xcodeproj/project.pbxproj:
* Target.pri:
    - Added new files to build system.
* dfg/DFGOperations.cpp:
(JSC::DFG::operationPutByValInternal):
    - Added support for property access with name objects.
* interpreter/CallFrame.h:
(JSC::ExecState::privateNamePrototypeTable):
    - Added hash table for NamePrototype
* interpreter/Interpreter.cpp:
(JSC::Interpreter::privateExecute):
    - Added support for property access with name objects.
* jit/JITStubs.cpp:
(JSC::DEFINE_STUB_FUNCTION):
    - Added support for property access with name objects.
* llint/LLIntSlowPaths.cpp:
(JSC::LLInt::getByVal):
(JSC::LLInt::LLINT_SLOW_PATH_DECL):
* runtime/CommonSlowPaths.h:
(JSC::CommonSlowPaths::opIn):
* runtime/JSActivation.cpp:
(JSC::JSActivation::symbolTableGet):
(JSC::JSActivation::symbolTablePut):
(JSC::JSActivation::symbolTablePutWithAttributes):
    - Added support for property access with name objects.
* runtime/JSGlobalData.cpp:
(JSC):
(JSC::JSGlobalData::JSGlobalData):
(JSC::JSGlobalData::~JSGlobalData):
* runtime/JSGlobalData.h:
(JSGlobalData):
    - Added hash table for NamePrototype
* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::reset):
* runtime/JSGlobalObject.h:
(JSGlobalObject):
(JSC::JSGlobalObject::privateNameStructure):
(JSC::JSGlobalObject::symbolTableHasProperty):
    - Added new global properties.
* runtime/JSType.h:
* runtime/JSTypeInfo.h:
(JSC::TypeInfo::isName):
    - Added type for NameInstances, for fast isName check.
* runtime/JSVariableObject.cpp:
(JSC::JSVariableObject::deleteProperty):
(JSC::JSVariableObject::symbolTableGet):
* runtime/JSVariableObject.h:
(JSC::JSVariableObject::symbolTableGet):
(JSC::JSVariableObject::symbolTablePut):
(JSC::JSVariableObject::symbolTablePutWithAttributes):
    - symbol table lookup should take a PropertyName.
* runtime/Lookup.cpp:
(JSC::setUpStaticFunctionSlot):
* runtime/Lookup.h:
(JSC::HashTable::entry):
    - entry lookup should take a PropertyName.
* runtime/NameConstructor.cpp: Added.
(JSC):
(JSC::NameConstructor::NameConstructor):
(JSC::NameConstructor::finishCreation):
(JSC::constructPrivateName):
(JSC::NameConstructor::getConstructData):
(JSC::NameConstructor::getCallData):
* runtime/NameConstructor.h: Added.
(JSC):
(NameConstructor):
(JSC::NameConstructor::create):
(JSC::NameConstructor::createStructure):
    - Added constructor.
* runtime/NameInstance.cpp: Added.
(JSC):
(JSC::NameInstance::NameInstance):
(JSC::NameInstance::destroy):
* runtime/NameInstance.h: Added.
(JSC):
(NameInstance):
(JSC::NameInstance::createStructure):
(JSC::NameInstance::create):
(JSC::NameInstance::privateName):
(JSC::NameInstance::nameString):
(JSC::NameInstance::finishCreation):
(JSC::isName):
    - Added instance.
* runtime/NamePrototype.cpp: Added.
(JSC):
(JSC::NamePrototype::NamePrototype):
(JSC::NamePrototype::finishCreation):
(JSC::NamePrototype::getOwnPropertySlot):
(JSC::NamePrototype::getOwnPropertyDescriptor):
(JSC::privateNameProtoFuncToString):
* runtime/NamePrototype.h: Added.
(JSC):
(NamePrototype):
(JSC::NamePrototype::create):
(JSC::NamePrototype::createStructure):
    - Added prototype.
* runtime/PrivateName.h: Added.
(JSC):
(PrivateName):
(JSC::PrivateName::PrivateName):
(JSC::PrivateName::uid):
    - A private name object holds a StringImpl that can be used as a unique key in a property map.
* runtime/PropertyMapHashTable.h:
(JSC::PropertyTable::find):
(JSC::PropertyTable::findWithString):
    - Strings should only match keys in the table that are identifiers.
* runtime/PropertyName.h:
(JSC::PropertyName::PropertyName):
(PropertyName):
(JSC::PropertyName::uid):
(JSC::PropertyName::publicName):
(JSC::PropertyName::asIndex):
(JSC::operator==):
(JSC::operator!=):
    - replaced impl() & ustring() with uid() [to get the raw impl] and publicName() [impl or null, if not an identifier].
* runtime/Structure.cpp:
(JSC::Structure::despecifyDictionaryFunction):
(JSC::Structure::addPropertyTransitionToExistingStructure):
(JSC::Structure::addPropertyTransition):
(JSC::Structure::attributeChangeTransition):
(JSC::Structure::get):
(JSC::Structure::despecifyFunction):
(JSC::Structure::putSpecificValue):
(JSC::Structure::remove):
(JSC::Structure::getPropertyNamesFromStructure):
* runtime/Structure.h:
(JSC::Structure::get):
    - call uid() to get a PropertyName raw impl, for use as a key.

Source/WebCore: 

Test: fast/js/names.html

* bindings/js/JSCSSStyleDeclarationCustom.cpp:
(WebCore::cssPropertyIDForJSCSSPropertyName):
* bindings/js/JSDOMBinding.cpp:
(WebCore::findAtomicString):
(WebCore::objectToStringFunctionGetter):
* bindings/js/JSDOMBinding.h:
(WebCore::propertyNameToString):
(WebCore::propertyNameToAtomicString):
* bindings/js/JSDOMWindowCustom.cpp:
(WebCore::nonCachingStaticFunctionGetter):
* bindings/js/JSHistoryCustom.cpp:
(WebCore::nonCachingStaticBackFunctionGetter):
(WebCore::nonCachingStaticForwardFunctionGetter):
(WebCore::nonCachingStaticGoFunctionGetter):
* bindings/js/JSLocationCustom.cpp:
(WebCore::nonCachingStaticReplaceFunctionGetter):
(WebCore::nonCachingStaticReloadFunctionGetter):
(WebCore::nonCachingStaticAssignFunctionGetter):
* bridge/c/c_class.cpp:
(JSC::Bindings::CClass::methodsNamed):
(JSC::Bindings::CClass::fieldNamed):
* bridge/c/c_instance.cpp:
(JSC::Bindings::CInstance::getMethod):
* bridge/jni/jsc/JavaClassJSC.cpp:
(JavaClass::methodsNamed):
(JavaClass::fieldNamed):
* bridge/jni/jsc/JavaInstanceJSC.cpp:
* bridge/objc/objc_class.mm:
(JSC::Bindings::ObjcClass::methodsNamed):
(JSC::Bindings::ObjcClass::fieldNamed):
(JSC::Bindings::ObjcClass::fallbackObject):
* bridge/objc/objc_instance.mm:
(ObjcInstance::setValueOfUndefinedField):
(ObjcInstance::getValueOfUndefinedField):
    - Removed PropertyName::impl(), call publicName() to get the string associated with a name.

Source/WebKit/mac: 

* Plugins/Hosted/ProxyInstance.mm:
(WebKit::ProxyClass::methodsNamed):
(WebKit::ProxyClass::fieldNamed):
(WebKit::ProxyInstance::getMethod):
(WebKit::ProxyInstance::methodsNamed):
(WebKit::ProxyInstance::fieldNamed):
    - Removed PropertyName::impl(), call publicName() to get the string associated with a name.

Source/WebKit2: 

* WebProcess/Plugins/Netscape/JSNPObject.cpp:
(WebKit::npIdentifierFromIdentifier):
(WebKit::JSNPObject::methodGetter):
    - Removed PropertyName::impl(), call publicName() to get the string associated with a name.

Source/WTF: 

* wtf/text/StringImpl.h:
(WTF::StringImpl::StringImpl):
(StringImpl):
(WTF::StringImpl::createEmptyUnique):
(WTF::StringImpl::isEmptyUnique):
    - Allow empty string impls to be allocated, which can be used as unique keys.

LayoutTests: 

* fast/js/names-expected.txt: Added.
* fast/js/names.html: Added.
* fast/js/script-tests/names.js: Added.
    - Added test cases.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@117859 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 339a5dde
2012-05-15 Gavin Barraclough <barraclough@apple.com>
Add support for private names
https://bugs.webkit.org/show_bug.cgi?id=86509
Reviewed by Oliver Hunt.
The spec isn't final, but we can start adding support to allow property maps
to contain keys that aren't identifiers.
* fast/js/names-expected.txt: Added.
* fast/js/names.html: Added.
* fast/js/script-tests/names.js: Added.
- Added test cases.
2012-05-21 Emil A Eklund <eae@chromium.org>
Fix bug in paintNinePieceImage exposed by subpixel change
This tests an early experimental implementation of ES6-esque private names.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS prop in o is false
PASS 'prop' in o is false
PASS Object.getOwnPropertyNames(o).length is 0
PASS forIn(o) is []
PASS prop in o is true
PASS 'prop' in o is false
PASS Object.getOwnPropertyNames(o).length is 0
PASS forIn(o) is []
PASS o[prop] is 42
PASS o['prop'] is 101
PASS Object.getOwnPropertyNames(o).length is 1
PASS forIn(o) is ["prop"]
PASS prop in o is false
PASS 'prop' in o is true
PASS Object.getOwnPropertyNames(o).length is 1
PASS forIn(o) is ["prop"]
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="resources/js-test-pre.js"></script>
</head>
<body>
<script src="script-tests/names.js"></script>
<script src="resources/js-test-post.js"></script>
</body>
</html>
description(
"This tests an early experimental implementation of ES6-esque private names."
);
function forIn(o)
{
var a = [];
for (x in o)
a.push(x);
return a;
}
var prop = Name("prop");
var o = {};
shouldBeFalse("prop in o");
shouldBeFalse("'prop' in o");
shouldBe("Object.getOwnPropertyNames(o).length", '0');
shouldBe("forIn(o)", '[]');
o[prop] = 42;
shouldBeTrue("prop in o");
shouldBeFalse("'prop' in o");
shouldBe("Object.getOwnPropertyNames(o).length", '0');
shouldBe("forIn(o)", '[]');
o['prop'] = 101;
shouldBe("o[prop]", '42');
shouldBe("o['prop']", '101');
shouldBe("Object.getOwnPropertyNames(o).length", '1');
shouldBe("forIn(o)", '["prop"]');
delete o[prop];
shouldBeFalse("prop in o");
shouldBeTrue("'prop' in o");
shouldBe("Object.getOwnPropertyNames(o).length", '1');
shouldBe("forIn(o)", '["prop"]');
successfullyParsed = true;
......@@ -1436,6 +1436,9 @@ BUGWK80335 : fast/js/mozilla/strict/15.4.4.13.html = TEXT
// V8 should implement the length property of constructors
BUGWK78657 : fast/js/constructor-length.html = FAIL
// This is JSC-only, preliminary implementation of a ES6 feature - doesn't exist in V8 (yet)
BUGWK86509 SKIP WONTFIX : fast/js/names.html = FAIL
// Linux pixeltest failure: The text suggests that the radios should not
// overlap, but it's very close and quite different from the Windows version
BUGCR10350 LINUX : fast/replaced/width100percent-radio.html = FAIL
......
......@@ -192,6 +192,12 @@ SET(JavaScriptCore_SOURCES
runtime/LiteralParser.cpp
runtime/Lookup.cpp
runtime/MathObject.cpp
runtime/NameConstructor.cpp
runtime/NameConstructor.h
runtime/NameInstance.cpp
runtime/NameInstance.h
runtime/NamePrototype.cpp
runtime/NamePrototype.h
runtime/NativeErrorConstructor.cpp
runtime/NativeErrorPrototype.cpp
runtime/NumberConstructor.cpp
......@@ -243,6 +249,7 @@ SET(JavaScriptCore_LUT_FILES
runtime/JSGlobalObject.cpp
runtime/JSONObject.cpp
runtime/MathObject.cpp
runtime/NamePrototype.cpp
runtime/NumberConstructor.cpp
runtime/NumberPrototype.cpp
runtime/ObjectConstructor.cpp
......
2012-05-15 Gavin Barraclough <barraclough@apple.com>
Add support for private names
https://bugs.webkit.org/show_bug.cgi?id=86509
Reviewed by Oliver Hunt.
The spec isn't final, but we can start adding support to allow property maps
to contain keys that aren't identifiers.
* API/JSCallbackObjectFunctions.h:
(JSC::::getOwnPropertySlot):
(JSC::::put):
(JSC::::deleteProperty):
(JSC::::getStaticValue):
(JSC::::staticFunctionGetter):
(JSC::::callbackGetter):
- Only expose public named properties over the JSC API.
* CMakeLists.txt:
* DerivedSources.make:
* DerivedSources.pri:
* GNUmakefile.list.am:
* JavaScriptCore.gypi:
* JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
* JavaScriptCore.xcodeproj/project.pbxproj:
* Target.pri:
- Added new files to build system.
* dfg/DFGOperations.cpp:
(JSC::DFG::operationPutByValInternal):
- Added support for property access with name objects.
* interpreter/CallFrame.h:
(JSC::ExecState::privateNamePrototypeTable):
- Added hash table for NamePrototype
* interpreter/Interpreter.cpp:
(JSC::Interpreter::privateExecute):
- Added support for property access with name objects.
* jit/JITStubs.cpp:
(JSC::DEFINE_STUB_FUNCTION):
- Added support for property access with name objects.
* llint/LLIntSlowPaths.cpp:
(JSC::LLInt::getByVal):
(JSC::LLInt::LLINT_SLOW_PATH_DECL):
* runtime/CommonSlowPaths.h:
(JSC::CommonSlowPaths::opIn):
* runtime/JSActivation.cpp:
(JSC::JSActivation::symbolTableGet):
(JSC::JSActivation::symbolTablePut):
(JSC::JSActivation::symbolTablePutWithAttributes):
- Added support for property access with name objects.
* runtime/JSGlobalData.cpp:
(JSC):
(JSC::JSGlobalData::JSGlobalData):
(JSC::JSGlobalData::~JSGlobalData):
* runtime/JSGlobalData.h:
(JSGlobalData):
- Added hash table for NamePrototype
* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::reset):
* runtime/JSGlobalObject.h:
(JSGlobalObject):
(JSC::JSGlobalObject::privateNameStructure):
(JSC::JSGlobalObject::symbolTableHasProperty):
- Added new global properties.
* runtime/JSType.h:
* runtime/JSTypeInfo.h:
(JSC::TypeInfo::isName):
- Added type for NameInstances, for fast isName check.
* runtime/JSVariableObject.cpp:
(JSC::JSVariableObject::deleteProperty):
(JSC::JSVariableObject::symbolTableGet):
* runtime/JSVariableObject.h:
(JSC::JSVariableObject::symbolTableGet):
(JSC::JSVariableObject::symbolTablePut):
(JSC::JSVariableObject::symbolTablePutWithAttributes):
- symbol table lookup should take a PropertyName.
* runtime/Lookup.cpp:
(JSC::setUpStaticFunctionSlot):
* runtime/Lookup.h:
(JSC::HashTable::entry):
- entry lookup should take a PropertyName.
* runtime/NameConstructor.cpp: Added.
(JSC):
(JSC::NameConstructor::NameConstructor):
(JSC::NameConstructor::finishCreation):
(JSC::constructPrivateName):
(JSC::NameConstructor::getConstructData):
(JSC::NameConstructor::getCallData):
* runtime/NameConstructor.h: Added.
(JSC):
(NameConstructor):
(JSC::NameConstructor::create):
(JSC::NameConstructor::createStructure):
- Added constructor.
* runtime/NameInstance.cpp: Added.
(JSC):
(JSC::NameInstance::NameInstance):
(JSC::NameInstance::destroy):
* runtime/NameInstance.h: Added.
(JSC):
(NameInstance):
(JSC::NameInstance::createStructure):
(JSC::NameInstance::create):
(JSC::NameInstance::privateName):
(JSC::NameInstance::nameString):
(JSC::NameInstance::finishCreation):
(JSC::isName):
- Added instance.
* runtime/NamePrototype.cpp: Added.
(JSC):
(JSC::NamePrototype::NamePrototype):
(JSC::NamePrototype::finishCreation):
(JSC::NamePrototype::getOwnPropertySlot):
(JSC::NamePrototype::getOwnPropertyDescriptor):
(JSC::privateNameProtoFuncToString):
* runtime/NamePrototype.h: Added.
(JSC):
(NamePrototype):
(JSC::NamePrototype::create):
(JSC::NamePrototype::createStructure):
- Added prototype.
* runtime/PrivateName.h: Added.
(JSC):
(PrivateName):
(JSC::PrivateName::PrivateName):
(JSC::PrivateName::uid):
- A private name object holds a StringImpl that can be used as a unique key in a property map.
* runtime/PropertyMapHashTable.h:
(JSC::PropertyTable::find):
(JSC::PropertyTable::findWithString):
- Strings should only match keys in the table that are identifiers.
* runtime/PropertyName.h:
(JSC::PropertyName::PropertyName):
(PropertyName):
(JSC::PropertyName::uid):
(JSC::PropertyName::publicName):
(JSC::PropertyName::asIndex):
(JSC::operator==):
(JSC::operator!=):
- replaced impl() & ustring() with uid() [to get the raw impl] and publicName() [impl or null, if not an identifier].
* runtime/Structure.cpp:
(JSC::Structure::despecifyDictionaryFunction):
(JSC::Structure::addPropertyTransitionToExistingStructure):
(JSC::Structure::addPropertyTransition):
(JSC::Structure::attributeChangeTransition):
(JSC::Structure::get):
(JSC::Structure::despecifyFunction):
(JSC::Structure::putSpecificValue):
(JSC::Structure::remove):
(JSC::Structure::getPropertyNamesFromStructure):
* runtime/Structure.h:
(JSC::Structure::get):
- call uid() to get a PropertyName raw impl, for use as a key.
2012-04-30 Filip Pizlo <fpizlo@apple.com>
Bytecode dumps should contain data about the state of get_by_id caches
......@@ -47,6 +47,7 @@ all : \
KeywordLookup.h \
Lexer.lut.h \
MathObject.lut.h \
NamePrototype.lut.h \
NumberConstructor.lut.h \
NumberPrototype.lut.h \
ObjectConstructor.lut.h \
......
......@@ -16,6 +16,7 @@ LUT_FILES += \
runtime/JSGlobalObject.cpp \
runtime/JSONObject.cpp \
runtime/MathObject.cpp \
runtime/NamePrototype.cpp \
runtime/NumberConstructor.cpp \
runtime/NumberPrototype.cpp \
runtime/ObjectConstructor.cpp \
......
......@@ -20,6 +20,7 @@ javascriptcore_built_nosources += \
DerivedSources/JavaScriptCore/JSGlobalObject.lut.h \
DerivedSources/JavaScriptCore/JSONObject.lut.h \
DerivedSources/JavaScriptCore/MathObject.lut.h \
DerivedSources/JavaScriptCore/NamePrototype.lut.h \
DerivedSources/JavaScriptCore/NumberConstructor.lut.h \
DerivedSources/JavaScriptCore/NumberPrototype.lut.h \
DerivedSources/JavaScriptCore/ObjectConstructor.lut.h \
......@@ -507,6 +508,12 @@ javascriptcore_sources += \
Source/JavaScriptCore/runtime/MathObject.cpp \
Source/JavaScriptCore/runtime/MathObject.h \
Source/JavaScriptCore/runtime/MemoryStatistics.h \
Source/JavaScriptCore/runtime/NameConstructor.cpp \
Source/JavaScriptCore/runtime/NameConstructor.h \
Source/JavaScriptCore/runtime/NameInstance.cpp \
Source/JavaScriptCore/runtime/NameInstance.h \
Source/JavaScriptCore/runtime/NamePrototype.cpp \
Source/JavaScriptCore/runtime/NamePrototype.h \
Source/JavaScriptCore/runtime/NativeErrorConstructor.cpp \
Source/JavaScriptCore/runtime/NativeErrorConstructor.h \
Source/JavaScriptCore/runtime/NativeErrorPrototype.cpp \
......
......@@ -272,6 +272,9 @@
'runtime/MatchResult.h',
'runtime/MathObject.h',
'runtime/MemoryStatistics.h',
'runtime/NameConstructor.h',
'runtime/NameInstance.h',
'runtime/NamePrototype.h',
'runtime/NativeErrorConstructor.h',
'runtime/NativeErrorPrototype.h',
'runtime/NumberConstructor.h',
......@@ -497,6 +500,9 @@
'runtime/Lookup.cpp',
'runtime/MathObject.cpp',
'runtime/MemoryStatistics.cpp',
'runtime/NameConstructor.cpp',
'runtime/NameInstance.cpp',
'runtime/NamePrototype.cpp',
'runtime/NativeErrorConstructor.cpp',
'runtime/NativeErrorPrototype.cpp',
'runtime/NumberConstructor.cpp',
......@@ -549,6 +555,7 @@
'<(PRODUCT_DIR)/DerivedSources/JavaScriptCore/JSGlobalObject.lut.h',
'<(PRODUCT_DIR)/DerivedSources/JavaScriptCore/JSONObject.lut.h',
'<(PRODUCT_DIR)/DerivedSources/JavaScriptCore/MathObject.lut.h',
'<(PRODUCT_DIR)/DerivedSources/JavaScriptCore/NamePrototype.lut.h',
'<(PRODUCT_DIR)/DerivedSources/JavaScriptCore/NumberConstructor.lut.h',
'<(PRODUCT_DIR)/DerivedSources/JavaScriptCore/NumberPrototype.lut.h',
'<(PRODUCT_DIR)/DerivedSources/JavaScriptCore/ObjectConstructor.lut.h',
......
......@@ -957,6 +957,30 @@
RelativePath="..\..\runtime\MathObject.h"
>
</File>
<File
RelativePath="..\..\runtime\NameConstructor.cpp"
>
</File>
<File
RelativePath="..\..\runtime\NameConstructor.h"
>
</File>
<File
RelativePath="..\..\runtime\NameInstance.cpp"
>
</File>
<File
RelativePath="..\..\runtime\NameInstance.h"
>
</File>
<File
RelativePath="..\..\runtime\NamePrototype.cpp"
>
</File>
<File
RelativePath="..\..\runtime\NamePrototype.h"
>
</File>
<File
RelativePath="..\..\runtime\NativeErrorConstructor.cpp"
>
......@@ -2057,6 +2081,10 @@
RelativePath="$(ConfigurationBuildDir)\obj\$(ProjectName)\DerivedSources\MathObject.lut.h"
>
</File>
<File
RelativePath="$(ConfigurationBuildDir)\obj\$(ProjectName)\DerivedSources\NamePrototype.lut.h"
>
</File>
<File
RelativePath="$(ConfigurationBuildDir)\obj\$(ProjectName)\DerivedSources\NumberConstructor.lut.h"
>
......
......@@ -200,6 +200,9 @@ SOURCES += \
runtime/LiteralParser.cpp \
runtime/Lookup.cpp \
runtime/MathObject.cpp \
runtime/NameConstructor.cpp \
runtime/NameInstance.cpp \
runtime/NamePrototype.cpp \
runtime/NativeErrorConstructor.cpp \
runtime/NativeErrorPrototype.cpp \
runtime/NumberConstructor.cpp \
......
......@@ -36,6 +36,7 @@
#include "JSActivation.h"
#include "JSGlobalData.h"
#include "JSStaticScopeObject.h"
#include "NameInstance.h"
#include "Operations.h"
#if ENABLE(DFG_JIT)
......@@ -200,6 +201,11 @@ ALWAYS_INLINE static void DFG_OPERATION operationPutByValInternal(ExecState* exe
}
}
if (isName(property)) {
PutPropertySlot slot(strict);
baseValue.put(exec, jsCast<NameInstance*>(property.asCell())->privateName(), value, slot);
return;
}
// Don't put to an object if toString throws an exception.
Identifier ident(exec, property.toString(exec)->value(exec));
......@@ -307,6 +313,9 @@ EncodedJSValue DFG_OPERATION operationGetByVal(ExecState* exec, EncodedJSValue e
}
}
if (isName(property))
return JSValue::encode(baseValue.get(exec, jsCast<NameInstance*>(property.asCell())->privateName()));
Identifier ident(exec, property.toString(exec)->value(exec));
return JSValue::encode(baseValue.get(exec, ident));
}
......@@ -330,6 +339,9 @@ EncodedJSValue DFG_OPERATION operationGetByValCell(ExecState* exec, JSCell* base
return JSValue::encode(result);
}
if (isName(property))
return JSValue::encode(JSValue(base).get(exec, jsCast<NameInstance*>(property.asCell())->privateName()));
Identifier ident(exec, property.toString(exec)->value(exec));
return JSValue::encode(JSValue(base).get(exec, ident));
}
......
......@@ -90,6 +90,7 @@ namespace JSC {
static const HashTable* numberPrototypeTable(CallFrame* callFrame) { return callFrame->globalData().numberPrototypeTable; }
static const HashTable* objectConstructorTable(CallFrame* callFrame) { return callFrame->globalData().objectConstructorTable; }
static const HashTable* objectPrototypeTable(CallFrame* callFrame) { return callFrame->globalData().objectPrototypeTable; }
static const HashTable* privateNamePrototypeTable(CallFrame* callFrame) { return callFrame->globalData().privateNamePrototypeTable; }
static const HashTable* regExpTable(CallFrame* callFrame) { return callFrame->globalData().regExpTable; }
static const HashTable* regExpConstructorTable(CallFrame* callFrame) { return callFrame->globalData().regExpConstructorTable; }
static const HashTable* regExpPrototypeTable(CallFrame* callFrame) { return callFrame->globalData().regExpPrototypeTable; }
......
......@@ -50,6 +50,7 @@
#include "LiteralParser.h"
#include "JSStaticScopeObject.h"
#include "JSString.h"
#include "NameInstance.h"
#include "ObjectPrototype.h"
#include "Operations.h"
#include "Parser.h"
......@@ -2795,6 +2796,8 @@ JSValue Interpreter::privateExecute(ExecutionFlag flag, RegisterFile* registerFi
uint32_t i;
if (propName.getUInt32(i))
callFrame->uncheckedR(dst) = jsBoolean(baseObj->hasProperty(callFrame, i));
else if (isName(propName))
callFrame->uncheckedR(dst) = jsBoolean(baseObj->hasProperty(callFrame, jsCast<NameInstance*>(propName.asCell())->privateName()));
else {
Identifier property(callFrame, propName.toString(callFrame)->value(callFrame));
CHECK_FOR_EXCEPTION();
......@@ -3775,7 +3778,9 @@ skip_id_custom_self:
result = asString(baseValue)->getIndex(callFrame, i);
else
result = baseValue.get(callFrame, i);
} else {
} else if (isName(subscript))
result = baseValue.get(callFrame, jsCast<NameInstance*>(subscript.asCell())->privateName());
else {
Identifier property(callFrame, subscript.toString(callFrame)->value(callFrame));
result = baseValue.get(callFrame, property);
}
......@@ -3813,6 +3818,9 @@ skip_id_custom_self:
jsArray->JSArray::putByIndex(jsArray, callFrame, i, callFrame->r(value).jsValue(), codeBlock->isStrictMode());
} else
baseValue.putByIndex(callFrame, i, callFrame->r(value).jsValue(), codeBlock->isStrictMode());
} else if (isName(subscript)) {
PutPropertySlot slot(codeBlock->isStrictMode());
baseValue.put(callFrame, jsCast<NameInstance*>(subscript.asCell())->privateName(), callFrame->r(value).jsValue(), slot);
} else {
Identifier property(callFrame, subscript.toString(callFrame)->value(callFrame));
if (!globalData->exception) { // Don't put to an object if toString threw an exception.
......@@ -3844,6 +3852,8 @@ skip_id_custom_self:
uint32_t i;
if (subscript.getUInt32(i))
result = baseObj->methodTable()->deletePropertyByIndex(baseObj, callFrame, i);
else if (isName(subscript))
result = baseObj->methodTable()->deleteProperty(baseObj, callFrame, jsCast<NameInstance*>(subscript.asCell())->privateName());
else {
CHECK_FOR_EXCEPTION();
Identifier property(callFrame, subscript.toString(callFrame)->value(callFrame));
......
......@@ -54,6 +54,7 @@
#include "JSPropertyNameIterator.h"
#include "JSStaticScopeObject.h"
#include "JSString.h"
#include "NameInstance.h"
#include "ObjectPrototype.h"
#include "Operations.h"
#include "Parser.h"
......@@ -2447,7 +2448,13 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, op_get_by_val)
CHECK_FOR_EXCEPTION();
return JSValue::encode(result);
}
if (isName(subscript)) {
JSValue result = baseValue.get(callFrame, jsCast<NameInstance*>(subscript.asCell())->privateName());
CHECK_FOR_EXCEPTION();
return JSValue::encode(result);
}
Identifier property(callFrame, subscript.toString(callFrame)->value(callFrame));
JSValue result = baseValue.get(callFrame, property);
CHECK_FOR_EXCEPTION_AT_END();
......@@ -2474,7 +2481,9 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, op_get_by_val_string)
if (!isJSString(baseValue))
ctiPatchCallByReturnAddress(callFrame->codeBlock(), STUB_RETURN_ADDRESS, FunctionPtr(cti_op_get_by_val));
}
} else {
} else if (isName(subscript))
result = baseValue.get(callFrame, jsCast<NameInstance*>(subscript.asCell())->privateName());
else {
Identifier property(callFrame, subscript.toString(callFrame)->value(callFrame));
result = baseValue.get(callFrame, property);
}
......@@ -2520,6 +2529,9 @@ DEFINE_STUB_FUNCTION(void, op_put_by_val)
JSArray::putByIndex(jsArray, callFrame, i, value, callFrame->codeBlock()->isStrictMode());
} else
baseValue.putByIndex(callFrame, i, value, callFrame->codeBlock()->isStrictMode());
} else if (isName(subscript)) {
PutPropertySlot slot(callFrame->codeBlock()->isStrictMode());
baseValue.put(callFrame, jsCast<NameInstance*>(subscript.asCell())->privateName(), value, slot);
} else {
Identifier property(callFrame, subscript.toString(callFrame)->value(callFrame));
if (!stackFrame.globalData->exception) { // Don't put to an object if toString threw an exception.
......@@ -3241,6 +3253,9 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, op_in)
if (propName.getUInt32(i))
return JSValue::encode(jsBoolean(baseObj->hasProperty(callFrame, i)));
if (isName(propName))
return JSValue::encode(jsBoolean(baseObj->hasProperty(callFrame, jsCast<NameInstance*>(propName.asCell())->privateName())));
Identifier property(callFrame, propName.toString(callFrame)->value(callFrame));
CHECK_FOR_EXCEPTION();
return JSValue::encode(jsBoolean(baseObj->hasProperty(callFrame, property)));
......@@ -3353,6 +3368,8 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, op_del_by_val)
uint32_t i;
if (subscript.getUInt32(i))
result = baseObj->methodTable()->deletePropertyByIndex(baseObj, callFrame, i);
else if (isName(subscript))
result = baseObj->methodTable()->deleteProperty(baseObj, callFrame, jsCast<NameInstance*>(subscript.asCell())->privateName());
else {
CHECK_FOR_EXCEPTION();
Identifier property(callFrame, subscript.toString(callFrame)->value(callFrame));
......
......@@ -952,6 +952,9 @@ inline JSValue getByVal(ExecState* exec, JSValue baseValue, JSValue subscript)
return baseValue.get(exec, i);
}
if (isName(subscript))
return baseValue.get(exec, jsCast<NameInstance*>(subscript.asCell())->privateName());
Identifier property(exec, subscript.toString(exec)->value(exec));
return baseValue.get(exec, property);
......@@ -1004,7 +1007,13 @@ LLINT_SLOW_PATH_DECL(slow_path_put_by_val)
baseValue.putByIndex(exec, i, value, exec->codeBlock()->isStrictMode());
LLINT_END();
}
if (isName(subscript)) {
PutPropertySlot slot(exec->codeBlock()->isStrictMode());
baseValue.put(exec, jsCast<NameInstance*>(subscript.asCell())->privateName(), value, slot);
LLINT_END();
}
Identifier property(exec, subscript.toString(exec)->value(exec));
LLINT_CHECK_EXCEPTION();
PutPropertySlot slot(exec->codeBlock()->isStrictMode());
......@@ -1025,6 +1034,8 @@ LLINT_SLOW_PATH_DECL(slow_path_del_by_val)
uint32_t i;
if (subscript.getUInt32(i))
couldDelete = baseObject->methodTable()->deletePropertyByIndex(baseObject, exec, i);
else if (isName(subscript))
couldDelete = baseObject->methodTable()->deleteProperty(baseObject, exec, jsCast<NameInstance*>(subscript.asCell())->privateName());
else {
LLINT_CHECK_EXCEPTION();
Identifier property(exec, subscript.toString(exec)->value(exec));
......
......@@ -30,6 +30,7 @@
#include "CodeSpecializationKind.h"
#include "ExceptionHelpers.h"
#include "JSArray.h"
#include "NameInstance.h"
namespace JSC {
......@@ -109,6 +110,9 @@ inline bool opIn(ExecState* exec, JSValue propName, JSValue baseVal)
if (propName.getUInt32(i))
return baseObj->hasProperty(exec, i);
if (isName(propName))
return baseObj->hasProperty(exec, jsCast<NameInstance*>(propName.asCell())->privateName());
Identifier property(exec, propName.toString(exec)->value(exec));
if (exec->globalData().exception)
return false;
......
......@@ -92,7 +92,7 @@ void JSActivation::visitChildren(JSCell* cell, SlotVisitor& visitor)
inline bool JSActivation::symbolTableGet(PropertyName propertyName, PropertySlot& slot)
{
SymbolTableEntry entry = symbolTable().inlineGet(propertyName.impl());
SymbolTableEntry entry = symbolTable().inlineGet(propertyName.publicName());
if (entry.isNull())
return false;
if (m_isTornOff && entry.getIndex() >= m_numCapturedVars)
......@@ -107,7 +107,7 @@ inline bool JSActivation::symbolTablePut(ExecState* exec, PropertyName propertyN
JSGlobalData& globalData = exec->globalData();
ASSERT(!Heap::heap(value) || Heap::heap(value) == Heap::heap(this));
SymbolTableEntry entry = symbolTable().inlineGet(propertyName.impl());
SymbolTableEntry entry = symbolTable().inlineGet(propertyName.publicName());
if (entry.isNull())
return false;
if (entry.isReadOnly()) {
......@@ -141,7 +141,7 @@ inline bool JSActivation::symbolTablePutWithAttributes(JSGlobalData& globalData,
{
ASSERT(!Heap::heap(value) || Heap::heap(value) == Heap::heap(this));
SymbolTable::iterator iter = symbolTable().find(propertyName.impl());
SymbolTable::iterator iter = symbolTable().find(propertyName.publicName());
if (iter == symbolTable().end())
return false;
SymbolTableEntry& entry = iter->second;
......
......@@ -86,6 +86,7 @@ extern const HashTable numberConstructorTable;
extern const HashTable numberPrototypeTable;
JS_EXPORTDATA extern const HashTable objectConstructorTable;