Title: [151548] branches/dfgFourthTier/Source/_javascript_Core
Revision
151548
Author
[email protected]
Date
2013-06-13 08:29:50 -0700 (Thu, 13 Jun 2013)

Log Message

The Math object should not be polymorphic
https://bugs.webkit.org/show_bug.cgi?id=117576

Reviewed by Oliver Hunt.

Fill in the Math object eagerly, to avoid its structure changing during
execution. There are lots of ways to skin this cat; this one seemed
easiest, and justified given the relative hotness of math operations.

20% speedup on DSP-filtrr tests, small speedups on a few Kraken tests.

* DerivedSources.make:
* _javascript_Core.order:
* create_hash_table:
* interpreter/CallFrame.h:
(JSC::ExecState::jsonTable): Removed the Math object's static table.

* runtime/JSObject.cpp:
(JSC::JSObject::putDirectNativeFunctionWithoutTransition):
* runtime/JSObject.h:
* runtime/MathObject.cpp:
(JSC::MathObject::finishCreation):
* runtime/MathObject.h:
(JSC::MathObject::create): Set up the Math object at construction time.

* runtime/VM.cpp:
(JSC::VM::VM):
(JSC::VM::~VM):
* runtime/VM.h: Removed the Math object's static table.

Modified Paths

Diff

Modified: branches/dfgFourthTier/Source/_javascript_Core/ChangeLog (151547 => 151548)


--- branches/dfgFourthTier/Source/_javascript_Core/ChangeLog	2013-06-13 15:05:14 UTC (rev 151547)
+++ branches/dfgFourthTier/Source/_javascript_Core/ChangeLog	2013-06-13 15:29:50 UTC (rev 151548)
@@ -1,3 +1,35 @@
+2013-06-12  Geoffrey Garen  <[email protected]>
+
+        The Math object should not be polymorphic
+        https://bugs.webkit.org/show_bug.cgi?id=117576
+
+        Reviewed by Oliver Hunt.
+
+        Fill in the Math object eagerly, to avoid its structure changing during
+        execution. There are lots of ways to skin this cat; this one seemed
+        easiest, and justified given the relative hotness of math operations.
+
+        20% speedup on DSP-filtrr tests, small speedups on a few Kraken tests.
+
+        * DerivedSources.make:
+        * _javascript_Core.order:
+        * create_hash_table:
+        * interpreter/CallFrame.h:
+        (JSC::ExecState::jsonTable): Removed the Math object's static table.
+
+        * runtime/JSObject.cpp:
+        (JSC::JSObject::putDirectNativeFunctionWithoutTransition):
+        * runtime/JSObject.h:
+        * runtime/MathObject.cpp:
+        (JSC::MathObject::finishCreation):
+        * runtime/MathObject.h:
+        (JSC::MathObject::create): Set up the Math object at construction time.
+
+        * runtime/VM.cpp:
+        (JSC::VM::VM):
+        (JSC::VM::~VM):
+        * runtime/VM.h: Removed the Math object's static table.
+
 2013-06-11  Michael Saboff  <[email protected]>
 
         Unreviewed, rolled back in http://trac.webkit.org/changeset/151362.

Modified: branches/dfgFourthTier/Source/_javascript_Core/DerivedSources.make (151547 => 151548)


--- branches/dfgFourthTier/Source/_javascript_Core/DerivedSources.make	2013-06-13 15:05:14 UTC (rev 151547)
+++ branches/dfgFourthTier/Source/_javascript_Core/DerivedSources.make	2013-06-13 15:29:50 UTC (rev 151548)
@@ -45,7 +45,6 @@
     JSGlobalObject.lut.h \
     KeywordLookup.h \
     Lexer.lut.h \
-    MathObject.lut.h \
     NamePrototype.lut.h \
     NumberConstructor.lut.h \
     NumberPrototype.lut.h \

Modified: branches/dfgFourthTier/Source/_javascript_Core/_javascript_Core.order (151547 => 151548)


--- branches/dfgFourthTier/Source/_javascript_Core/_javascript_Core.order	2013-06-13 15:05:14 UTC (rev 151547)
+++ branches/dfgFourthTier/Source/_javascript_Core/_javascript_Core.order	2013-06-13 15:29:50 UTC (rev 151548)
@@ -1973,7 +1973,6 @@
 __ZN3JSC3JIT29emit_op_throw_reference_errorEPNS_11InstructionE
 _cti_op_throw_reference_error
 __ZN3JSC16parseIntOverflowEPKcii
-__ZN3JSC9ExecState9mathTableEPS0_
 __ZN3JSCL17mathProtoFuncACosEPNS_9ExecStateE
 __ZN3JSCL17mathProtoFuncASinEPNS_9ExecStateE
 __ZN3JSCL17mathProtoFuncATanEPNS_9ExecStateE

Modified: branches/dfgFourthTier/Source/_javascript_Core/create_hash_table (151547 => 151548)


--- branches/dfgFourthTier/Source/_javascript_Core/create_hash_table	2013-06-13 15:05:14 UTC (rev 151547)
+++ branches/dfgFourthTier/Source/_javascript_Core/create_hash_table	2013-06-13 15:29:50 UTC (rev 151548)
@@ -272,18 +272,6 @@
 
         my $intrinsic = "NoIntrinsic";
         $intrinsic = "FromCharCodeIntrinsic" if ($key eq "fromCharCode");
-        if ($name eq "mathTable") {
-            $intrinsic = "MinIntrinsic" if ($key eq "min");
-            $intrinsic = "MaxIntrinsic" if ($key eq "max");
-            $intrinsic = "SqrtIntrinsic" if ($key eq "sqrt");
-            $intrinsic = "PowIntrinsic" if ($key eq "pow");
-            $intrinsic = "AbsIntrinsic" if ($key eq "abs");
-            $intrinsic = "FloorIntrinsic" if ($key eq "floor");
-            $intrinsic = "CeilIntrinsic" if ($key eq "ceil");
-            $intrinsic = "RoundIntrinsic" if ($key eq "round");
-            $intrinsic = "ExpIntrinsic" if ($key eq "exp");
-            $intrinsic = "LogIntrinsic" if ($key eq "log");
-        }
         if ($name eq "arrayPrototypeTable") {
             $intrinsic = "ArrayPushIntrinsic" if ($key eq "push");
             $intrinsic = "ArrayPopIntrinsic" if ($key eq "pop");

Modified: branches/dfgFourthTier/Source/_javascript_Core/interpreter/CallFrame.h (151547 => 151548)


--- branches/dfgFourthTier/Source/_javascript_Core/interpreter/CallFrame.h	2013-06-13 15:05:14 UTC (rev 151547)
+++ branches/dfgFourthTier/Source/_javascript_Core/interpreter/CallFrame.h	2013-06-13 15:29:50 UTC (rev 151548)
@@ -91,7 +91,6 @@
         static const HashTable* errorPrototypeTable(CallFrame* callFrame) { return callFrame->vm().errorPrototypeTable; }
         static const HashTable* globalObjectTable(CallFrame* callFrame) { return callFrame->vm().globalObjectTable; }
         static const HashTable* jsonTable(CallFrame* callFrame) { return callFrame->vm().jsonTable; }
-        static const HashTable* mathTable(CallFrame* callFrame) { return callFrame->vm().mathTable; }
         static const HashTable* numberConstructorTable(CallFrame* callFrame) { return callFrame->vm().numberConstructorTable; }
         static const HashTable* numberPrototypeTable(CallFrame* callFrame) { return callFrame->vm().numberPrototypeTable; }
         static const HashTable* objectConstructorTable(CallFrame* callFrame) { return callFrame->vm().objectConstructorTable; }

Modified: branches/dfgFourthTier/Source/_javascript_Core/runtime/JSObject.cpp (151547 => 151548)


--- branches/dfgFourthTier/Source/_javascript_Core/runtime/JSObject.cpp	2013-06-13 15:05:14 UTC (rev 151547)
+++ branches/dfgFourthTier/Source/_javascript_Core/runtime/JSObject.cpp	2013-06-13 15:29:50 UTC (rev 151548)
@@ -2189,11 +2189,19 @@
     StringImpl* name = propertyName.publicName();
     ASSERT(name);
     
-    JSFunction* function =
-        JSFunction::create(exec, globalObject, functionLength, name, nativeFunction, intrinsic);
+    JSFunction* function = JSFunction::create(exec, globalObject, functionLength, name, nativeFunction, intrinsic);
     putDirect(exec->vm(), propertyName, function, attributes);
 }
 
+void JSObject::putDirectNativeFunctionWithoutTransition(ExecState* exec, JSGlobalObject* globalObject, const PropertyName& propertyName, unsigned functionLength, NativeFunction nativeFunction, Intrinsic intrinsic, unsigned attributes)
+{
+    StringImpl* name = propertyName.publicName();
+    ASSERT(name);
+    
+    JSFunction* function = JSFunction::create(exec, globalObject, functionLength, name, nativeFunction, intrinsic);
+    putDirectWithoutTransition(exec->vm(), propertyName, function, attributes);
+}
+
 ALWAYS_INLINE unsigned JSObject::getNewVectorLength(unsigned currentVectorLength, unsigned currentLength, unsigned desiredLength)
 {
     ASSERT(desiredLength <= MAX_STORAGE_VECTOR_LENGTH);

Modified: branches/dfgFourthTier/Source/_javascript_Core/runtime/JSObject.h (151547 => 151548)


--- branches/dfgFourthTier/Source/_javascript_Core/runtime/JSObject.h	2013-06-13 15:05:14 UTC (rev 151547)
+++ branches/dfgFourthTier/Source/_javascript_Core/runtime/JSObject.h	2013-06-13 15:29:50 UTC (rev 151548)
@@ -563,6 +563,7 @@
     void putDirectUndefined(PropertyOffset offset) { locationForOffset(offset)->setUndefined(); }
 
     void putDirectNativeFunction(ExecState*, JSGlobalObject*, const PropertyName&, unsigned functionLength, NativeFunction, Intrinsic, unsigned attributes);
+    void putDirectNativeFunctionWithoutTransition(ExecState*, JSGlobalObject*, const PropertyName&, unsigned functionLength, NativeFunction, Intrinsic, unsigned attributes);
 
     JS_EXPORT_PRIVATE static bool defineOwnProperty(JSObject*, ExecState*, PropertyName, PropertyDescriptor&, bool shouldThrow);
 

Modified: branches/dfgFourthTier/Source/_javascript_Core/runtime/MathObject.cpp (151547 => 151548)


--- branches/dfgFourthTier/Source/_javascript_Core/runtime/MathObject.cpp	2013-06-13 15:05:14 UTC (rev 151547)
+++ branches/dfgFourthTier/Source/_javascript_Core/runtime/MathObject.cpp	2013-06-13 15:29:50 UTC (rev 151548)
@@ -1,6 +1,6 @@
 /*
  *  Copyright (C) 1999-2000 Harri Porten ([email protected])
- *  Copyright (C) 2007, 2008 Apple Inc. All Rights Reserved.
+ *  Copyright (C) 2007, 2008, 2013 Apple Inc. All Rights Reserved.
  *
  *  This library is free software; you can redistribute it and/or
  *  modify it under the terms of the GNU Lesser General Public
@@ -55,35 +55,10 @@
 
 }
 
-#include "MathObject.lut.h"
-
 namespace JSC {
 
-const ClassInfo MathObject::s_info = { "Math", &Base::s_info, 0, ExecState::mathTable, CREATE_METHOD_TABLE(MathObject) };
+const ClassInfo MathObject::s_info = { "Math", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(MathObject) };
 
-/* Source for MathObject.lut.h
-@begin mathTable
-  abs           mathProtoFuncAbs               DontEnum|Function 1
-  acos          mathProtoFuncACos              DontEnum|Function 1
-  asin          mathProtoFuncASin              DontEnum|Function 1
-  atan          mathProtoFuncATan              DontEnum|Function 1
-  atan2         mathProtoFuncATan2             DontEnum|Function 2
-  ceil          mathProtoFuncCeil              DontEnum|Function 1
-  cos           mathProtoFuncCos               DontEnum|Function 1
-  exp           mathProtoFuncExp               DontEnum|Function 1
-  floor         mathProtoFuncFloor             DontEnum|Function 1
-  log           mathProtoFuncLog               DontEnum|Function 1
-  max           mathProtoFuncMax               DontEnum|Function 2
-  min           mathProtoFuncMin               DontEnum|Function 2
-  pow           mathProtoFuncPow               DontEnum|Function 2
-  random        mathProtoFuncRandom            DontEnum|Function 0 
-  round         mathProtoFuncRound             DontEnum|Function 1
-  sin           mathProtoFuncSin               DontEnum|Function 1
-  sqrt          mathProtoFuncSqrt              DontEnum|Function 1
-  tan           mathProtoFuncTan               DontEnum|Function 1
-@end
-*/
-
 MathObject::MathObject(JSGlobalObject* globalObject, Structure* structure)
     : JSNonFinalObject(globalObject->vm(), structure)
 {
@@ -98,22 +73,31 @@
     putDirectWithoutTransition(exec->vm(), Identifier(exec, "LN2"), jsNumber(log(2.0)), DontDelete | DontEnum | ReadOnly);
     putDirectWithoutTransition(exec->vm(), Identifier(exec, "LN10"), jsNumber(log(10.0)), DontDelete | DontEnum | ReadOnly);
     putDirectWithoutTransition(exec->vm(), Identifier(exec, "LOG2E"), jsNumber(1.0 / log(2.0)), DontDelete | DontEnum | ReadOnly);
-    putDirectWithoutTransition(exec->vm(), Identifier(exec, "LOG10E"), jsNumber(0.4342944819032518), DontDelete | DontEnum | ReadOnly); // See ECMA-262 15.8.1.5
+    putDirectWithoutTransition(exec->vm(), Identifier(exec, "LOG10E"), jsNumber(0.4342944819032518), DontDelete | DontEnum | ReadOnly);
     putDirectWithoutTransition(exec->vm(), Identifier(exec, "PI"), jsNumber(piDouble), DontDelete | DontEnum | ReadOnly);
     putDirectWithoutTransition(exec->vm(), Identifier(exec, "SQRT1_2"), jsNumber(sqrt(0.5)), DontDelete | DontEnum | ReadOnly);
     putDirectWithoutTransition(exec->vm(), Identifier(exec, "SQRT2"), jsNumber(sqrt(2.0)), DontDelete | DontEnum | ReadOnly);
-}
 
-bool MathObject::getOwnPropertySlot(JSCell* cell, ExecState* exec, PropertyName propertyName, PropertySlot &slot)
-{
-    return getStaticFunctionSlot<JSObject>(exec, ExecState::mathTable(exec), jsCast<MathObject*>(cell), propertyName, slot);
+    putDirectNativeFunctionWithoutTransition(exec, globalObject, Identifier(exec, "abs"), 1, mathProtoFuncAbs, AbsIntrinsic, DontEnum | Function);
+    putDirectNativeFunctionWithoutTransition(exec, globalObject, Identifier(exec, "acos"), 1, mathProtoFuncACos, NoIntrinsic, DontEnum | Function);
+    putDirectNativeFunctionWithoutTransition(exec, globalObject, Identifier(exec, "asin"), 1, mathProtoFuncASin, NoIntrinsic, DontEnum | Function);
+    putDirectNativeFunctionWithoutTransition(exec, globalObject, Identifier(exec, "atan"), 1, mathProtoFuncATan, NoIntrinsic, DontEnum | Function);
+    putDirectNativeFunctionWithoutTransition(exec, globalObject, Identifier(exec, "atan2"), 2, mathProtoFuncATan2, NoIntrinsic, DontEnum | Function);
+    putDirectNativeFunctionWithoutTransition(exec, globalObject, Identifier(exec, "ceil"), 1, mathProtoFuncCeil, CeilIntrinsic, DontEnum | Function);
+    putDirectNativeFunctionWithoutTransition(exec, globalObject, Identifier(exec, "cos"), 1, mathProtoFuncCos, NoIntrinsic, DontEnum | Function);
+    putDirectNativeFunctionWithoutTransition(exec, globalObject, Identifier(exec, "exp"), 1, mathProtoFuncExp, ExpIntrinsic, DontEnum | Function);
+    putDirectNativeFunctionWithoutTransition(exec, globalObject, Identifier(exec, "floor"), 1, mathProtoFuncFloor, FloorIntrinsic, DontEnum | Function);
+    putDirectNativeFunctionWithoutTransition(exec, globalObject, Identifier(exec, "log"), 1, mathProtoFuncLog, LogIntrinsic, DontEnum | Function);
+    putDirectNativeFunctionWithoutTransition(exec, globalObject, Identifier(exec, "max"), 2, mathProtoFuncMax, MaxIntrinsic, DontEnum | Function);
+    putDirectNativeFunctionWithoutTransition(exec, globalObject, Identifier(exec, "min"), 2, mathProtoFuncMin, MinIntrinsic, DontEnum | Function);
+    putDirectNativeFunctionWithoutTransition(exec, globalObject, Identifier(exec, "pow"), 2, mathProtoFuncPow, PowIntrinsic, DontEnum | Function);
+    putDirectNativeFunctionWithoutTransition(exec, globalObject, Identifier(exec, "random"), 0, mathProtoFuncRandom, NoIntrinsic, DontEnum | Function);
+    putDirectNativeFunctionWithoutTransition(exec, globalObject, Identifier(exec, "round"), 1, mathProtoFuncRound, RoundIntrinsic, DontEnum | Function);
+    putDirectNativeFunctionWithoutTransition(exec, globalObject, Identifier(exec, "sin"), 1, mathProtoFuncSin, NoIntrinsic, DontEnum | Function);
+    putDirectNativeFunctionWithoutTransition(exec, globalObject, Identifier(exec, "sqrt"), 1, mathProtoFuncSqrt, SqrtIntrinsic, DontEnum | Function);
+    putDirectNativeFunctionWithoutTransition(exec, globalObject, Identifier(exec, "tan"), 1, mathProtoFuncTan, NoIntrinsic, DontEnum | Function);
 }
 
-bool MathObject::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor)
-{
-    return getStaticFunctionDescriptor<JSObject>(exec, ExecState::mathTable(exec), jsCast<MathObject*>(object), propertyName, descriptor);
-}
-
 // ------------------------------ Functions --------------------------------
 
 EncodedJSValue JSC_HOST_CALL mathProtoFuncAbs(ExecState* exec)

Modified: branches/dfgFourthTier/Source/_javascript_Core/runtime/MathObject.h (151547 => 151548)


--- branches/dfgFourthTier/Source/_javascript_Core/runtime/MathObject.h	2013-06-13 15:05:14 UTC (rev 151547)
+++ branches/dfgFourthTier/Source/_javascript_Core/runtime/MathObject.h	2013-06-13 15:29:50 UTC (rev 151548)
@@ -38,8 +38,6 @@
             object->finishCreation(exec, globalObject);
             return object;
         }
-        static bool getOwnPropertySlot(JSCell*, ExecState*, PropertyName, PropertySlot&);
-        static bool getOwnPropertyDescriptor(JSObject*, ExecState*, PropertyName, PropertyDescriptor&);
 
         static const ClassInfo s_info;
 

Modified: branches/dfgFourthTier/Source/_javascript_Core/runtime/VM.cpp (151547 => 151548)


--- branches/dfgFourthTier/Source/_javascript_Core/runtime/VM.cpp	2013-06-13 15:05:14 UTC (rev 151547)
+++ branches/dfgFourthTier/Source/_javascript_Core/runtime/VM.cpp	2013-06-13 15:29:50 UTC (rev 151548)
@@ -90,7 +90,6 @@
 extern const HashTable dateConstructorTable;
 extern const HashTable errorPrototypeTable;
 extern const HashTable globalObjectTable;
-extern const HashTable mathTable;
 extern const HashTable numberConstructorTable;
 extern const HashTable numberPrototypeTable;
 JS_EXPORTDATA extern const HashTable objectConstructorTable;
@@ -150,7 +149,6 @@
     , errorPrototypeTable(fastNew<HashTable>(JSC::errorPrototypeTable))
     , globalObjectTable(fastNew<HashTable>(JSC::globalObjectTable))
     , jsonTable(fastNew<HashTable>(JSC::jsonTable))
-    , mathTable(fastNew<HashTable>(JSC::mathTable))
     , numberConstructorTable(fastNew<HashTable>(JSC::numberConstructorTable))
     , numberPrototypeTable(fastNew<HashTable>(JSC::numberPrototypeTable))
     , objectConstructorTable(fastNew<HashTable>(JSC::objectConstructorTable))
@@ -284,7 +282,6 @@
     errorPrototypeTable->deleteTable();
     globalObjectTable->deleteTable();
     jsonTable->deleteTable();
-    mathTable->deleteTable();
     numberConstructorTable->deleteTable();
     numberPrototypeTable->deleteTable();
     objectConstructorTable->deleteTable();
@@ -302,7 +299,6 @@
     fastDelete(const_cast<HashTable*>(errorPrototypeTable));
     fastDelete(const_cast<HashTable*>(globalObjectTable));
     fastDelete(const_cast<HashTable*>(jsonTable));
-    fastDelete(const_cast<HashTable*>(mathTable));
     fastDelete(const_cast<HashTable*>(numberConstructorTable));
     fastDelete(const_cast<HashTable*>(numberPrototypeTable));
     fastDelete(const_cast<HashTable*>(objectConstructorTable));

Modified: branches/dfgFourthTier/Source/_javascript_Core/runtime/VM.h (151547 => 151548)


--- branches/dfgFourthTier/Source/_javascript_Core/runtime/VM.h	2013-06-13 15:05:14 UTC (rev 151547)
+++ branches/dfgFourthTier/Source/_javascript_Core/runtime/VM.h	2013-06-13 15:29:50 UTC (rev 151548)
@@ -226,7 +226,6 @@
         const HashTable* errorPrototypeTable;
         const HashTable* globalObjectTable;
         const HashTable* jsonTable;
-        const HashTable* mathTable;
         const HashTable* numberConstructorTable;
         const HashTable* numberPrototypeTable;
         const HashTable* objectConstructorTable;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to