Pass VM instead of ExecState to StringObject constructor.
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 6 Oct 2013 18:16:48 +0000 (18:16 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 6 Oct 2013 18:16:48 +0000 (18:16 +0000)
<https://webkit.org/b/122395>

Reviewed by Sam Weinig.

StringObject() only uses the ExecState to find the VM.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@156998 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/dfg/DFGOperations.cpp
Source/JavaScriptCore/runtime/JSString.cpp
Source/JavaScriptCore/runtime/StringConstructor.cpp
Source/JavaScriptCore/runtime/StringObject.cpp
Source/JavaScriptCore/runtime/StringObject.h
Source/WebCore/bindings/js/SerializedScriptValue.cpp

index 07f8e65..11f1c95 100644 (file)
@@ -1,3 +1,12 @@
+2013-10-05  Andreas Kling  <akling@apple.com>
+
+        Pass VM instead of ExecState to StringObject constructor.
+        <https://webkit.org/b/122395>
+
+        Reviewed by Sam Weinig.
+
+        StringObject() only uses the ExecState to find the VM.
+
 2013-10-05  Filip Pizlo  <fpizlo@apple.com>
 
         Compress DFG stack layout
index 4248639..75c7f36 100644 (file)
@@ -997,7 +997,7 @@ JSCell* JIT_OPERATION operationNewStringObject(ExecState* exec, JSString* string
     VM& vm = exec->vm();
     NativeCallFrameTracer tracer(&vm, exec);
     
-    return StringObject::create(exec, structure, string);
+    return StringObject::create(vm, structure, string);
 }
 
 JSCell* JIT_OPERATION operationToStringOnCell(ExecState* exec, JSCell* cell)
index 0bbc087..a5bfe26 100644 (file)
@@ -262,23 +262,23 @@ double JSString::toNumber(ExecState* exec) const
     return jsToNumber(value(exec));
 }
 
-inline StringObject* StringObject::create(ExecState* exec, JSGlobalObject* globalObject, JSString* string)
+inline StringObject* StringObject::create(VM& vm, JSGlobalObject* globalObject, JSString* string)
 {
-    StringObject* object = new (NotNull, allocateCell<StringObject>(*exec->heap())) StringObject(exec->vm(), globalObject->stringObjectStructure());
-    object->finishCreation(exec->vm(), string);
+    StringObject* object = new (NotNull, allocateCell<StringObject>(vm.heap)) StringObject(vm, globalObject->stringObjectStructure());
+    object->finishCreation(vm, string);
     return object;
 }
 
 JSObject* JSString::toObject(ExecState* exec, JSGlobalObject* globalObject) const
 {
-    return StringObject::create(exec, globalObject, const_cast<JSString*>(this));
+    return StringObject::create(exec->vm(), globalObject, const_cast<JSString*>(this));
 }
 
 JSValue JSString::toThis(JSCell* cell, ExecState* exec, ECMAMode ecmaMode)
 {
     if (ecmaMode == StrictMode)
         return cell;
-    return StringObject::create(exec, exec->lexicalGlobalObject(), jsCast<JSString*>(cell));
+    return StringObject::create(exec->vm(), exec->lexicalGlobalObject(), jsCast<JSString*>(cell));
 }
 
 bool JSString::getStringPropertyDescriptor(ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor)
index cb0697a..1474534 100644 (file)
@@ -92,10 +92,12 @@ JSCell* JSC_HOST_CALL stringFromCharCode(ExecState* exec, int32_t arg)
 static EncodedJSValue JSC_HOST_CALL constructWithStringConstructor(ExecState* exec)
 {
     JSGlobalObject* globalObject = asInternalFunction(exec->callee())->globalObject();
+    VM& vm = exec->vm();
+
     if (!exec->argumentCount())
-        return JSValue::encode(StringObject::create(exec, globalObject->stringObjectStructure()));
+        return JSValue::encode(StringObject::create(vm, globalObject->stringObjectStructure()));
     
-    return JSValue::encode(StringObject::create(exec, globalObject->stringObjectStructure(), exec->uncheckedArgument(0).toString(exec)));
+    return JSValue::encode(StringObject::create(vm, globalObject->stringObjectStructure(), exec->uncheckedArgument(0).toString(exec)));
 }
 
 ConstructType StringConstructor::getConstructData(JSCell*, ConstructData& constructData)
index 3736a0d..440a609 100644 (file)
@@ -155,10 +155,10 @@ void StringObject::getOwnPropertyNames(JSObject* object, ExecState* exec, Proper
     return JSObject::getOwnPropertyNames(thisObject, exec, propertyNames, mode);
 }
 
-StringObject* constructString(ExecState* exec, JSGlobalObject* globalObject, JSValue string)
+StringObject* constructString(VM& vm, JSGlobalObject* globalObject, JSValue string)
 {
-    StringObject* object = StringObject::create(exec, globalObject->stringObjectStructure());
-    object->setInternalValue(exec->vm(), string);
+    StringObject* object = StringObject::create(vm, globalObject->stringObjectStructure());
+    object->setInternalValue(vm, string);
     return object;
 }
 
index a713004..df63614 100644 (file)
@@ -30,20 +30,20 @@ namespace JSC {
     public:
         typedef JSWrapperObject Base;
 
-        static StringObject* create(ExecState* exec, Structure* structure)
+        static StringObject* create(VM& vm, Structure* structure)
         {
-            JSString* string = jsEmptyString(exec);
-            StringObject* object = new (NotNull, allocateCell<StringObject>(*exec->heap())) StringObject(exec->vm(), structure);  
-            object->finishCreation(exec->vm(), string);
+            JSString* string = jsEmptyString(&vm);
+            StringObject* object = new (NotNull, allocateCell<StringObject>(vm.heap)) StringObject(vm, structure);
+            object->finishCreation(vm, string);
             return object;
         }
-        static StringObject* create(ExecState* exec, Structure* structure, JSString* string)
+        static StringObject* create(VM& vm, Structure* structure, JSString* string)
         {
-            StringObject* object = new (NotNull, allocateCell<StringObject>(*exec->heap())) StringObject(exec->vm(), structure);
-            object->finishCreation(exec->vm(), string);
+            StringObject* object = new (NotNull, allocateCell<StringObject>(vm.heap)) StringObject(vm, structure);
+            object->finishCreation(vm, string);
             return object;
         }
-        static StringObject* create(ExecState*, JSGlobalObject*, JSString*);
+        static StringObject* create(VM&, JSGlobalObject*, JSString*);
 
         static bool getOwnPropertySlot(JSObject*, ExecState*, PropertyName, PropertySlot&);
         static bool getOwnPropertySlotByIndex(JSObject*, ExecState*, unsigned propertyName, PropertySlot&);
@@ -79,7 +79,7 @@ namespace JSC {
         return static_cast<StringObject*>(asObject(value));
     }
 
-    JS_EXPORT_PRIVATE StringObject* constructString(ExecState*, JSGlobalObject*, JSValue);
+    JS_EXPORT_PRIVATE StringObject* constructString(VM&, JSGlobalObject*, JSValue);
 
 } // namespace JSC
 
index 2419615..de4c729 100644 (file)
@@ -1591,12 +1591,13 @@ private:
             CachedStringRef cachedString;
             if (!readStringData(cachedString))
                 return JSValue();
-            StringObject* obj = constructString(m_exec, m_globalObject, cachedString->jsString(m_exec));
+            StringObject* obj = constructString(m_exec->vm(), m_globalObject, cachedString->jsString(m_exec));
             m_gcBuffer.append(obj);
             return obj;
         }
         case EmptyStringObjectTag: {
-            StringObject* obj = constructString(m_exec, m_globalObject, jsEmptyString(&m_exec->vm()));
+            VM& vm = m_exec->vm();
+            StringObject* obj = constructString(vm, m_globalObject, jsEmptyString(&vm));
             m_gcBuffer.append(obj);
             return obj;
         }