Commit 62475f81 authored by rniwa@webkit.org's avatar rniwa@webkit.org

Function names on Object.prototype should be common identifiers

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

Reviewed by Darin Adler.

Source/JavaScriptCore: 

Patch written by Sam Weinig. Make Object's prototype function names common identififers since they're used frequently.

* runtime/CommonIdentifiers.h:
* runtime/FunctionConstructor.cpp:
(JSC::constructFunction):
* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::reset):
* runtime/JSObject.h:
* runtime/ObjectPrototype.cpp:
(JSC::ObjectPrototype::finishCreation):
* runtime/StringPrototype.cpp:
(JSC::StringPrototype::finishCreation):

Source/WebCore: 

Use the added common identifiers.

* bindings/js/JSDOMWindowBase.cpp:
(WebCore::JSDOMWindowBase::finishCreation):
(WebCore::JSDOMWindowBase::updateDocument):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@151605 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 79ee7751
2013-06-14 Ryosuke Niwa <rniwa@webkit.org>
Function names on Object.prototype should be common identifiers
https://bugs.webkit.org/show_bug.cgi?id=117614
Reviewed by Darin Adler.
Patch written by Sam Weinig. Make Object's prototype function names common identififers since they're used frequently.
* runtime/CommonIdentifiers.h:
* runtime/FunctionConstructor.cpp:
(JSC::constructFunction):
* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::reset):
* runtime/JSObject.h:
* runtime/ObjectPrototype.cpp:
(JSC::ObjectPrototype::finishCreation):
* runtime/StringPrototype.cpp:
(JSC::StringPrototype::finishCreation):
2013-06-13 Ryosuke Niwa <rniwa@webkit.org>
Remove LiteralIdentifierTable
......
......@@ -27,9 +27,33 @@
// MarkedArgumentBuffer of property names, passed to a macro so we can do set them up various
// ways without repeating the list.
#define JSC_COMMON_IDENTIFIERS_EACH_PROPERTY_NAME(macro) \
macro(Array) \
macro(Boolean) \
macro(Date) \
macro(Error) \
macro(EvalError) \
macro(Function) \
macro(Infinity) \
macro(JSON) \
macro(Math) \
macro(NaN) \
macro(Number) \
macro(Object) \
macro(RangeError) \
macro(ReferenceError) \
macro(RegExp) \
macro(String) \
macro(SyntaxError) \
macro(TypeError) \
macro(URIError) \
macro(UTC) \
macro(__defineGetter__) \
macro(__defineSetter__) \
macro(__lookupGetter__) \
macro(__lookupSetter__) \
macro(anonymous) \
macro(apply) \
macro(arguments) \
macro(Array) \
macro(bind) \
macro(bytecode) \
macro(bytecodeIndex) \
......@@ -47,14 +71,16 @@
macro(counters) \
macro(description) \
macro(descriptions) \
macro(displayName) \
macro(document) \
macro(enumerable) \
macro(eval) \
macro(exec) \
macro(executionCount) \
macro(exitKind) \
macro(fromCharCode) \
macro(global) \
macro(get) \
macro(global) \
macro(hasOwnProperty) \
macro(hash) \
macro(header) \
......@@ -67,16 +93,16 @@
macro(isArray) \
macro(isPrototypeOf) \
macro(isWatchpoint) \
macro(join) \
macro(lastIndex) \
macro(length) \
macro(message) \
macro(multiline) \
macro(name) \
macro(now) \
macro(numInlinedCalls) \
macro(numInlinedGetByIds) \
macro(numInlinedPutByIds) \
macro(numInlinedCalls) \
macro(Object) \
macro(opcode) \
macro(origin) \
macro(osrExitSites) \
......@@ -97,16 +123,10 @@
macro(toLocaleString) \
macro(toPrecision) \
macro(toString) \
macro(UTC) \
macro(value) \
macro(valueOf) \
macro(writable) \
macro(displayName) \
macro(join) \
macro(__defineGetter__) \
macro(__defineSetter__) \
macro(__lookupGetter__) \
macro(__lookupSetter__)
macro(window) \
macro(writable)
#define JSC_COMMON_IDENTIFIERS_EACH_KEYWORD(macro) \
macro(null) \
......
......@@ -124,7 +124,7 @@ JSObject* constructFunctionSkippingEvalEnabledCheck(ExecState* exec, JSGlobalObj
// ECMA 15.3.2 The Function Constructor
JSObject* constructFunction(ExecState* exec, JSGlobalObject* globalObject, const ArgList& args)
{
return constructFunction(exec, globalObject, args, Identifier(exec, "anonymous"), String(), TextPosition::minimumPosition());
return constructFunction(exec, globalObject, args, exec->propertyNames().anonymous, String(), TextPosition::minimumPosition());
}
} // namespace JSC
......@@ -297,31 +297,31 @@ void JSGlobalObject::reset(JSValue prototype)
m_errorPrototype->putDirectWithoutTransition(exec->vm(), exec->propertyNames().constructor, m_errorConstructor.get(), DontEnum);
putDirectWithoutTransition(exec->vm(), exec->propertyNames().Object, objectConstructor, DontEnum);
putDirectWithoutTransition(exec->vm(), Identifier(exec, "Function"), functionConstructor, DontEnum);
putDirectWithoutTransition(exec->vm(), exec->propertyNames().Function, functionConstructor, DontEnum);
putDirectWithoutTransition(exec->vm(), exec->propertyNames().Array, arrayConstructor, DontEnum);
putDirectWithoutTransition(exec->vm(), Identifier(exec, "Boolean"), booleanConstructor, DontEnum);
putDirectWithoutTransition(exec->vm(), Identifier(exec, "String"), stringConstructor, DontEnum);
putDirectWithoutTransition(exec->vm(), Identifier(exec, "Number"), numberConstructor, DontEnum);
putDirectWithoutTransition(exec->vm(), Identifier(exec, "Date"), dateConstructor, DontEnum);
putDirectWithoutTransition(exec->vm(), Identifier(exec, "RegExp"), m_regExpConstructor.get(), DontEnum);
putDirectWithoutTransition(exec->vm(), Identifier(exec, "Error"), m_errorConstructor.get(), DontEnum);
putDirectWithoutTransition(exec->vm(), Identifier(exec, "EvalError"), m_evalErrorConstructor.get(), DontEnum);
putDirectWithoutTransition(exec->vm(), Identifier(exec, "RangeError"), m_rangeErrorConstructor.get(), DontEnum);
putDirectWithoutTransition(exec->vm(), Identifier(exec, "ReferenceError"), m_referenceErrorConstructor.get(), DontEnum);
putDirectWithoutTransition(exec->vm(), Identifier(exec, "SyntaxError"), m_syntaxErrorConstructor.get(), DontEnum);
putDirectWithoutTransition(exec->vm(), Identifier(exec, "TypeError"), m_typeErrorConstructor.get(), DontEnum);
putDirectWithoutTransition(exec->vm(), Identifier(exec, "URIError"), m_URIErrorConstructor.get(), DontEnum);
putDirectWithoutTransition(exec->vm(), exec->propertyNames().Boolean, booleanConstructor, DontEnum);
putDirectWithoutTransition(exec->vm(), exec->propertyNames().String, stringConstructor, DontEnum);
putDirectWithoutTransition(exec->vm(), exec->propertyNames().Number, numberConstructor, DontEnum);
putDirectWithoutTransition(exec->vm(), exec->propertyNames().Date, dateConstructor, DontEnum);
putDirectWithoutTransition(exec->vm(), exec->propertyNames().RegExp, m_regExpConstructor.get(), DontEnum);
putDirectWithoutTransition(exec->vm(), exec->propertyNames().Error, m_errorConstructor.get(), DontEnum);
putDirectWithoutTransition(exec->vm(), exec->propertyNames().EvalError, m_evalErrorConstructor.get(), DontEnum);
putDirectWithoutTransition(exec->vm(), exec->propertyNames().RangeError, m_rangeErrorConstructor.get(), DontEnum);
putDirectWithoutTransition(exec->vm(), exec->propertyNames().ReferenceError, m_referenceErrorConstructor.get(), DontEnum);
putDirectWithoutTransition(exec->vm(), exec->propertyNames().SyntaxError, m_syntaxErrorConstructor.get(), DontEnum);
putDirectWithoutTransition(exec->vm(), exec->propertyNames().TypeError, m_typeErrorConstructor.get(), DontEnum);
putDirectWithoutTransition(exec->vm(), exec->propertyNames().URIError, m_URIErrorConstructor.get(), DontEnum);
m_evalFunction.set(exec->vm(), this, JSFunction::create(exec, this, 1, exec->propertyNames().eval.string(), globalFuncEval));
putDirectWithoutTransition(exec->vm(), exec->propertyNames().eval, m_evalFunction.get(), DontEnum);
putDirectWithoutTransition(exec->vm(), Identifier(exec, "JSON"), JSONObject::create(exec, this, JSONObject::createStructure(exec->vm(), this, m_objectPrototype.get())), DontEnum);
putDirectWithoutTransition(exec->vm(), Identifier(exec, "Math"), MathObject::create(exec, this, MathObject::createStructure(exec->vm(), this, m_objectPrototype.get())), DontEnum);
putDirectWithoutTransition(exec->vm(), exec->propertyNames().JSON, JSONObject::create(exec, this, JSONObject::createStructure(exec->vm(), this, m_objectPrototype.get())), DontEnum);
putDirectWithoutTransition(exec->vm(), exec->propertyNames().Math, MathObject::create(exec, this, MathObject::createStructure(exec->vm(), this, m_objectPrototype.get())), DontEnum);
GlobalPropertyInfo staticGlobals[] = {
GlobalPropertyInfo(Identifier(exec, "NaN"), jsNaN(), DontEnum | DontDelete | ReadOnly),
GlobalPropertyInfo(Identifier(exec, "Infinity"), jsNumber(std::numeric_limits<double>::infinity()), DontEnum | DontDelete | ReadOnly),
GlobalPropertyInfo(Identifier(exec, "undefined"), jsUndefined(), DontEnum | DontDelete | ReadOnly)
GlobalPropertyInfo(exec->propertyNames().NaN, jsNaN(), DontEnum | DontDelete | ReadOnly),
GlobalPropertyInfo(exec->propertyNames().Infinity, jsNumber(std::numeric_limits<double>::infinity()), DontEnum | DontDelete | ReadOnly),
GlobalPropertyInfo(exec->propertyNames().undefinedKeyword, jsUndefined(), DontEnum | DontDelete | ReadOnly)
};
addStaticGlobals(staticGlobals, WTF_ARRAY_LENGTH(staticGlobals));
......
......@@ -1460,13 +1460,23 @@ inline int offsetRelativeToBase(PropertyOffset offset)
COMPILE_ASSERT(!(sizeof(JSObject) % sizeof(WriteBarrierBase<Unknown>)), JSObject_inline_storage_has_correct_alignment);
ALWAYS_INLINE Identifier makeIdentifier(ExecState* exec, const char* name)
{
return Identifier(exec, name);
}
ALWAYS_INLINE Identifier makeIdentifier(ExecState*, const Identifier& name)
{
return name;
}
// Helper for defining native functions, if you're not using a static hash table.
// Use this macro from within finishCreation() methods in prototypes. This assumes
// you've defined variables called exec, globalObject, and vm, and they
// have the expected meanings.
#define JSC_NATIVE_INTRINSIC_FUNCTION(jsName, cppName, attributes, length, intrinsic) \
putDirectNativeFunction(\
exec, globalObject, Identifier(exec, (jsName)), (length), cppName, \
exec, globalObject, makeIdentifier(exec, (jsName)), (length), cppName, \
(intrinsic), (attributes))
// As above, but this assumes that the function you're defining doesn't have an
......
......@@ -57,16 +57,16 @@ void ObjectPrototype::finishCreation(ExecState* exec, JSGlobalObject* globalObje
ASSERT(inherits(&s_info));
vm.prototypeMap.addPrototype(this);
JSC_NATIVE_FUNCTION("toString", objectProtoFuncToString, DontEnum, 0);
JSC_NATIVE_FUNCTION("toLocaleString", objectProtoFuncToLocaleString, DontEnum, 0);
JSC_NATIVE_FUNCTION("valueOf", objectProtoFuncValueOf, DontEnum, 0);
JSC_NATIVE_FUNCTION("hasOwnProperty", objectProtoFuncHasOwnProperty, DontEnum, 1);
JSC_NATIVE_FUNCTION("propertyIsEnumerable", objectProtoFuncPropertyIsEnumerable, DontEnum, 1);
JSC_NATIVE_FUNCTION("isPrototypeOf", objectProtoFuncIsPrototypeOf, DontEnum, 1);
JSC_NATIVE_FUNCTION("__defineGetter__", objectProtoFuncDefineGetter, DontEnum, 2);
JSC_NATIVE_FUNCTION("__defineSetter__", objectProtoFuncDefineSetter, DontEnum, 2);
JSC_NATIVE_FUNCTION("__lookupGetter__", objectProtoFuncLookupGetter, DontEnum, 1);
JSC_NATIVE_FUNCTION("__lookupSetter__", objectProtoFuncLookupSetter, DontEnum, 1);
JSC_NATIVE_FUNCTION(vm.propertyNames->toString, objectProtoFuncToString, DontEnum, 0);
JSC_NATIVE_FUNCTION(vm.propertyNames->toLocaleString, objectProtoFuncToLocaleString, DontEnum, 0);
JSC_NATIVE_FUNCTION(vm.propertyNames->valueOf, objectProtoFuncValueOf, DontEnum, 0);
JSC_NATIVE_FUNCTION(vm.propertyNames->hasOwnProperty, objectProtoFuncHasOwnProperty, DontEnum, 1);
JSC_NATIVE_FUNCTION(vm.propertyNames->propertyIsEnumerable, objectProtoFuncPropertyIsEnumerable, DontEnum, 1);
JSC_NATIVE_FUNCTION(vm.propertyNames->isPrototypeOf, objectProtoFuncIsPrototypeOf, DontEnum, 1);
JSC_NATIVE_FUNCTION(vm.propertyNames->__defineGetter__, objectProtoFuncDefineGetter, DontEnum, 2);
JSC_NATIVE_FUNCTION(vm.propertyNames->__defineSetter__, objectProtoFuncDefineSetter, DontEnum, 2);
JSC_NATIVE_FUNCTION(vm.propertyNames->__lookupGetter__, objectProtoFuncLookupGetter, DontEnum, 1);
JSC_NATIVE_FUNCTION(vm.propertyNames->__lookupSetter__, objectProtoFuncLookupSetter, DontEnum, 1);
}
ObjectPrototype* ObjectPrototype::create(ExecState* exec, JSGlobalObject* globalObject, Structure* structure)
......
......@@ -97,8 +97,8 @@ void StringPrototype::finishCreation(ExecState* exec, JSGlobalObject* globalObje
Base::finishCreation(vm, nameAndMessage);
ASSERT(inherits(&s_info));
JSC_NATIVE_INTRINSIC_FUNCTION("toString", stringProtoFuncToString, DontEnum, 0, StringPrototypeValueOfIntrinsic);
JSC_NATIVE_INTRINSIC_FUNCTION("valueOf", stringProtoFuncToString, DontEnum, 0, StringPrototypeValueOfIntrinsic);
JSC_NATIVE_INTRINSIC_FUNCTION(vm.propertyNames->toString, stringProtoFuncToString, DontEnum, 0, StringPrototypeValueOfIntrinsic);
JSC_NATIVE_INTRINSIC_FUNCTION(vm.propertyNames->valueOf, stringProtoFuncToString, DontEnum, 0, StringPrototypeValueOfIntrinsic);
JSC_NATIVE_INTRINSIC_FUNCTION("charAt", stringProtoFuncCharAt, DontEnum, 1, CharAtIntrinsic);
JSC_NATIVE_INTRINSIC_FUNCTION("charCodeAt", stringProtoFuncCharCodeAt, DontEnum, 1, CharCodeAtIntrinsic);
JSC_NATIVE_FUNCTION("concat", stringProtoFuncConcat, DontEnum, 1);
......
2013-06-14 Ryosuke Niwa <rniwa@webkit.org>
Function names on Object.prototype should be common identifiers
https://bugs.webkit.org/show_bug.cgi?id=117614
Reviewed by Darin Adler.
Use the added common identifiers.
* bindings/js/JSDOMWindowBase.cpp:
(WebCore::JSDOMWindowBase::finishCreation):
(WebCore::JSDOMWindowBase::updateDocument):
2013-06-14 Arpita Bahuguna <a.bah@samsung.com>
Editing: wrong text position when you click enter on the text behind the image
......@@ -65,8 +65,8 @@ void JSDOMWindowBase::finishCreation(VM& vm, JSDOMWindowShell* shell)
ASSERT(inherits(&s_info));
GlobalPropertyInfo staticGlobals[] = {
GlobalPropertyInfo(Identifier(globalExec(), "document"), jsNull(), DontDelete | ReadOnly),
GlobalPropertyInfo(Identifier(globalExec(), "window"), m_shell, DontDelete | ReadOnly)
GlobalPropertyInfo(vm.propertyNames->document, jsNull(), DontDelete | ReadOnly),
GlobalPropertyInfo(vm.propertyNames->window, m_shell, DontDelete | ReadOnly)
};
addStaticGlobals(staticGlobals, WTF_ARRAY_LENGTH(staticGlobals));
......@@ -81,7 +81,7 @@ void JSDOMWindowBase::updateDocument()
{
ASSERT(m_impl->document());
ExecState* exec = globalExec();
symbolTablePutWithAttributes(this, exec->vm(), Identifier(exec, "document"), toJS(exec, this, m_impl->document()), DontDelete | ReadOnly);
symbolTablePutWithAttributes(this, exec->vm(), exec->vm().propertyNames->document, toJS(exec, this, m_impl->document()), DontDelete | ReadOnly);
}
ScriptExecutionContext* JSDOMWindowBase::scriptExecutionContext() const
......
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