Commit 8128fe1e authored by oliver@apple.com's avatar oliver@apple.com
Browse files

2010-09-05 Oliver Hunt <oliver@apple.com>

        Reviewed by Sam Weinig.

        SerializedScriptValue needs to use a flat storage mechanism
        https://bugs.webkit.org/show_bug.cgi?id=45244

        Export JSArray::put

        * JavaScriptCore.exp:
2010-09-05  Oliver Hunt  <oliver@apple.com>

        Reviewed by Sam Weinig.

        SerializedScriptValue needs to use a flat storage mechanism
        https://bugs.webkit.org/show_bug.cgi?id=45244

        Add a few more test cases to cover the new branches in the
        rewritten serialization logic.

        * fast/dom/Window/window-postmessage-clone-expected.txt:
        * fast/dom/Window/window-postmessage-clone.html:
2010-09-05  Oliver Hunt  <oliver@apple.com>

        Reviewed by Sam Weinig.

        SerializedScriptValue needs to use a flat storage mechanism
        https://bugs.webkit.org/show_bug.cgi?id=45244

        Rewrite the old tree to tree serialization logic to use
        flat storage.  Unfortunately this basically required a
        complete rewrite.

        * bindings/js/SerializedScriptValue.cpp:
        (WebCore::CloneBase::CloneBase):
        (WebCore::CloneBase::shouldTerminate):
        (WebCore::CloneBase::ticksUntilNextCheck):
        (WebCore::CloneBase::didTimeOut):
        (WebCore::CloneBase::throwStackOverflow):
        (WebCore::CloneBase::throwInterruptedException):
        (WebCore::CloneBase::fail):
        (WebCore::CloneSerializer::serialize):
        (WebCore::CloneSerializer::CloneSerializer):
        (WebCore::CloneSerializer::isArray):
        (WebCore::CloneSerializer::startObject):
        (WebCore::CloneSerializer::startArray):
        (WebCore::CloneSerializer::endObject):
        (WebCore::CloneSerializer::getSparseIndex):
        (WebCore::CloneSerializer::getProperty):
        (WebCore::CloneSerializer::dumpImmediate):
        (WebCore::CloneSerializer::dumpString):
        (WebCore::CloneSerializer::dumpIfTerminal):
        (WebCore::CloneSerializer::write):
        (WebCore::CloneSerializer::writeLittleEndian):
        (WebCore::CloneSerializer::writeStringIndex):
        (WebCore::CloneDeserializer::deserializeString):
        (WebCore::CloneDeserializer::deserialize):
        (WebCore::CloneDeserializer::CloneDeserializer):
        (WebCore::CloneDeserializer::throwValidationError):
        (WebCore::CloneDeserializer::isValid):
        (WebCore::CloneDeserializer::readLittleEndian):
        (WebCore::CloneDeserializer::read):
        (WebCore::CloneDeserializer::readStringIndex):
        (WebCore::CloneDeserializer::readString):
        (WebCore::CloneDeserializer::readStringData):
        (WebCore::CloneDeserializer::readTag):
        (WebCore::CloneDeserializer::putProperty):
        (WebCore::CloneDeserializer::readFile):
        (WebCore::CloneDeserializer::readTerminal):
        (WebCore::SerializedScriptValue::~SerializedScriptValue):
        (WebCore::SerializedScriptValue::SerializedScriptValue):
        (WebCore::SerializedScriptValue::create):
        (WebCore::SerializedScriptValue::toString):
        (WebCore::SerializedScriptValue::deserialize):
        (WebCore::SerializedScriptValue::nullValue):
        * bindings/js/SerializedScriptValue.h:
        * dom/MessagePortChannel.cpp:
        (WebCore::MessagePortChannel::EventData::EventData):
        * workers/WorkerMessagingProxy.cpp:
        (WebCore::MessageWorkerContextTask::MessageWorkerContextTask):
        (WebCore::MessageWorkerTask::MessageWorkerTask):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@66850 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 1414c99f
2010-09-05 Oliver Hunt <oliver@apple.com>
Reviewed by Sam Weinig.
SerializedScriptValue needs to use a flat storage mechanism
https://bugs.webkit.org/show_bug.cgi?id=45244
Export JSArray::put
* JavaScriptCore.exp:
2010-09-06 Chao-ying Fu <fu@mips.com>
Reviewed by Oliver Hunt.
......
......@@ -241,6 +241,7 @@ __ZN3JSC6JSLockC1EPNS_9ExecStateE
__ZN3JSC6Parser5parseEPNS_12JSGlobalDataEPiPNS_7UStringE
__ZN3JSC7JSArray12markChildrenERNS_9MarkStackE
__ZN3JSC7JSArray15setSubclassDataEPv
__ZN3JSC7JSArray18getOwnPropertySlotEPNS_9ExecStateEjRNS_12PropertySlotE
__ZN3JSC7JSArray4infoE
__ZN3JSC7JSArray9setLengthEj
__ZN3JSC7JSArrayC1EN3WTF17NonNullPassRefPtrINS_9StructureEEE
......
2010-09-05 Oliver Hunt <oliver@apple.com>
Reviewed by Sam Weinig.
SerializedScriptValue needs to use a flat storage mechanism
https://bugs.webkit.org/show_bug.cgi?id=45244
Add a few more test cases to cover the new branches in the
rewritten serialization logic.
* fast/dom/Window/window-postmessage-clone-expected.txt:
* fast/dom/Window/window-postmessage-clone.html:
2010-09-06 Justin Schuh <jschuh@chromium.org>
 
Reviewed by Nikolas Zimmermann.
......@@ -10,7 +10,14 @@ PASS: eventData is true of type boolean
PASS: eventData is 1 of type string
PASS: eventData is [object Object] of type object
PASS: eventData is [object Object] of type object
PASS: eventData is [object Object] of type object
PASS: eventData is [object Object] of type object
PASS: eventData is [object Object] of type object
PASS: eventData is [object Object] of type object
PASS: eventData is [object Object] of type object
PASS: eventData is of type object
PASS: eventData is a,a,b,a,b of type object
PASS: eventData is a,a,b,[object Object] of type object
PASS: eventData is 1,2,3 of type object
PASS: eventData is ,,1 of type object
PASS: eventData is null of type object
......
......@@ -124,7 +124,14 @@ tryPostMessage('true');
tryPostMessage('"1"');
tryPostMessage('({})');
tryPostMessage('({a:1})');
tryPostMessage('({a:"a"})');
tryPostMessage('({b:"a", a:"b"})');
tryPostMessage('({a:""})');
tryPostMessage('({a:0})');
tryPostMessage('({a:1})');
tryPostMessage('[]');
tryPostMessage('["a", "a", "b", "a", "b"]');
tryPostMessage('["a", "a", "b", {a:"b", b:"a"}]');
tryPostMessage('[1,2,3]');
tryPostMessage('[,,1]');
tryPostMessage('(function(){})', false, 'null');
......
2010-09-05 Oliver Hunt <oliver@apple.com>
Reviewed by Sam Weinig.
SerializedScriptValue needs to use a flat storage mechanism
https://bugs.webkit.org/show_bug.cgi?id=45244
Rewrite the old tree to tree serialization logic to use
flat storage. Unfortunately this basically required a
complete rewrite.
* bindings/js/SerializedScriptValue.cpp:
(WebCore::CloneBase::CloneBase):
(WebCore::CloneBase::shouldTerminate):
(WebCore::CloneBase::ticksUntilNextCheck):
(WebCore::CloneBase::didTimeOut):
(WebCore::CloneBase::throwStackOverflow):
(WebCore::CloneBase::throwInterruptedException):
(WebCore::CloneBase::fail):
(WebCore::CloneSerializer::serialize):
(WebCore::CloneSerializer::CloneSerializer):
(WebCore::CloneSerializer::isArray):
(WebCore::CloneSerializer::startObject):
(WebCore::CloneSerializer::startArray):
(WebCore::CloneSerializer::endObject):
(WebCore::CloneSerializer::getSparseIndex):
(WebCore::CloneSerializer::getProperty):
(WebCore::CloneSerializer::dumpImmediate):
(WebCore::CloneSerializer::dumpString):
(WebCore::CloneSerializer::dumpIfTerminal):
(WebCore::CloneSerializer::write):
(WebCore::CloneSerializer::writeLittleEndian):
(WebCore::CloneSerializer::writeStringIndex):
(WebCore::CloneDeserializer::deserializeString):
(WebCore::CloneDeserializer::deserialize):
(WebCore::CloneDeserializer::CloneDeserializer):
(WebCore::CloneDeserializer::throwValidationError):
(WebCore::CloneDeserializer::isValid):
(WebCore::CloneDeserializer::readLittleEndian):
(WebCore::CloneDeserializer::read):
(WebCore::CloneDeserializer::readStringIndex):
(WebCore::CloneDeserializer::readString):
(WebCore::CloneDeserializer::readStringData):
(WebCore::CloneDeserializer::readTag):
(WebCore::CloneDeserializer::putProperty):
(WebCore::CloneDeserializer::readFile):
(WebCore::CloneDeserializer::readTerminal):
(WebCore::SerializedScriptValue::~SerializedScriptValue):
(WebCore::SerializedScriptValue::SerializedScriptValue):
(WebCore::SerializedScriptValue::create):
(WebCore::SerializedScriptValue::toString):
(WebCore::SerializedScriptValue::deserialize):
(WebCore::SerializedScriptValue::nullValue):
* bindings/js/SerializedScriptValue.h:
* dom/MessagePortChannel.cpp:
(WebCore::MessagePortChannel::EventData::EventData):
* workers/WorkerMessagingProxy.cpp:
(WebCore::MessageWorkerContextTask::MessageWorkerContextTask):
(WebCore::MessageWorkerTask::MessageWorkerTask):
2010-09-06 Martin Robinson <mrobinson@igalia.com>
 
Reviewed by Gustavo Noronha Silva.
......@@ -28,229 +28,34 @@
#define SerializedScriptValue_h
#include "ScriptValue.h"
#include <wtf/Forward.h>
typedef const struct OpaqueJSContext* JSContextRef;
typedef const struct OpaqueJSValue* JSValueRef;
namespace WebCore {
class Blob;
class File;
class FileList;
class ImageData;
class SerializedArray;
class SerializedBlob;
class SerializedFile;
class SerializedFileList;
class SerializedImageData;
class SerializedObject;
class SharedSerializedData : public RefCounted<SharedSerializedData> {
public:
virtual ~SharedSerializedData() { }
SerializedArray* asArray();
SerializedObject* asObject();
SerializedBlob* asBlob();
SerializedFile* asFile();
SerializedFileList* asFileList();
SerializedImageData* asImageData();
};
class SharedBuffer;
class SerializedScriptValue;
class SerializedScriptValue : public RefCounted<SerializedScriptValue> {
public:
static PassRefPtr<SerializedScriptValue> create(JSC::ExecState* exec, JSC::JSValue value);
static PassRefPtr<SerializedScriptValue> create(JSContextRef, JSValueRef value, JSValueRef* exception);
static PassRefPtr<SerializedScriptValue> create(String string);
static PassRefPtr<SerializedScriptValue> create();
static SerializedScriptValue* nullValue();
class SerializedScriptValueData {
public:
enum SerializedType {
EmptyType,
DateType,
NumberType,
ImmediateType,
ObjectType,
ArrayType,
StringType,
BlobType,
FileType,
FileListType,
ImageDataType
};
JSC::JSValue deserialize(JSC::ExecState* exec, JSC::JSGlobalObject* globalObject);
String toString();
JSValueRef deserialize(JSContextRef, JSValueRef* exception);
~SerializedScriptValue();
SerializedType type() const { return m_type; }
static SerializedScriptValueData serialize(JSC::ExecState*, JSC::JSValue);
JSC::JSValue deserialize(JSC::ExecState*, JSC::JSGlobalObject*, bool mustCopy) const;
private:
SerializedScriptValue(Vector<unsigned char>&);
Vector<unsigned char> m_data;
};
~SerializedScriptValueData()
{
if (m_sharedData)
tearDownSerializedData();
}
SerializedScriptValueData()
: m_type(EmptyType)
{
}
explicit SerializedScriptValueData(const String& string)
: m_type(StringType)
, m_string(string.crossThreadString()) // FIXME: Should be able to just share the StringImpl
{
}
explicit SerializedScriptValueData(const Blob*);
explicit SerializedScriptValueData(const File*);
explicit SerializedScriptValueData(const FileList*);
explicit SerializedScriptValueData(const ImageData*);
explicit SerializedScriptValueData(JSC::JSValue value)
: m_type(ImmediateType)
{
ASSERT(!value.isCell());
m_data.m_immediate = JSC::JSValue::encode(value);
}
SerializedScriptValueData(SerializedType type, double value)
: m_type(type)
{
m_data.m_double = value;
}
SerializedScriptValueData(RefPtr<SerializedObject>);
SerializedScriptValueData(RefPtr<SerializedArray>);
JSC::JSValue asImmediate() const
{
ASSERT(m_type == ImmediateType);
return JSC::JSValue::decode(m_data.m_immediate);
}
double asDouble() const
{
ASSERT(m_type == NumberType || m_type == DateType);
return m_data.m_double;
}
String asString() const
{
ASSERT(m_type == StringType);
return m_string;
}
SerializedObject* asObject() const
{
ASSERT(m_type == ObjectType);
ASSERT(m_sharedData);
return m_sharedData->asObject();
}
SerializedArray* asArray() const
{
ASSERT(m_type == ArrayType);
ASSERT(m_sharedData);
return m_sharedData->asArray();
}
SerializedBlob* asBlob() const
{
ASSERT(m_type == BlobType);
ASSERT(m_sharedData);
return m_sharedData->asBlob();
}
SerializedFile* asFile() const
{
ASSERT(m_type == FileType);
ASSERT(m_sharedData);
return m_sharedData->asFile();
}
SerializedFileList* asFileList() const
{
ASSERT(m_type == FileListType);
ASSERT(m_sharedData);
return m_sharedData->asFileList();
}
SerializedImageData* asImageData() const
{
ASSERT(m_type == ImageDataType);
ASSERT(m_sharedData);
return m_sharedData->asImageData();
}
operator bool() const { return m_type != EmptyType; }
SerializedScriptValueData release()
{
SerializedScriptValueData result = *this;
*this = SerializedScriptValueData();
return result;
}
private:
void tearDownSerializedData();
SerializedType m_type;
RefPtr<SharedSerializedData> m_sharedData;
String m_string;
union {
double m_double;
JSC::EncodedJSValue m_immediate;
} m_data;
};
class SerializedScriptValue : public RefCounted<SerializedScriptValue> {
public:
static PassRefPtr<SerializedScriptValue> create(JSC::ExecState* exec, JSC::JSValue value)
{
return adoptRef(new SerializedScriptValue(SerializedScriptValueData::serialize(exec, value)));
}
static PassRefPtr<SerializedScriptValue> create(JSContextRef, JSValueRef value, JSValueRef* exception);
static PassRefPtr<SerializedScriptValue> create(String string)
{
return adoptRef(new SerializedScriptValue(SerializedScriptValueData(string)));
}
static PassRefPtr<SerializedScriptValue> create()
{
return adoptRef(new SerializedScriptValue(SerializedScriptValueData()));
}
static SerializedScriptValue* nullValue();
PassRefPtr<SerializedScriptValue> release()
{
PassRefPtr<SerializedScriptValue> result = adoptRef(new SerializedScriptValue(m_value));
m_value = SerializedScriptValueData();
result->m_mustCopy = true;
return result;
}
String toString()
{
if (m_value.type() != SerializedScriptValueData::StringType)
return "";
return m_value.asString();
}
JSC::JSValue deserialize(JSC::ExecState* exec, JSC::JSGlobalObject* globalObject)
{
if (!m_value)
return JSC::jsNull();
return m_value.deserialize(exec, globalObject, m_mustCopy);
}
JSValueRef deserialize(JSContextRef, JSValueRef* exception);
~SerializedScriptValue();
private:
SerializedScriptValue(SerializedScriptValueData value)
: m_value(value)
, m_mustCopy(false)
{
}
SerializedScriptValueData m_value;
bool m_mustCopy;
};
}
#endif // SerializedScriptValue_h
......@@ -39,7 +39,7 @@ PassOwnPtr<MessagePortChannel::EventData> MessagePortChannel::EventData::create(
}
MessagePortChannel::EventData::EventData(PassRefPtr<SerializedScriptValue> message, PassOwnPtr<MessagePortChannelArray> channels)
: m_message(message->release())
: m_message(message)
, m_channels(channels)
{
}
......
......@@ -54,7 +54,7 @@ public:
private:
MessageWorkerContextTask(PassRefPtr<SerializedScriptValue> message, PassOwnPtr<MessagePortChannelArray> channels)
: m_message(message->release())
: m_message(message)
, m_channels(channels)
{
}
......@@ -82,7 +82,7 @@ public:
private:
MessageWorkerTask(PassRefPtr<SerializedScriptValue> message, PassOwnPtr<MessagePortChannelArray> channels, WorkerMessagingProxy* messagingProxy)
: m_message(message->release())
: m_message(message)
, m_channels(channels)
, m_messagingProxy(messagingProxy)
{
......
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