From: Simon Hausmann Date: Thu, 5 Jan 2012 09:38:10 +0000 (+0100) Subject: Remove QtV8 library from QtBase X-Git-Tag: qt-v5.0.0-alpha1~1955 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=51d634ce2e7d4348a004d0807f53288cfbbb97ff;p=profile%2Fivi%2Fqtbase.git Remove QtV8 library from QtBase The QtV8 library is going to live in the qtjsbackend module. Change-Id: I72251316163829411dda998b9503ce6f75b3606a Reviewed-by: Oswald Buddenhagen Reviewed-by: Aaron Kennedy Reviewed-by: Kent Hansen Reviewed-by: Rohan McGovern --- diff --git a/.gitignore b/.gitignore index 03883f6..87d3f62 100644 --- a/.gitignore +++ b/.gitignore @@ -128,13 +128,10 @@ src/openvg/qtopenvgversion.h src/sql/qtsqlversion.h src/testlib/qttestversion.h src/xml/qtxmlversion.h -src/v8/qtv8version.h src/platformsupport/qtplatformsupportversion.h src/printsupport/qtprintsupportversion.h src/widgets/qtwidgetsversion.h -src/v8/generated-debug/ - # Test generated files QObject.log tst_* diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 183f5b4..0000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "src/3rdparty/v8"] - path = src/3rdparty/v8 - url = git://github.com/aaronkennedy/v8.git diff --git a/src/3rdparty/v8 b/src/3rdparty/v8 deleted file mode 160000 index a07f617..0000000 --- a/src/3rdparty/v8 +++ /dev/null @@ -1 +0,0 @@ -Subproject commit a07f617da094b83b7a9e5b2d37e8bf9172c61109 diff --git a/src/modules/qt_v8.pri b/src/modules/qt_v8.pri deleted file mode 100644 index 89d6c26..0000000 --- a/src/modules/qt_v8.pri +++ /dev/null @@ -1,16 +0,0 @@ -QT.v8.VERSION = 5.0.0 -QT.v8.MAJOR_VERSION = 5 -QT.v8.MINOR_VERSION = 0 -QT.v8.PATCH_VERSION = 0 - -QT.v8.name = QtV8 -QT.v8.bins = $$QT_MODULE_BIN_BASE -QT.v8.includes = $$QT_MODULE_INCLUDE_BASE/QtV8 -QT.v8.private_includes = $$QT_MODULE_INCLUDE_BASE/QtV8/$$QT.v8.VERSION -QT.v8.sources = $$QT_MODULE_BASE/src/v8 -QT.v8.libs = $$QT_MODULE_LIB_BASE -QT.v8.plugins = $$QT_MODULE_PLUGIN_BASE -QT.v8.imports = $$QT_MODULE_IMPORT_BASE -QT.v8.depends = -QT.v8.DEFINES = -!contains(QT_CONFIG, static): QT.v8.DEFINES += V8_SHARED USING_V8_SHARED diff --git a/src/src.pro b/src/src.pro index 04e3688..80d1c4e 100644 --- a/src/src.pro +++ b/src/src.pro @@ -10,7 +10,6 @@ nacl: SRC_SUBDIRS -= src_network src_testlib contains(QT_CONFIG, dbus):SRC_SUBDIRS += src_dbus contains(QT_CONFIG, no-gui): SRC_SUBDIRS -= src_gui -contains(QT_CONFIG, v8): SRC_SUBDIRS += src_v8 contains(QT_CONFIG, opengl)|contains(QT_CONFIG, opengles1)|contains(QT_CONFIG, opengles2): SRC_SUBDIRS += src_opengl SRC_SUBDIRS += src_plugins @@ -19,8 +18,6 @@ src_winmain.subdir = $$QT_SOURCE_TREE/src/winmain src_winmain.target = sub-winmain src_corelib.subdir = $$QT_SOURCE_TREE/src/corelib src_corelib.target = sub-corelib -src_v8.subdir = $$QT_SOURCE_TREE/src/v8 -src_v8.target = sub-v8 src_xml.subdir = $$QT_SOURCE_TREE/src/xml src_xml.target = sub-xml src_dbus.subdir = $$QT_SOURCE_TREE/src/dbus @@ -65,7 +62,6 @@ src_platformsupport.target = sub-platformsupport src_declarative.depends += src_opengl src_webkit.depends += src_opengl } - contains(QT_CONFIG, v8snapshot):src_v8.depends += src_tools_mkv8snapshot } diff --git a/src/tools/mkv8snapshot/mkv8snapshot.pro b/src/tools/mkv8snapshot/mkv8snapshot.pro deleted file mode 100644 index 41fa5df..0000000 --- a/src/tools/mkv8snapshot/mkv8snapshot.pro +++ /dev/null @@ -1,39 +0,0 @@ -TEMPLATE = app -TARGET = mkv8snapshot -QT = -CONFIG -= app_bundle -CONFIG -= qt -CONFIG += console -CONFIG += warn_off - -DESTDIR = ../../../bin -INCLUDEPATH += . -DEPENDPATH += . -LIBS = -OBJECTS_DIR = . - -contains(QT_CONFIG, build_all): CONFIG += build_all -win32|mac:!macx-xcode: CONFIG += debug_and_release - -TARGET = $$TARGET$$qtPlatformTargetSuffix() - -cross_compile { - equals(QT_ARCH, arm): V8_TARGET_ARCH = arm -} - -include(../../v8/v8.pri) - -cross_compile { - equals(V8_TARGET_ARCH, arm): SOURCES += $$V8SRC/arm/simulator-arm.cc -} - -SOURCES += \ - $$V8SRC/snapshot-empty.cc \ - $$V8SRC/mksnapshot.cc - -unix:LIBS += -lpthread - -# We don't need to install this tool, it's only used for building v8. -# However we do have to make sure that 'make install' builds it. -dummytarget.CONFIG = dummy_install -INSTALLS += dummytarget diff --git a/src/tools/tools.pro b/src/tools/tools.pro index 89ce0be..5cbe923 100644 --- a/src/tools/tools.pro +++ b/src/tools/tools.pro @@ -2,7 +2,6 @@ TEMPLATE = subdirs TOOLS_SUBDIRS = src_tools_bootstrap src_tools_moc src_tools_rcc !contains(QT_CONFIG, no-gui): TOOLS_SUBDIRS += src_tools_uic -contains(QT_CONFIG, v8):contains(QT_CONFIG, v8snapshot): TOOLS_SUBDIRS += src_tools_mkv8snapshot # Set subdir and respective target name src_tools_bootstrap.subdir = $$QT_SOURCE_TREE/src/tools/bootstrap src_tools_bootstrap.target = sub-tools-bootstrap @@ -12,8 +11,6 @@ src_tools_rcc.subdir = $$QT_SOURCE_TREE/src/tools/rcc src_tools_rcc.target = sub-rcc src_tools_uic.subdir = $$QT_SOURCE_TREE/src/tools/uic src_tools_uic.target = sub-uic -src_tools_mkv8snapshot.subdir = $$QT_SOURCE_TREE/src/tools/mkv8snapshot -src_tools_mkv8snapshot.target = sub-mkv8snapshot !wince*:!ordered { # Set dependencies for each subdir diff --git a/src/v8/0001-Add-hashing-and-comparison-methods-to-v8-String.patch b/src/v8/0001-Add-hashing-and-comparison-methods-to-v8-String.patch deleted file mode 100644 index dd6374a..0000000 --- a/src/v8/0001-Add-hashing-and-comparison-methods-to-v8-String.patch +++ /dev/null @@ -1,336 +0,0 @@ -From d97195f011cdaa8b859d759f8a34dd50c3092f30 Mon Sep 17 00:00:00 2001 -From: Aaron Kennedy -Date: Tue, 4 Oct 2011 15:04:21 +1000 -Subject: [PATCH 01/13] Add hashing and comparison methods to v8::String - -This allows us to more rapidly search for a v8::String inside a hash -of QStrings. ---- - include/v8.h | 45 +++++++++++++++++++++++++++++ - src/api.cc | 51 +++++++++++++++++++++++++++++++++ - src/heap-inl.h | 2 + - src/heap.cc | 3 ++ - src/objects-inl.h | 1 + - src/objects.cc | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++- - src/objects.h | 10 ++++++- - 7 files changed, 192 insertions(+), 2 deletions(-) - -diff --git a/include/v8.h b/include/v8.h -index 73b7fbe..86ea70f 100644 ---- a/include/v8.h -+++ b/include/v8.h -@@ -1021,6 +1021,49 @@ class String : public Primitive { - V8EXPORT int Utf8Length() const; - - /** -+ * Returns the hash of this string. -+ */ -+ V8EXPORT uint32_t Hash() const; -+ -+ struct CompleteHashData { -+ CompleteHashData() : length(0), hash(0), symbol_id(0) {} -+ int length; -+ uint32_t hash; -+ uint32_t symbol_id; -+ }; -+ -+ /** -+ * Returns the "complete" hash of the string. This is -+ * all the information about the string needed to implement -+ * a very efficient hash keyed on the string. -+ * -+ * The members of CompleteHashData are: -+ * length: The length of the string. Equivalent to Length() -+ * hash: The hash of the string. Equivalent to Hash() -+ * symbol_id: If the string is a sequential symbol, the symbol -+ * id, otherwise 0. If the symbol ids of two strings are -+ * the same (and non-zero) the two strings are identical. -+ * If the symbol ids are different the strings may still be -+ * identical, but an Equals() check must be performed. -+ */ -+ V8EXPORT CompleteHashData CompleteHash() const; -+ -+ /** -+ * Compute a hash value for the passed UTF16 string -+ * data. -+ */ -+ V8EXPORT static uint32_t ComputeHash(uint16_t *string, int length); -+ V8EXPORT static uint32_t ComputeHash(char *string, int length); -+ -+ /** -+ * Returns true if this string is equal to the external -+ * string data provided. -+ */ -+ V8EXPORT bool Equals(uint16_t *string, int length); -+ V8EXPORT bool Equals(char *string, int length); -+ inline bool Equals(Handle that) const { return v8::Value::Equals(that); } -+ -+ /** - * Write the contents of the string to an external buffer. - * If no arguments are given, expects the buffer to be large - * enough to hold the entire string and NULL terminator. Copies -@@ -1051,6 +1094,8 @@ class String : public Primitive { - NO_NULL_TERMINATION = 2 - }; - -+ V8EXPORT uint16_t GetCharacter(int index); -+ - // 16-bit character codes. - V8EXPORT int Write(uint16_t* buffer, - int start = 0, -diff --git a/src/api.cc b/src/api.cc -index ac4f07f..996812e 100644 ---- a/src/api.cc -+++ b/src/api.cc -@@ -3633,6 +3633,57 @@ int String::Utf8Length() const { - } - - -+uint32_t String::Hash() const { -+ i::Handle str = Utils::OpenHandle(this); -+ if (IsDeadCheck(str->GetIsolate(), "v8::String::Hash()")) return 0; -+ return str->Hash(); -+} -+ -+ -+String::CompleteHashData String::CompleteHash() const { -+ i::Handle str = Utils::OpenHandle(this); -+ if (IsDeadCheck(str->GetIsolate(), "v8::String::CompleteHash()")) return CompleteHashData(); -+ CompleteHashData result; -+ result.length = str->length(); -+ result.hash = str->Hash(); -+ if (str->IsSeqString()) -+ result.symbol_id = i::SeqString::cast(*str)->symbol_id(); -+ return result; -+} -+ -+ -+uint32_t String::ComputeHash(uint16_t *string, int length) { -+ return i::HashSequentialString(string, length) >> i::String::kHashShift; -+} -+ -+ -+uint32_t String::ComputeHash(char *string, int length) { -+ return i::HashSequentialString(string, length) >> i::String::kHashShift; -+} -+ -+ -+uint16_t String::GetCharacter(int index) -+{ -+ i::Handle str = Utils::OpenHandle(this); -+ return str->Get(index); -+} -+ -+ -+bool String::Equals(uint16_t *string, int length) { -+ i::Handle str = Utils::OpenHandle(this); -+ if (IsDeadCheck(str->GetIsolate(), "v8::String::Equals()")) return 0; -+ return str->SlowEqualsExternal(string, length); -+} -+ -+ -+bool String::Equals(char *string, int length) -+{ -+ i::Handle str = Utils::OpenHandle(this); -+ if (IsDeadCheck(str->GetIsolate(), "v8::String::Equals()")) return 0; -+ return str->SlowEqualsExternal(string, length); -+} -+ -+ - int String::WriteUtf8(char* buffer, - int capacity, - int* nchars_ref, -diff --git a/src/heap-inl.h b/src/heap-inl.h -index aaf2927..4c55d63 100644 ---- a/src/heap-inl.h -+++ b/src/heap-inl.h -@@ -105,6 +105,7 @@ MaybeObject* Heap::AllocateAsciiSymbol(Vector str, - String* answer = String::cast(result); - answer->set_length(str.length()); - answer->set_hash_field(hash_field); -+ SeqString::cast(answer)->set_symbol_id(0); - - ASSERT_EQ(size, answer->Size()); - -@@ -138,6 +139,7 @@ MaybeObject* Heap::AllocateTwoByteSymbol(Vector str, - String* answer = String::cast(result); - answer->set_length(str.length()); - answer->set_hash_field(hash_field); -+ SeqString::cast(answer)->set_symbol_id(0); - - ASSERT_EQ(size, answer->Size()); - -diff --git a/src/heap.cc b/src/heap.cc -index bbb9d3e..d287ead 100644 ---- a/src/heap.cc -+++ b/src/heap.cc -@@ -4009,6 +4009,7 @@ MaybeObject* Heap::AllocateInternalSymbol(unibrow::CharacterStream* buffer, - String* answer = String::cast(result); - answer->set_length(chars); - answer->set_hash_field(hash_field); -+ SeqString::cast(answer)->set_symbol_id(0); - - ASSERT_EQ(size, answer->Size()); - -@@ -4051,6 +4052,7 @@ MaybeObject* Heap::AllocateRawAsciiString(int length, PretenureFlag pretenure) { - HeapObject::cast(result)->set_map(ascii_string_map()); - String::cast(result)->set_length(length); - String::cast(result)->set_hash_field(String::kEmptyHashField); -+ SeqString::cast(result)->set_symbol_id(0); - ASSERT_EQ(size, HeapObject::cast(result)->Size()); - return result; - } -@@ -4086,6 +4088,7 @@ MaybeObject* Heap::AllocateRawTwoByteString(int length, - HeapObject::cast(result)->set_map(string_map()); - String::cast(result)->set_length(length); - String::cast(result)->set_hash_field(String::kEmptyHashField); -+ SeqString::cast(result)->set_symbol_id(0); - ASSERT_EQ(size, HeapObject::cast(result)->Size()); - return result; - } -diff --git a/src/objects-inl.h b/src/objects-inl.h -index dc3aa46..34cae9f 100644 ---- a/src/objects-inl.h -+++ b/src/objects-inl.h -@@ -2082,6 +2082,7 @@ SMI_ACCESSORS(FixedArrayBase, length, kLengthOffset) - SMI_ACCESSORS(FreeSpace, size, kSizeOffset) - - SMI_ACCESSORS(String, length, kLengthOffset) -+SMI_ACCESSORS(SeqString, symbol_id, kSymbolIdOffset) - - - uint32_t String::hash_field() { -diff --git a/src/objects.cc b/src/objects.cc -index 9a87ac5..2946d02 100644 ---- a/src/objects.cc -+++ b/src/objects.cc -@@ -6716,6 +6716,71 @@ static inline bool CompareStringContentsPartial(Isolate* isolate, - } - - -+bool String::SlowEqualsExternal(uc16 *string, int length) { -+ int len = this->length(); -+ if (len != length) return false; -+ if (len == 0) return true; -+ -+ // We know the strings are both non-empty. Compare the first chars -+ // before we try to flatten the strings. -+ if (this->Get(0) != string[0]) return false; -+ -+ String* lhs = this->TryFlattenGetString(); -+ -+ if (lhs->IsFlat()) { -+ String::FlatContent lhs_content = lhs->GetFlatContent(); -+ if (lhs->IsAsciiRepresentation()) { -+ Vector vec1 = lhs_content.ToAsciiVector(); -+ VectorIterator buf1(vec1); -+ VectorIterator ib(string, length); -+ return CompareStringContents(&buf1, &ib); -+ } else { -+ Vector vec1 = lhs_content.ToUC16Vector(); -+ Vector vec2(string, length); -+ return CompareRawStringContents(vec1, vec2); -+ } -+ } else { -+ Isolate* isolate = GetIsolate(); -+ isolate->objects_string_compare_buffer_a()->Reset(0, lhs); -+ VectorIterator ib(string, length); -+ return CompareStringContents(isolate->objects_string_compare_buffer_a(), &ib); -+ } -+} -+ -+ -+bool String::SlowEqualsExternal(char *string, int length) -+{ -+ int len = this->length(); -+ if (len != length) return false; -+ if (len == 0) return true; -+ -+ // We know the strings are both non-empty. Compare the first chars -+ // before we try to flatten the strings. -+ if (this->Get(0) != string[0]) return false; -+ -+ String* lhs = this->TryFlattenGetString(); -+ -+ if (StringShape(lhs).IsSequentialAscii()) { -+ const char* str1 = SeqAsciiString::cast(lhs)->GetChars(); -+ return CompareRawStringContents(Vector(str1, len), -+ Vector(string, len)); -+ } -+ -+ if (lhs->IsFlat()) { -+ String::FlatContent lhs_content = lhs->GetFlatContent(); -+ Vector vec1 = lhs_content.ToUC16Vector(); -+ VectorIterator buf1(vec1); -+ VectorIterator buf2(string, length); -+ return CompareStringContents(&buf1, &buf2); -+ } else { -+ Isolate* isolate = GetIsolate(); -+ isolate->objects_string_compare_buffer_a()->Reset(0, lhs); -+ VectorIterator ib(string, length); -+ return CompareStringContents(isolate->objects_string_compare_buffer_a(), &ib); -+ } -+} -+ -+ - bool String::SlowEquals(String* other) { - // Fast check: negative check with lengths. - int len = length(); -@@ -10716,9 +10781,24 @@ class AsciiSymbolKey : public SequentialSymbolKey { - - MaybeObject* AsObject() { - if (hash_field_ == 0) Hash(); -- return HEAP->AllocateAsciiSymbol(string_, hash_field_); -+ MaybeObject *result = HEAP->AllocateAsciiSymbol(string_, hash_field_); -+ if (!result->IsFailure() && result->ToObjectUnchecked()->IsSeqString()) { -+ while (true) { -+ Atomic32 my_symbol_id = next_symbol_id; -+ if (my_symbol_id > Smi::kMaxValue) -+ break; -+ if (my_symbol_id == NoBarrier_CompareAndSwap(&next_symbol_id, my_symbol_id, my_symbol_id + 1)) { -+ SeqString::cast(result->ToObjectUnchecked())->set_symbol_id(my_symbol_id); -+ break; -+ } -+ } -+ } -+ return result; - } -+ -+ static Atomic32 next_symbol_id; - }; -+Atomic32 AsciiSymbolKey::next_symbol_id = 1; - - - class SubStringAsciiSymbolKey : public HashTableKey { -diff --git a/src/objects.h b/src/objects.h -index f7d2180..d96e5f9 100644 ---- a/src/objects.h -+++ b/src/objects.h -@@ -6201,6 +6201,9 @@ class String: public HeapObject { - bool IsAsciiEqualTo(Vector str); - bool IsTwoByteEqualTo(Vector str); - -+ bool SlowEqualsExternal(uc16 *string, int length); -+ bool SlowEqualsExternal(char *string, int length); -+ - // Return a UTF8 representation of the string. The string is null - // terminated but may optionally contain nulls. Length is returned - // in length_output if length_output is not a null pointer The string -@@ -6457,8 +6460,13 @@ class SeqString: public String { - // Casting. - static inline SeqString* cast(Object* obj); - -+ // Get and set the symbol id of the string -+ inline int symbol_id(); -+ inline void set_symbol_id(int value); -+ - // Layout description. -- static const int kHeaderSize = String::kSize; -+ static const int kSymbolIdOffset = String::kSize; -+ static const int kHeaderSize = kSymbolIdOffset + kPointerSize; - - private: - DISALLOW_IMPLICIT_CONSTRUCTORS(SeqString); --- -1.7.4.1 - diff --git a/src/v8/0002-Add-a-fallback-mode-for-named-property-interceptors.patch b/src/v8/0002-Add-a-fallback-mode-for-named-property-interceptors.patch deleted file mode 100644 index 7ee05ca..0000000 --- a/src/v8/0002-Add-a-fallback-mode-for-named-property-interceptors.patch +++ /dev/null @@ -1,361 +0,0 @@ -From e30b202d683e36731d9674ebf75803990a33816e Mon Sep 17 00:00:00 2001 -From: Aaron Kennedy -Date: Thu, 27 Oct 2011 11:31:56 +0100 -Subject: [PATCH 02/13] Add a "fallback" mode for named property interceptors - -By default interceptors are called before the normal property -resolution on objects. When an interceptor is installed as a -"fallback" interceptor, it is only called if the object doesn't -already have the property. - -In the case of a global object having an fallback interceptor, -the interceptor is not invoked at all for var or function -declarations. ---- - include/v8.h | 7 +++++++ - src/api.cc | 29 +++++++++++++++++++++++++++++ - src/factory.cc | 3 +++ - src/handles.cc | 6 ++++-- - src/handles.h | 3 ++- - src/objects-inl.h | 15 +++++++++++++++ - src/objects.cc | 24 +++++++++++++++++------- - src/objects.h | 16 ++++++++++++---- - src/runtime.cc | 11 ++++++----- - 9 files changed, 95 insertions(+), 19 deletions(-) - -diff --git a/include/v8.h b/include/v8.h -index 86ea70f..d2e6c32 100644 ---- a/include/v8.h -+++ b/include/v8.h -@@ -2305,6 +2305,7 @@ class V8EXPORT FunctionTemplate : public Template { - NamedPropertyQuery query, - NamedPropertyDeleter remover, - NamedPropertyEnumerator enumerator, -+ bool is_fallback, - Handle data); - void SetIndexedInstancePropertyHandler(IndexedPropertyGetter getter, - IndexedPropertySetter setter, -@@ -2388,6 +2389,12 @@ class V8EXPORT ObjectTemplate : public Template { - NamedPropertyDeleter deleter = 0, - NamedPropertyEnumerator enumerator = 0, - Handle data = Handle()); -+ void SetFallbackPropertyHandler(NamedPropertyGetter getter, -+ NamedPropertySetter setter = 0, -+ NamedPropertyQuery query = 0, -+ NamedPropertyDeleter deleter = 0, -+ NamedPropertyEnumerator enumerator = 0, -+ Handle data = Handle()); - - /** - * Sets an indexed property handler on the object template. -diff --git a/src/api.cc b/src/api.cc -index 996812e..e0f3b5a 100644 ---- a/src/api.cc -+++ b/src/api.cc -@@ -1123,6 +1123,7 @@ void FunctionTemplate::SetNamedInstancePropertyHandler( - NamedPropertyQuery query, - NamedPropertyDeleter remover, - NamedPropertyEnumerator enumerator, -+ bool is_fallback, - Handle data) { - i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); - if (IsDeadCheck(isolate, -@@ -1141,6 +1142,7 @@ void FunctionTemplate::SetNamedInstancePropertyHandler( - if (query != 0) SET_FIELD_WRAPPED(obj, set_query, query); - if (remover != 0) SET_FIELD_WRAPPED(obj, set_deleter, remover); - if (enumerator != 0) SET_FIELD_WRAPPED(obj, set_enumerator, enumerator); -+ obj->set_is_fallback(i::Smi::FromInt(is_fallback)); - - if (data.IsEmpty()) data = v8::Undefined(); - obj->set_data(*Utils::OpenHandle(*data)); -@@ -1285,6 +1287,33 @@ void ObjectTemplate::SetNamedPropertyHandler(NamedPropertyGetter getter, - query, - remover, - enumerator, -+ false, -+ data); -+} -+ -+ -+void ObjectTemplate::SetFallbackPropertyHandler(NamedPropertyGetter getter, -+ NamedPropertySetter setter, -+ NamedPropertyQuery query, -+ NamedPropertyDeleter remover, -+ NamedPropertyEnumerator enumerator, -+ Handle data) { -+ i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); -+ if (IsDeadCheck(isolate, "v8::ObjectTemplate::SetNamedPropertyHandler()")) { -+ return; -+ } -+ ENTER_V8(isolate); -+ i::HandleScope scope(isolate); -+ EnsureConstructor(this); -+ i::FunctionTemplateInfo* constructor = -+ i::FunctionTemplateInfo::cast(Utils::OpenHandle(this)->constructor()); -+ i::Handle cons(constructor); -+ Utils::ToLocal(cons)->SetNamedInstancePropertyHandler(getter, -+ setter, -+ query, -+ remover, -+ enumerator, -+ true, - data); - } - -diff --git a/src/factory.cc b/src/factory.cc -index 15f640e..1b95ed1 100644 ---- a/src/factory.cc -+++ b/src/factory.cc -@@ -1213,6 +1213,9 @@ Handle Factory::CreateApiFunction( - // Set interceptor information in the map. - if (!obj->named_property_handler()->IsUndefined()) { - map->set_has_named_interceptor(); -+ InterceptorInfo *nph = InterceptorInfo::cast(obj->named_property_handler()); -+ bool is_fallback = nph->is_fallback()->IsUndefined()?false:nph->is_fallback()->value(); -+ map->set_named_interceptor_is_fallback(is_fallback); - } - if (!obj->indexed_property_handler()->IsUndefined()) { - map->set_has_indexed_interceptor(); -diff --git a/src/handles.cc b/src/handles.cc -index 62851f3..790d224 100644 ---- a/src/handles.cc -+++ b/src/handles.cc -@@ -269,9 +269,11 @@ Handle SetProperty(Handle object, - Handle key, - Handle value, - PropertyAttributes attributes, -- StrictModeFlag strict_mode) { -+ StrictModeFlag strict_mode, -+ bool skip_fallback_interceptor) { - CALL_HEAP_FUNCTION(object->GetIsolate(), -- object->SetProperty(*key, *value, attributes, strict_mode), -+ object->SetProperty(*key, *value, attributes, strict_mode, -+ skip_fallback_interceptor), - Object); - } - -diff --git a/src/handles.h b/src/handles.h -index 06e47fc..c359cb3 100644 ---- a/src/handles.h -+++ b/src/handles.h -@@ -190,7 +190,8 @@ Handle SetProperty(Handle object, - Handle key, - Handle value, - PropertyAttributes attributes, -- StrictModeFlag strict_mode); -+ StrictModeFlag strict_mode, -+ bool skip_fallback_interceptor = false); - - Handle SetProperty(Handle object, - Handle key, -diff --git a/src/objects-inl.h b/src/objects-inl.h -index 34cae9f..1cfea84 100644 ---- a/src/objects-inl.h -+++ b/src/objects-inl.h -@@ -2754,6 +2754,20 @@ void Map::set_is_shared(bool value) { - bool Map::is_shared() { - return ((1 << kIsShared) & bit_field3()) != 0; - } -+ -+void Map::set_named_interceptor_is_fallback(bool value) -+{ -+ if (value) { -+ set_bit_field3(bit_field3() | (1 << kNamedInterceptorIsFallback)); -+ } else { -+ set_bit_field3(bit_field3() & ~(1 << kNamedInterceptorIsFallback)); -+ } -+} -+ -+bool Map::named_interceptor_is_fallback() -+{ -+ return ((1 << kNamedInterceptorIsFallback) & bit_field3()) != 0; -+} - - - JSFunction* Map::unchecked_constructor() { -@@ -3255,6 +3269,7 @@ ACCESSORS(InterceptorInfo, query, Object, kQueryOffset) - ACCESSORS(InterceptorInfo, deleter, Object, kDeleterOffset) - ACCESSORS(InterceptorInfo, enumerator, Object, kEnumeratorOffset) - ACCESSORS(InterceptorInfo, data, Object, kDataOffset) -+ACCESSORS(InterceptorInfo, is_fallback, Smi, kFallbackOffset) - - ACCESSORS(CallHandlerInfo, callback, Object, kCallbackOffset) - ACCESSORS(CallHandlerInfo, data, Object, kDataOffset) -diff --git a/src/objects.cc b/src/objects.cc -index 2946d02..f5b6bee 100644 ---- a/src/objects.cc -+++ b/src/objects.cc -@@ -1980,9 +1980,10 @@ MaybeObject* JSObject::SetPropertyWithInterceptor( - MaybeObject* JSReceiver::SetProperty(String* name, - Object* value, - PropertyAttributes attributes, -- StrictModeFlag strict_mode) { -+ StrictModeFlag strict_mode, -+ bool skip_fallback_interceptor) { - LookupResult result(GetIsolate()); -- LocalLookup(name, &result); -+ LocalLookup(name, &result, skip_fallback_interceptor); - return SetProperty(&result, name, value, attributes, strict_mode); - } - -@@ -4213,7 +4214,8 @@ AccessorDescriptor* Map::FindAccessor(String* name) { - } - - --void JSReceiver::LocalLookup(String* name, LookupResult* result) { -+void JSReceiver::LocalLookup(String* name, LookupResult* result, -+ bool skip_fallback_interceptor) { - ASSERT(name->IsString()); - - Heap* heap = GetHeap(); -@@ -4245,23 +4247,31 @@ void JSReceiver::LocalLookup(String* name, LookupResult* result) { - } - - // Check for lookup interceptor except when bootstrapping. -- if (js_object->HasNamedInterceptor() && -- !heap->isolate()->bootstrapper()->IsActive()) { -+ bool wouldIntercept = js_object->HasNamedInterceptor() && -+ !heap->isolate()->bootstrapper()->IsActive(); -+ if (wouldIntercept && !map()->named_interceptor_is_fallback()) { - result->InterceptorResult(js_object); - return; - } - - js_object->LocalLookupRealNamedProperty(name, result); -+ -+ if (wouldIntercept && !skip_fallback_interceptor && !result->IsProperty() && -+ map()->named_interceptor_is_fallback()) { -+ result->InterceptorResult(js_object); -+ return; -+ } - } - - --void JSReceiver::Lookup(String* name, LookupResult* result) { -+void JSReceiver::Lookup(String* name, LookupResult* result, -+ bool skip_fallback_interceptor) { - // Ecma-262 3rd 8.6.2.4 - Heap* heap = GetHeap(); - for (Object* current = this; - current != heap->null_value(); - current = JSObject::cast(current)->GetPrototype()) { -- JSReceiver::cast(current)->LocalLookup(name, result); -+ JSReceiver::cast(current)->LocalLookup(name, result, skip_fallback_interceptor); - if (result->IsProperty()) return; - } - result->NotFound(); -diff --git a/src/objects.h b/src/objects.h -index d96e5f9..ed40061 100644 ---- a/src/objects.h -+++ b/src/objects.h -@@ -1362,7 +1362,8 @@ class JSReceiver: public HeapObject { - MUST_USE_RESULT MaybeObject* SetProperty(String* key, - Object* value, - PropertyAttributes attributes, -- StrictModeFlag strict_mode); -+ StrictModeFlag strict_mode, -+ bool skip_fallback_interceptor = false); - MUST_USE_RESULT MaybeObject* SetProperty(LookupResult* result, - String* key, - Object* value, -@@ -1414,8 +1415,8 @@ class JSReceiver: public HeapObject { - - // Lookup a property. If found, the result is valid and has - // detailed information. -- void LocalLookup(String* name, LookupResult* result); -- void Lookup(String* name, LookupResult* result); -+ void LocalLookup(String* name, LookupResult* result, bool skip_fallback_interceptor = false); -+ void Lookup(String* name, LookupResult* result, bool skip_fallback_interceptor = false); - - protected: - Smi* GenerateIdentityHash(); -@@ -4242,6 +4243,10 @@ class Map: public HeapObject { - inline void set_is_access_check_needed(bool access_check_needed); - inline bool is_access_check_needed(); - -+ // Whether the named interceptor is a fallback interceptor or not -+ inline void set_named_interceptor_is_fallback(bool value); -+ inline bool named_interceptor_is_fallback(); -+ - // [prototype]: implicit prototype object. - DECL_ACCESSORS(prototype, Object) - -@@ -4506,6 +4511,7 @@ class Map: public HeapObject { - - // Bit positions for bit field 3 - static const int kIsShared = 0; -+ static const int kNamedInterceptorIsFallback = 1; - - // Layout of the default cache. It holds alternating name and code objects. - static const int kCodeCacheEntrySize = 2; -@@ -7390,6 +7396,7 @@ class InterceptorInfo: public Struct { - DECL_ACCESSORS(deleter, Object) - DECL_ACCESSORS(enumerator, Object) - DECL_ACCESSORS(data, Object) -+ DECL_ACCESSORS(is_fallback, Smi) - - static inline InterceptorInfo* cast(Object* obj); - -@@ -7409,7 +7416,8 @@ class InterceptorInfo: public Struct { - static const int kDeleterOffset = kQueryOffset + kPointerSize; - static const int kEnumeratorOffset = kDeleterOffset + kPointerSize; - static const int kDataOffset = kEnumeratorOffset + kPointerSize; -- static const int kSize = kDataOffset + kPointerSize; -+ static const int kFallbackOffset = kDataOffset + kPointerSize; -+ static const int kSize = kFallbackOffset + kPointerSize; - - private: - DISALLOW_IMPLICIT_CONSTRUCTORS(InterceptorInfo); -diff --git a/src/runtime.cc b/src/runtime.cc -index 9c23c2c..0e256c1 100644 ---- a/src/runtime.cc -+++ b/src/runtime.cc -@@ -1330,7 +1330,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_DeclareGlobals) { - // Lookup the property in the global object, and don't set the - // value of the variable if the property is already there. - LookupResult lookup(isolate); -- global->Lookup(*name, &lookup); -+ global->Lookup(*name, &lookup, true); - if (lookup.IsProperty()) { - // We found an existing property. Unless it was an interceptor - // that claims the property is absent, skip this declaration. -@@ -1357,7 +1357,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_DeclareGlobals) { - } - - LookupResult lookup(isolate); -- global->LocalLookup(*name, &lookup); -+ global->LocalLookup(*name, &lookup, true); - - // Compute the property attributes. According to ECMA-262, section - // 13, page 71, the property must be read-only and -@@ -1398,7 +1398,8 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_DeclareGlobals) { - name, - value, - static_cast(attr), -- strict_mode)); -+ strict_mode, -+ true)); - } - } - -@@ -1534,7 +1535,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_InitializeVarGlobal) { - while (object->IsJSObject() && - JSObject::cast(object)->map()->is_hidden_prototype()) { - JSObject* raw_holder = JSObject::cast(object); -- raw_holder->LocalLookup(*name, &lookup); -+ raw_holder->LocalLookup(*name, &lookup, true); - if (lookup.IsProperty() && lookup.type() == INTERCEPTOR) { - HandleScope handle_scope(isolate); - Handle holder(raw_holder); -@@ -1557,7 +1558,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_InitializeVarGlobal) { - // Reload global in case the loop above performed a GC. - global = isolate->context()->global(); - if (assign) { -- return global->SetProperty(*name, args[2], attributes, strict_mode); -+ return global->SetProperty(*name, args[2], attributes, strict_mode, true); - } - return isolate->heap()->undefined_value(); - } --- -1.7.4.1 - diff --git a/src/v8/0003-Generalize-external-object-resources.patch b/src/v8/0003-Generalize-external-object-resources.patch deleted file mode 100644 index 580b8f0..0000000 --- a/src/v8/0003-Generalize-external-object-resources.patch +++ /dev/null @@ -1,595 +0,0 @@ -From 501255df9cb6241a1f6c8d8a3361b9582fa481ef Mon Sep 17 00:00:00 2001 -From: Aaron Kennedy -Date: Tue, 4 Oct 2011 16:06:09 +1000 -Subject: [PATCH 03/13] Generalize external object resources - -V8 was already able to manage and finalize an external string -resource. This change generalizes that mechanism to handle a -single generic external resource - a v8::Object::ExternalResource -derived instance - on normal JSObject's. - -This is useful for mapping C++ objects to JS objects where the -C++ object's memory is effectively owned by the JS Object, and -thus needs to destroyed when the JS Object is garbage collected. -The V8 mailing list suggests using a weak persistent handle for -this purpose, but that seems to incur a fairly massive performance -penalty for short lived objects as weak persistent handle callbacks -are not called until the object has been promoted into the old -object space. ---- - include/v8.h | 25 ++++++++++++++++++++ - src/api.cc | 56 +++++++++++++++++++++++++++++++++++++++++++++ - src/factory.cc | 11 +++++++++ - src/heap-inl.h | 63 +++++++++++++++++++++++++++++++++++--------------- - src/heap.cc | 29 +++++++++++++++++------ - src/heap.h | 16 ++++++++----- - src/mark-compact.cc | 13 +++++----- - src/objects-inl.h | 35 +++++++++++++++++++++++++++- - src/objects.h | 19 ++++++++++++--- - 9 files changed, 223 insertions(+), 44 deletions(-) - -diff --git a/include/v8.h b/include/v8.h -index d2e6c32..3ef4dd6 100644 ---- a/include/v8.h -+++ b/include/v8.h -@@ -1597,6 +1597,25 @@ class Object : public Value { - /** Sets a native pointer in an internal field. */ - V8EXPORT void SetPointerInInternalField(int index, void* value); - -+ class V8EXPORT ExternalResource { // NOLINT -+ public: -+ ExternalResource() {} -+ virtual ~ExternalResource() {} -+ -+ protected: -+ virtual void Dispose() { delete this; } -+ -+ private: -+ // Disallow copying and assigning. -+ ExternalResource(const ExternalResource&); -+ void operator=(const ExternalResource&); -+ -+ friend class v8::internal::Heap; -+ }; -+ -+ V8EXPORT void SetExternalResource(ExternalResource *); -+ V8EXPORT ExternalResource *GetExternalResource(); -+ - // Testers for local properties. - V8EXPORT bool HasOwnProperty(Handle key); - V8EXPORT bool HasRealNamedProperty(Handle key); -@@ -2466,6 +2485,12 @@ class V8EXPORT ObjectTemplate : public Template { - */ - void SetInternalFieldCount(int value); - -+ /** -+ * Sets whether the object can store an "external resource" object. -+ */ -+ bool HasExternalResource(); -+ void SetHasExternalResource(bool value); -+ - private: - ObjectTemplate(); - static Local New(Handle constructor); -diff --git a/src/api.cc b/src/api.cc -index e0f3b5a..7d54252 100644 ---- a/src/api.cc -+++ b/src/api.cc -@@ -1436,6 +1436,34 @@ void ObjectTemplate::SetInternalFieldCount(int value) { - } - - -+bool ObjectTemplate::HasExternalResource() -+{ -+ if (IsDeadCheck(Utils::OpenHandle(this)->GetIsolate(), -+ "v8::ObjectTemplate::HasExternalResource()")) { -+ return 0; -+ } -+ return !Utils::OpenHandle(this)->has_external_resource()->IsUndefined(); -+} -+ -+ -+void ObjectTemplate::SetHasExternalResource(bool value) -+{ -+ i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); -+ if (IsDeadCheck(isolate, "v8::ObjectTemplate::SetHasExternalResource()")) { -+ return; -+ } -+ ENTER_V8(isolate); -+ if (value) { -+ EnsureConstructor(this); -+ } -+ if (value) { -+ Utils::OpenHandle(this)->set_has_external_resource(i::Smi::FromInt(1)); -+ } else { -+ Utils::OpenHandle(this)->set_has_external_resource(Utils::OpenHandle(this)->GetHeap()->undefined_value()); -+ } -+} -+ -+ - // --- S c r i p t D a t a --- - - -@@ -4029,6 +4057,34 @@ void v8::Object::SetPointerInInternalField(int index, void* value) { - } - - -+void v8::Object::SetExternalResource(v8::Object::ExternalResource *resource) { -+ i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); -+ ENTER_V8(isolate); -+ i::Handle obj = Utils::OpenHandle(this); -+ if (CanBeEncodedAsSmi(resource)) { -+ obj->SetExternalResourceObject(EncodeAsSmi(resource)); -+ } else { -+ obj->SetExternalResourceObject(*isolate->factory()->NewForeign(static_cast((void *)resource))); -+ } -+ if (!obj->IsSymbol()) { -+ isolate->heap()->external_string_table()->AddObject(*obj); -+ } -+} -+ -+ -+v8::Object::ExternalResource *v8::Object::GetExternalResource() { -+ i::Handle obj = Utils::OpenHandle(this); -+ i::Object* value = obj->GetExternalResourceObject(); -+ if (value->IsSmi()) { -+ return reinterpret_cast(i::Internals::GetExternalPointerFromSmi(value)); -+ } else if (value->IsForeign()) { -+ return reinterpret_cast(i::Foreign::cast(value)->address()); -+ } else { -+ return NULL; -+ } -+} -+ -+ - // --- E n v i r o n m e n t --- - - -diff --git a/src/factory.cc b/src/factory.cc -index 1b95ed1..8c96944 100644 ---- a/src/factory.cc -+++ b/src/factory.cc -@@ -1152,15 +1152,21 @@ Handle Factory::CreateApiFunction( - Handle construct_stub = isolate()->builtins()->JSConstructStubApi(); - - int internal_field_count = 0; -+ bool has_external_resource = false; -+ - if (!obj->instance_template()->IsUndefined()) { - Handle instance_template = - Handle( - ObjectTemplateInfo::cast(obj->instance_template())); - internal_field_count = - Smi::cast(instance_template->internal_field_count())->value(); -+ has_external_resource = -+ !instance_template->has_external_resource()->IsUndefined(); - } - - int instance_size = kPointerSize * internal_field_count; -+ if (has_external_resource) instance_size += kPointerSize; -+ - InstanceType type = INVALID_TYPE; - switch (instance_type) { - case JavaScriptObject: -@@ -1195,6 +1201,11 @@ Handle Factory::CreateApiFunction( - - Handle map = Handle(result->initial_map()); - -+ // Mark as having external data object if needed -+ if (has_external_resource) { -+ map->set_has_external_resource(true); -+ } -+ - // Mark as undetectable if needed. - if (obj->undetectable()) { - map->set_is_undetectable(); -diff --git a/src/heap-inl.h b/src/heap-inl.h -index 4c55d63..bca57cb 100644 ---- a/src/heap-inl.h -+++ b/src/heap-inl.h -@@ -222,21 +222,36 @@ MaybeObject* Heap::NumberFromUint32(uint32_t value) { - } - - --void Heap::FinalizeExternalString(String* string) { -- ASSERT(string->IsExternalString()); -- v8::String::ExternalStringResourceBase** resource_addr = -- reinterpret_cast( -- reinterpret_cast(string) + -- ExternalString::kResourceOffset - -- kHeapObjectTag); -- -- // Dispose of the C++ object if it has not already been disposed. -- if (*resource_addr != NULL) { -- (*resource_addr)->Dispose(); -+void Heap::FinalizeExternalString(HeapObject* string) { -+ ASSERT(string->IsExternalString() || string->map()->has_external_resource()); -+ -+ if (string->IsExternalString()) { -+ v8::String::ExternalStringResourceBase** resource_addr = -+ reinterpret_cast( -+ reinterpret_cast(string) + -+ ExternalString::kResourceOffset - -+ kHeapObjectTag); -+ -+ // Dispose of the C++ object if it has not already been disposed. -+ if (*resource_addr != NULL) { -+ (*resource_addr)->Dispose(); -+ } -+ -+ // Clear the resource pointer in the string. -+ *resource_addr = NULL; -+ } else { -+ JSObject *object = JSObject::cast(string); -+ Object *value = object->GetExternalResourceObject(); -+ v8::Object::ExternalResource *resource = 0; -+ if (value->IsSmi()) { -+ resource = reinterpret_cast(Internals::GetExternalPointerFromSmi(value)); -+ } else if (value->IsForeign()) { -+ resource = reinterpret_cast(Foreign::cast(value)->address()); -+ } -+ if (resource) { -+ resource->Dispose(); -+ } - } -- -- // Clear the resource pointer in the string. -- *resource_addr = NULL; - } - - -@@ -555,6 +570,16 @@ void ExternalStringTable::AddString(String* string) { - } - - -+void ExternalStringTable::AddObject(HeapObject* object) { -+ ASSERT(object->map()->has_external_resource()); -+ if (heap_->InNewSpace(object)) { -+ new_space_strings_.Add(object); -+ } else { -+ old_space_strings_.Add(object); -+ } -+} -+ -+ - void ExternalStringTable::Iterate(ObjectVisitor* v) { - if (!new_space_strings_.is_empty()) { - Object** start = &new_space_strings_[0]; -@@ -583,14 +608,14 @@ void ExternalStringTable::Verify() { - } - - --void ExternalStringTable::AddOldString(String* string) { -- ASSERT(string->IsExternalString()); -- ASSERT(!heap_->InNewSpace(string)); -- old_space_strings_.Add(string); -+void ExternalStringTable::AddOldObject(HeapObject* object) { -+ ASSERT(object->IsExternalString() || object->map()->has_external_resource()); -+ ASSERT(!heap_->InNewSpace(object)); -+ old_space_strings_.Add(object); - } - - --void ExternalStringTable::ShrinkNewStrings(int position) { -+void ExternalStringTable::ShrinkNewObjects(int position) { - new_space_strings_.Rewind(position); - if (FLAG_verify_heap) { - Verify(); -diff --git a/src/heap.cc b/src/heap.cc -index d287ead..53a0f27 100644 ---- a/src/heap.cc -+++ b/src/heap.cc -@@ -1099,18 +1099,18 @@ void Heap::Scavenge() { - } - - --String* Heap::UpdateNewSpaceReferenceInExternalStringTableEntry(Heap* heap, -- Object** p) { -+HeapObject* Heap::UpdateNewSpaceReferenceInExternalStringTableEntry(Heap* heap, -+ Object** p) { - MapWord first_word = HeapObject::cast(*p)->map_word(); - - if (!first_word.IsForwardingAddress()) { - // Unreachable external string can be finalized. -- heap->FinalizeExternalString(String::cast(*p)); -+ heap->FinalizeExternalString(HeapObject::cast(*p)); - return NULL; - } - - // String is still reachable. -- return String::cast(first_word.ToForwardingAddress()); -+ return HeapObject::cast(first_word.ToForwardingAddress()); - } - - -@@ -1128,11 +1128,11 @@ void Heap::UpdateNewSpaceReferencesInExternalStringTable( - - for (Object** p = start; p < end; ++p) { - ASSERT(InFromSpace(*p)); -- String* target = updater_func(this, p); -+ HeapObject* target = updater_func(this, p); - - if (target == NULL) continue; - -- ASSERT(target->IsExternalString()); -+ ASSERT(target->IsExternalString() || target->map()->has_external_resource()); - - if (InNewSpace(target)) { - // String is still in new space. Update the table entry. -@@ -1140,12 +1140,12 @@ void Heap::UpdateNewSpaceReferencesInExternalStringTable( - ++last; - } else { - // String got promoted. Move it to the old string list. -- external_string_table_.AddOldString(target); -+ external_string_table_.AddOldObject(target); - } - } - - ASSERT(last <= end); -- external_string_table_.ShrinkNewStrings(static_cast(last - start)); -+ external_string_table_.ShrinkNewObjects(static_cast(last - start)); - } - - -@@ -6367,6 +6367,19 @@ void ExternalStringTable::CleanUp() { - - - void ExternalStringTable::TearDown() { -+ for (int i = 0; i < new_space_strings_.length(); ++i) { -+ if (new_space_strings_[i] == heap_->raw_unchecked_null_value()) continue; -+ HeapObject *object = HeapObject::cast(new_space_strings_[i]); -+ if (!object->IsExternalString()) -+ heap_->FinalizeExternalString(object); -+ } -+ for (int i = 0; i < old_space_strings_.length(); ++i) { -+ if (old_space_strings_[i] == heap_->raw_unchecked_null_value()) continue; -+ HeapObject *object = HeapObject::cast(old_space_strings_[i]); -+ if (!object->IsExternalString()) -+ heap_->FinalizeExternalString(object); -+ } -+ - new_space_strings_.Free(); - old_space_strings_.Free(); - } -diff --git a/src/heap.h b/src/heap.h -index 7c0b0ea..5e90964 100644 ---- a/src/heap.h -+++ b/src/heap.h -@@ -245,8 +245,8 @@ class Isolate; - class WeakObjectRetainer; - - --typedef String* (*ExternalStringTableUpdaterCallback)(Heap* heap, -- Object** pointer); -+typedef HeapObject* (*ExternalStringTableUpdaterCallback)(Heap* heap, -+ Object** pointer); - - class StoreBufferRebuilder { - public: -@@ -331,10 +331,14 @@ typedef void (*ScavengingCallback)(Map* map, - // External strings table is a place where all external strings are - // registered. We need to keep track of such strings to properly - // finalize them. -+// The ExternalStringTable can contain both strings and objects with -+// external resources. It was not renamed to make the patch simpler. - class ExternalStringTable { - public: - // Registers an external string. - inline void AddString(String* string); -+ // Registers an external object. -+ inline void AddObject(HeapObject* string); - - inline void Iterate(ObjectVisitor* v); - -@@ -352,10 +356,10 @@ class ExternalStringTable { - - inline void Verify(); - -- inline void AddOldString(String* string); -+ inline void AddOldObject(HeapObject* string); - - // Notifies the table that only a prefix of the new list is valid. -- inline void ShrinkNewStrings(int position); -+ inline void ShrinkNewObjects(int position); - - // To speed up scavenge collections new space string are kept - // separate from old space strings. -@@ -851,7 +855,7 @@ class Heap { - - // Finalizes an external string by deleting the associated external - // data and clearing the resource pointer. -- inline void FinalizeExternalString(String* string); -+ inline void FinalizeExternalString(HeapObject* string); - - // Allocates an uninitialized object. The memory is non-executable if the - // hardware and OS allow. -@@ -1656,7 +1660,7 @@ class Heap { - // Performs a minor collection in new generation. - void Scavenge(); - -- static String* UpdateNewSpaceReferenceInExternalStringTableEntry( -+ static HeapObject* UpdateNewSpaceReferenceInExternalStringTableEntry( - Heap* heap, - Object** pointer); - -diff --git a/src/mark-compact.cc b/src/mark-compact.cc -index b41b033..bf0aab8 100644 ---- a/src/mark-compact.cc -+++ b/src/mark-compact.cc -@@ -1513,8 +1513,9 @@ class SymbolTableCleaner : public ObjectVisitor { - - // Since no objects have yet been moved we can safely access the map of - // the object. -- if (o->IsExternalString()) { -- heap_->FinalizeExternalString(String::cast(*p)); -+ if (o->IsExternalString() || -+ (o->IsHeapObject() && HeapObject::cast(o)->map()->has_external_resource())) { -+ heap_->FinalizeExternalString(HeapObject::cast(*p)); - } - // Set the entry to null_value (as deleted). - *p = heap_->null_value(); -@@ -2487,15 +2488,15 @@ static void UpdatePointer(HeapObject** p, HeapObject* object) { - } - - --static String* UpdateReferenceInExternalStringTableEntry(Heap* heap, -- Object** p) { -+static HeapObject* UpdateReferenceInExternalStringTableEntry(Heap* heap, -+ Object** p) { - MapWord map_word = HeapObject::cast(*p)->map_word(); - - if (map_word.IsForwardingAddress()) { -- return String::cast(map_word.ToForwardingAddress()); -+ return HeapObject::cast(map_word.ToForwardingAddress()); - } - -- return String::cast(*p); -+ return HeapObject::cast(*p); - } - - -diff --git a/src/objects-inl.h b/src/objects-inl.h -index 1cfea84..6a80c9c 100644 ---- a/src/objects-inl.h -+++ b/src/objects-inl.h -@@ -1343,7 +1343,7 @@ int JSObject::GetInternalFieldCount() { - // Make sure to adjust for the number of in-object properties. These - // properties do contribute to the size, but are not internal fields. - return ((Size() - GetHeaderSize()) >> kPointerSizeLog2) - -- map()->inobject_properties(); -+ map()->inobject_properties() - (map()->has_external_resource()?1:0); - } - - -@@ -1373,6 +1373,23 @@ void JSObject::SetInternalField(int index, Object* value) { - } - - -+void JSObject::SetExternalResourceObject(Object *value) { -+ ASSERT(map()->has_external_resource()); -+ int offset = GetHeaderSize() + kPointerSize * GetInternalFieldCount(); -+ WRITE_FIELD(this, offset, value); -+ WRITE_BARRIER(GetHeap(), this, offset, value); -+} -+ -+ -+Object *JSObject::GetExternalResourceObject() { -+ if (map()->has_external_resource()) { -+ return READ_FIELD(this, GetHeaderSize() + kPointerSize * GetInternalFieldCount()); -+ } else { -+ return GetHeap()->undefined_value(); -+ } -+} -+ -+ - // Access fast-case object properties at index. The use of these routines - // is needed to correctly distinguish between properties stored in-object and - // properties stored in the properties array. -@@ -2755,6 +2772,20 @@ bool Map::is_shared() { - return ((1 << kIsShared) & bit_field3()) != 0; - } - -+void Map::set_has_external_resource(bool value) { -+ if (value) { -+ set_bit_field(bit_field() | (1 << kHasExternalResource)); -+ } else { -+ set_bit_field(bit_field() & ~(1 << kHasExternalResource)); -+ } -+} -+ -+bool Map::has_external_resource() -+{ -+ return ((1 << kHasExternalResource) & bit_field()) != 0; -+} -+ -+ - void Map::set_named_interceptor_is_fallback(bool value) - { - if (value) { -@@ -3301,6 +3332,8 @@ ACCESSORS(FunctionTemplateInfo, flag, Smi, kFlagOffset) - ACCESSORS(ObjectTemplateInfo, constructor, Object, kConstructorOffset) - ACCESSORS(ObjectTemplateInfo, internal_field_count, Object, - kInternalFieldCountOffset) -+ACCESSORS(ObjectTemplateInfo, has_external_resource, Object, -+ kHasExternalResourceOffset) - - ACCESSORS(SignatureInfo, receiver, Object, kReceiverOffset) - ACCESSORS(SignatureInfo, args, Object, kArgsOffset) -diff --git a/src/objects.h b/src/objects.h -index ed40061..c38d461 100644 ---- a/src/objects.h -+++ b/src/objects.h -@@ -1760,6 +1760,9 @@ class JSObject: public JSReceiver { - inline Object* GetInternalField(int index); - inline void SetInternalField(int index, Object* value); - -+ inline void SetExternalResourceObject(Object *); -+ inline Object *GetExternalResourceObject(); -+ - // The following lookup functions skip interceptors. - void LocalLookupRealNamedProperty(String* name, LookupResult* result); - void LookupRealNamedProperty(String* name, LookupResult* result); -@@ -4171,11 +4174,11 @@ class Map: public HeapObject { - - // Tells whether the instance has a call-as-function handler. - inline void set_has_instance_call_handler() { -- set_bit_field(bit_field() | (1 << kHasInstanceCallHandler)); -+ set_bit_field3(bit_field3() | (1 << kHasInstanceCallHandler)); - } - - inline bool has_instance_call_handler() { -- return ((1 << kHasInstanceCallHandler) & bit_field()) != 0; -+ return ((1 << kHasInstanceCallHandler) & bit_field3()) != 0; - } - - inline void set_is_extensible(bool value); -@@ -4247,6 +4250,11 @@ class Map: public HeapObject { - inline void set_named_interceptor_is_fallback(bool value); - inline bool named_interceptor_is_fallback(); - -+ // Tells whether the instance has the space for an external resource -+ // object -+ inline void set_has_external_resource(bool value); -+ inline bool has_external_resource(); -+ - // [prototype]: implicit prototype object. - DECL_ACCESSORS(prototype, Object) - -@@ -4487,7 +4495,7 @@ class Map: public HeapObject { - static const int kHasNamedInterceptor = 3; - static const int kHasIndexedInterceptor = 4; - static const int kIsUndetectable = 5; -- static const int kHasInstanceCallHandler = 6; -+ static const int kHasExternalResource = 6; - static const int kIsAccessCheckNeeded = 7; - - // Bit positions for bit field 2 -@@ -4512,6 +4520,7 @@ class Map: public HeapObject { - // Bit positions for bit field 3 - static const int kIsShared = 0; - static const int kNamedInterceptorIsFallback = 1; -+ static const int kHasInstanceCallHandler = 2; - - // Layout of the default cache. It holds alternating name and code objects. - static const int kCodeCacheEntrySize = 2; -@@ -7539,6 +7548,7 @@ class ObjectTemplateInfo: public TemplateInfo { - public: - DECL_ACCESSORS(constructor, Object) - DECL_ACCESSORS(internal_field_count, Object) -+ DECL_ACCESSORS(has_external_resource, Object) - - static inline ObjectTemplateInfo* cast(Object* obj); - -@@ -7555,7 +7565,8 @@ class ObjectTemplateInfo: public TemplateInfo { - static const int kConstructorOffset = TemplateInfo::kHeaderSize; - static const int kInternalFieldCountOffset = - kConstructorOffset + kPointerSize; -- static const int kSize = kInternalFieldCountOffset + kPointerSize; -+ static const int kHasExternalResourceOffset = kInternalFieldCountOffset + kPointerSize; -+ static const int kSize = kHasExternalResourceOffset + kPointerSize; - }; - - --- -1.7.4.1 - diff --git a/src/v8/0004-Introduce-a-QML-compilation-mode.patch b/src/v8/0004-Introduce-a-QML-compilation-mode.patch deleted file mode 100644 index 84823ca..0000000 --- a/src/v8/0004-Introduce-a-QML-compilation-mode.patch +++ /dev/null @@ -1,2355 +0,0 @@ -From c49c39afa016b176c933ff01e748a2eddb26e131 Mon Sep 17 00:00:00 2001 -From: Aaron Kennedy -Date: Thu, 27 Oct 2011 13:34:16 +0100 -Subject: [PATCH 04/13] Introduce a QML compilation mode - -In QML mode, there is a second global object - known as the QML -global object. During property resolution, if a property is not -present on the JS global object, it is resolved on the QML global -object. - -This global object behavior is only enabled if a script is being -compiled in QML mode. The object to use as the QML global object -is passed as a parameter to the Script::Run() method. Any function -closures etc. created during the run will retain a reference to this -object, so different objects can be passed in different script -runs. ---- - include/v8.h | 19 +++++++-- - src/api.cc | 52 +++++++++++++++++++---- - src/arm/code-stubs-arm.cc | 4 ++ - src/arm/full-codegen-arm.cc | 28 +++++++----- - src/arm/lithium-arm.cc | 4 +- - src/arm/lithium-arm.h | 12 +++++- - src/arm/lithium-codegen-arm.cc | 9 ++-- - src/arm/macro-assembler-arm.h | 5 ++ - src/ast-inl.h | 5 ++ - src/ast.cc | 5 ++ - src/ast.h | 1 + - src/code-stubs.h | 2 +- - src/compiler.cc | 15 ++++++- - src/compiler.h | 16 ++++++- - src/contexts.cc | 35 ++++++++++++++++ - src/contexts.h | 4 ++ - src/execution.cc | 31 ++++++++++++-- - src/execution.h | 8 ++++ - src/full-codegen.cc | 3 +- - src/full-codegen.h | 1 + - src/heap.cc | 4 ++ - src/hydrogen-instructions.cc | 5 ++ - src/hydrogen-instructions.h | 21 ++++++++- - src/hydrogen.cc | 4 ++ - src/ia32/code-stubs-ia32.cc | 5 ++ - src/ia32/full-codegen-ia32.cc | 28 +++++++----- - src/ia32/lithium-codegen-ia32.cc | 9 ++-- - src/ia32/lithium-ia32.cc | 4 +- - src/ia32/lithium-ia32.h | 12 +++++- - src/ia32/macro-assembler-ia32.h | 3 + - src/mips/code-stubs-mips.cc | 5 ++ - src/mips/full-codegen-mips.cc | 30 ++++++++----- - src/mips/macro-assembler-mips.h | 5 ++ - src/objects-inl.h | 2 + - src/objects.h | 7 +++ - src/parser.cc | 28 +++++++++++-- - src/parser.h | 4 +- - src/prettyprinter.cc | 3 + - src/runtime.cc | 84 +++++++++++++++++++++++++------------- - src/runtime.h | 8 ++-- - src/scopeinfo.cc | 28 ++++++++++--- - src/scopeinfo.h | 1 + - src/scopes.cc | 63 ++++++++++++++++++++++++++++ - src/scopes.h | 8 ++++ - src/variables.cc | 3 +- - src/variables.h | 5 ++ - src/x64/code-stubs-x64.cc | 4 ++ - src/x64/full-codegen-x64.cc | 28 +++++++----- - src/x64/lithium-codegen-x64.cc | 9 ++-- - src/x64/lithium-x64.cc | 4 +- - src/x64/lithium-x64.h | 12 +++++ - src/x64/macro-assembler-x64.h | 5 ++ - 52 files changed, 559 insertions(+), 141 deletions(-) - -diff --git a/include/v8.h b/include/v8.h -index 3ef4dd6..193e2fe 100644 ---- a/include/v8.h -+++ b/include/v8.h -@@ -587,6 +587,11 @@ class ScriptOrigin { - */ - class V8EXPORT Script { - public: -+ enum CompileFlags { -+ Default = 0x00, -+ QmlMode = 0x01 -+ }; -+ - /** - * Compiles the specified script (context-independent). - * -@@ -605,7 +610,8 @@ class V8EXPORT Script { - static Local