From b095e7f7b79b537433f955214d5d0d1de3f12df1 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Thu, 14 Jul 2011 14:46:23 +1000 Subject: [PATCH] Update V8 Fixes a bug in threadsafe symbol id generation, and adds a ComputeHash implementation for const char * strings. Change-Id: Id1fb4c7d9bf8eae59229b3893e8a9ef20dede336 Reviewed-on: http://codereview.qt.nokia.com/1621 Reviewed-by: Qt Sanity Bot Reviewed-by: Aaron Kennedy Reviewed-by: Simon Hausmann --- src/3rdparty/v8 | 2 +- ...shing-and-comparison-methods-to-v8-String.patch | 29 +++++++++++++--------- src/v8/0002-Add-a-bit-field-3-to-Map.patch | 4 +-- ...back-mode-for-named-property-interceptors.patch | 12 ++++----- ...0004-Generalize-external-object-resources.patch | 20 +++++++-------- src/v8/0005-Introduce-a-QML-compilation-mode.patch | 10 ++++---- ...6-Allow-access-to-the-calling-script-data.patch | 10 ++++---- src/v8/0007-Fix-warnings.patch | 8 +++--- .../0008-Add-custom-object-compare-callback.patch | 14 +++++------ 9 files changed, 57 insertions(+), 52 deletions(-) diff --git a/src/3rdparty/v8 b/src/3rdparty/v8 index eb2dadf..bec11b8 160000 --- a/src/3rdparty/v8 +++ b/src/3rdparty/v8 @@ -1 +1 @@ -Subproject commit eb2dadf516823ec342e6d75a3a78b2af7b1dea85 +Subproject commit bec11b8b7f89d135e7d9a823ac4fe98c70d017cf 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 index e18e5bc..4596202 100644 --- 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 @@ -1,4 +1,4 @@ -From 9a956953836844f1342ac012f4c2408405224fcd Mon Sep 17 00:00:00 2001 +From e13ce09287a56c920d5ffdc5d4662d49f1838f16 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Mon, 23 May 2011 15:47:20 +1000 Subject: [PATCH 1/8] Add hashing and comparison methods to v8::String @@ -6,20 +6,20 @@ Subject: [PATCH 1/8] 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 | 43 +++++++++++++++++++++++++++++ - src/api.cc | 39 +++++++++++++++++++++++++++ + include/v8.h | 44 ++++++++++++++++++++++++++++++ + src/api.cc | 43 +++++++++++++++++++++++++++++ src/heap-inl.h | 2 + src/heap.cc | 3 ++ src/objects-inl.h | 1 + src/objects.cc | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++- src/objects.h | 15 +++++++++- - 7 files changed, 177 insertions(+), 3 deletions(-) + 7 files changed, 182 insertions(+), 3 deletions(-) diff --git a/include/v8.h b/include/v8.h -index d15d024..626f34c 100644 +index d15d024..bbd29e9 100644 --- a/include/v8.h +++ b/include/v8.h -@@ -994,6 +994,47 @@ class String : public Primitive { +@@ -994,6 +994,48 @@ class String : public Primitive { V8EXPORT int Utf8Length() const; /** @@ -55,6 +55,7 @@ index d15d024..626f34c 100644 + * 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 @@ -67,7 +68,7 @@ index d15d024..626f34c 100644 * 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 -@@ -1023,6 +1064,8 @@ class String : public Primitive { +@@ -1023,6 +1065,8 @@ class String : public Primitive { HINT_MANY_WRITES_EXPECTED = 1 }; @@ -77,10 +78,10 @@ index d15d024..626f34c 100644 int start = 0, int length = -1, diff --git a/src/api.cc b/src/api.cc -index a2373cd..0d860bd 100644 +index a2373cd..381935b 100644 --- a/src/api.cc +++ b/src/api.cc -@@ -3284,6 +3284,45 @@ int String::Utf8Length() const { +@@ -3284,6 +3284,49 @@ int String::Utf8Length() const { return str->Utf8Length(); } @@ -105,6 +106,10 @@ index a2373cd..0d860bd 100644 + 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); @@ -187,7 +192,7 @@ index 65aec5d..c82080d 100644 uint32_t String::hash_field() { diff --git a/src/objects.cc b/src/objects.cc -index df61956..877da3d 100644 +index df61956..dc4b260 100644 --- a/src/objects.cc +++ b/src/objects.cc @@ -5346,6 +5346,66 @@ static inline bool CompareStringContentsPartial(Isolate* isolate, @@ -268,8 +273,8 @@ index df61956..877da3d 100644 + 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(next_symbol_id++); ++ 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; + } + } diff --git a/src/v8/0002-Add-a-bit-field-3-to-Map.patch b/src/v8/0002-Add-a-bit-field-3-to-Map.patch index 98cc017..cb578c0 100644 --- a/src/v8/0002-Add-a-bit-field-3-to-Map.patch +++ b/src/v8/0002-Add-a-bit-field-3-to-Map.patch @@ -1,4 +1,4 @@ -From 4ce6693b28f0a699acd91c0ae88ae917cc273e9a Mon Sep 17 00:00:00 2001 +From 7c9cfff80b7864d5687432d424074e51712c4a07 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Mon, 23 May 2011 15:55:26 +1000 Subject: [PATCH 2/8] Add a bit field 3 to Map @@ -53,7 +53,7 @@ index c82080d..cce3edd 100644 if (value) { set_bit_field(bit_field() | (1 << kHasNonInstancePrototype)); diff --git a/src/objects.cc b/src/objects.cc -index 877da3d..2409ea3 100644 +index dc4b260..79d7240 100644 --- a/src/objects.cc +++ b/src/objects.cc @@ -3614,6 +3614,7 @@ MaybeObject* Map::CopyDropDescriptors() { diff --git a/src/v8/0003-Add-a-fallback-mode-for-named-property-interceptors.patch b/src/v8/0003-Add-a-fallback-mode-for-named-property-interceptors.patch index 6af02cf..daa2250 100644 --- a/src/v8/0003-Add-a-fallback-mode-for-named-property-interceptors.patch +++ b/src/v8/0003-Add-a-fallback-mode-for-named-property-interceptors.patch @@ -1,4 +1,4 @@ -From 5adbbff4a7f09a02d5c2d9b4e15dde89080e2405 Mon Sep 17 00:00:00 2001 +From ae8688b53d67044f2c9b0cce25fc282b078610c1 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Mon, 23 May 2011 16:21:02 +1000 Subject: [PATCH 3/8] Add a "fallback" mode for named property interceptors @@ -24,10 +24,10 @@ declarations. 9 files changed, 99 insertions(+), 18 deletions(-) diff --git a/include/v8.h b/include/v8.h -index 626f34c..06085ec 100644 +index bbd29e9..85452aa 100644 --- a/include/v8.h +++ b/include/v8.h -@@ -2168,6 +2168,7 @@ class V8EXPORT FunctionTemplate : public Template { +@@ -2169,6 +2169,7 @@ class V8EXPORT FunctionTemplate : public Template { NamedPropertyQuery query, NamedPropertyDeleter remover, NamedPropertyEnumerator enumerator, @@ -35,7 +35,7 @@ index 626f34c..06085ec 100644 Handle data); void SetIndexedInstancePropertyHandler(IndexedPropertyGetter getter, IndexedPropertySetter setter, -@@ -2252,6 +2253,13 @@ class V8EXPORT ObjectTemplate : public Template { +@@ -2253,6 +2254,13 @@ class V8EXPORT ObjectTemplate : public Template { NamedPropertyEnumerator enumerator = 0, Handle data = Handle()); @@ -50,7 +50,7 @@ index 626f34c..06085ec 100644 * Sets an indexed property handler on the object template. * diff --git a/src/api.cc b/src/api.cc -index 0d860bd..c20b062 100644 +index 381935b..8b0b32a 100644 --- a/src/api.cc +++ b/src/api.cc @@ -981,6 +981,7 @@ void FunctionTemplate::SetNamedInstancePropertyHandler( @@ -185,7 +185,7 @@ index cce3edd..6aaca2f 100644 ACCESSORS(CallHandlerInfo, callback, Object, kCallbackOffset) ACCESSORS(CallHandlerInfo, data, Object, kDataOffset) diff --git a/src/objects.cc b/src/objects.cc -index 2409ea3..f1e4c8c 100644 +index 79d7240..15e2cdb 100644 --- a/src/objects.cc +++ b/src/objects.cc @@ -1712,9 +1712,10 @@ MaybeObject* JSObject::SetPropertyWithInterceptor( diff --git a/src/v8/0004-Generalize-external-object-resources.patch b/src/v8/0004-Generalize-external-object-resources.patch index 3d5686f..56e5e37 100644 --- a/src/v8/0004-Generalize-external-object-resources.patch +++ b/src/v8/0004-Generalize-external-object-resources.patch @@ -1,4 +1,4 @@ -From 8f640251aeac30f08ddb7bc4c0fe6ba6ff7eabdd Mon Sep 17 00:00:00 2001 +From 4827116b12c50f6662794017c5a662b5dbb2da0b Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Mon, 23 May 2011 16:55:35 +1000 Subject: [PATCH 4/8] Generalize external object resources @@ -31,10 +31,10 @@ object space. 11 files changed, 280 insertions(+), 115 deletions(-) diff --git a/include/v8.h b/include/v8.h -index 06085ec..9740251 100644 +index 85452aa..7f06ae7 100644 --- a/include/v8.h +++ b/include/v8.h -@@ -1629,6 +1629,25 @@ class Object : public Value { +@@ -1630,6 +1630,25 @@ class Object : public Value { /** Sets a native pointer in an internal field. */ V8EXPORT void SetPointerInInternalField(int index, void* value); @@ -60,7 +60,7 @@ index 06085ec..9740251 100644 // Testers for local properties. V8EXPORT bool HasRealNamedProperty(Handle key); V8EXPORT bool HasRealIndexedProperty(uint32_t index); -@@ -2330,6 +2349,12 @@ class V8EXPORT ObjectTemplate : public Template { +@@ -2331,6 +2350,12 @@ class V8EXPORT ObjectTemplate : public Template { */ void SetInternalFieldCount(int value); @@ -74,7 +74,7 @@ index 06085ec..9740251 100644 ObjectTemplate(); static Local New(Handle constructor); diff --git a/src/api.cc b/src/api.cc -index c20b062..d81ece8 100644 +index 8b0b32a..1a6fbbb 100644 --- a/src/api.cc +++ b/src/api.cc @@ -1294,6 +1294,34 @@ void ObjectTemplate::SetInternalFieldCount(int value) { @@ -112,7 +112,7 @@ index c20b062..d81ece8 100644 // --- S c r i p t D a t a --- -@@ -3648,6 +3676,34 @@ void v8::Object::SetPointerInInternalField(int index, void* value) { +@@ -3652,6 +3680,34 @@ void v8::Object::SetPointerInInternalField(int index, void* value) { } @@ -147,7 +147,7 @@ index c20b062..d81ece8 100644 // --- E n v i r o n m e n t --- -@@ -4140,7 +4196,7 @@ Local v8::String::NewExternal( +@@ -4144,7 +4200,7 @@ Local v8::String::NewExternal( LOG_API(isolate, "String::NewExternal"); ENTER_V8(isolate); i::Handle result = NewExternalStringHandle(isolate, resource); @@ -156,7 +156,7 @@ index c20b062..d81ece8 100644 return Utils::ToLocal(result); } -@@ -4158,7 +4214,7 @@ bool v8::String::MakeExternal(v8::String::ExternalStringResource* resource) { +@@ -4162,7 +4218,7 @@ bool v8::String::MakeExternal(v8::String::ExternalStringResource* resource) { } bool result = obj->MakeExternal(resource); if (result && !obj->IsSymbol()) { @@ -165,7 +165,7 @@ index c20b062..d81ece8 100644 } return result; } -@@ -4171,7 +4227,7 @@ Local v8::String::NewExternal( +@@ -4175,7 +4231,7 @@ Local v8::String::NewExternal( LOG_API(isolate, "String::NewExternal"); ENTER_V8(isolate); i::Handle result = NewExternalAsciiStringHandle(isolate, resource); @@ -174,7 +174,7 @@ index c20b062..d81ece8 100644 return Utils::ToLocal(result); } -@@ -4190,7 +4246,7 @@ bool v8::String::MakeExternal( +@@ -4194,7 +4250,7 @@ bool v8::String::MakeExternal( } bool result = obj->MakeExternal(resource); if (result && !obj->IsSymbol()) { diff --git a/src/v8/0005-Introduce-a-QML-compilation-mode.patch b/src/v8/0005-Introduce-a-QML-compilation-mode.patch index 930e2b9..7ec10e9 100644 --- a/src/v8/0005-Introduce-a-QML-compilation-mode.patch +++ b/src/v8/0005-Introduce-a-QML-compilation-mode.patch @@ -1,4 +1,4 @@ -From de8b6a719219677dc8e34248de7836369bf1034d Mon Sep 17 00:00:00 2001 +From fd7d475e298e5b63cd6383c78cc900635c82aa38 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Mon, 23 May 2011 18:26:19 +1000 Subject: [PATCH 5/8] Introduce a QML compilation mode @@ -63,7 +63,7 @@ runs. 45 files changed, 391 insertions(+), 108 deletions(-) diff --git a/include/v8.h b/include/v8.h -index 9740251..d04b73e 100644 +index 7f06ae7..a858eae 100644 --- a/include/v8.h +++ b/include/v8.h @@ -577,6 +577,10 @@ class ScriptOrigin { @@ -125,7 +125,7 @@ index 9740251..d04b73e 100644 /** * Returns the script id value. -@@ -3325,6 +3334,7 @@ class V8EXPORT Context { +@@ -3326,6 +3335,7 @@ class V8EXPORT Context { * JavaScript frames an empty handle is returned. */ static Local GetCalling(); @@ -134,7 +134,7 @@ index 9740251..d04b73e 100644 /** * Sets the security token for the context. To access an object in diff --git a/src/api.cc b/src/api.cc -index d81ece8..0635f34 100644 +index 1a6fbbb..39767f4 100644 --- a/src/api.cc +++ b/src/api.cc @@ -1372,7 +1372,8 @@ ScriptData* ScriptData::New(const char* data, int length) { @@ -219,7 +219,7 @@ index d81ece8..0635f34 100644 EXCEPTION_BAILOUT_CHECK(isolate, Local()); raw_result = *result; } -@@ -3939,6 +3949,30 @@ v8::Local Context::GetCalling() { +@@ -3943,6 +3953,30 @@ v8::Local Context::GetCalling() { } diff --git a/src/v8/0006-Allow-access-to-the-calling-script-data.patch b/src/v8/0006-Allow-access-to-the-calling-script-data.patch index 214fe82..7af81c3 100644 --- a/src/v8/0006-Allow-access-to-the-calling-script-data.patch +++ b/src/v8/0006-Allow-access-to-the-calling-script-data.patch @@ -1,4 +1,4 @@ -From 55ac15fff18ba2d0469c92c533e7ceb1c343fcd9 Mon Sep 17 00:00:00 2001 +From f890f0d1a1e5bd62711815489c87755a4f382436 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Wed, 25 May 2011 10:36:13 +1000 Subject: [PATCH 6/8] Allow access to the calling script data @@ -9,10 +9,10 @@ Subject: [PATCH 6/8] Allow access to the calling script data 2 files changed, 13 insertions(+), 0 deletions(-) diff --git a/include/v8.h b/include/v8.h -index d04b73e..5f9e725 100644 +index a858eae..9aba4a8 100644 --- a/include/v8.h +++ b/include/v8.h -@@ -3335,6 +3335,7 @@ class V8EXPORT Context { +@@ -3336,6 +3336,7 @@ class V8EXPORT Context { */ static Local GetCalling(); static Local GetCallingQmlGlobal(); @@ -21,10 +21,10 @@ index d04b73e..5f9e725 100644 /** * Sets the security token for the context. To access an object in diff --git a/src/api.cc b/src/api.cc -index 0635f34..ba487e8 100644 +index 39767f4..ff74efb 100644 --- a/src/api.cc +++ b/src/api.cc -@@ -3972,6 +3972,18 @@ v8::Local Context::GetCallingQmlGlobal() { +@@ -3976,6 +3976,18 @@ v8::Local Context::GetCallingQmlGlobal() { } } diff --git a/src/v8/0007-Fix-warnings.patch b/src/v8/0007-Fix-warnings.patch index 1b7da91..2efc833 100644 --- a/src/v8/0007-Fix-warnings.patch +++ b/src/v8/0007-Fix-warnings.patch @@ -1,4 +1,4 @@ -From d37bb342f33c384e912ec7d86dfda8f384253ddd Mon Sep 17 00:00:00 2001 +From dac5d9db84cf20564621c679937ca7b9c6a8e880 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Fri, 27 May 2011 13:04:15 +1000 Subject: [PATCH 7/8] Fix warnings @@ -8,10 +8,10 @@ Subject: [PATCH 7/8] Fix warnings 1 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/v8.h b/include/v8.h -index 5f9e725..255b90b 100644 +index 9aba4a8..8891dab 100644 --- a/include/v8.h +++ b/include/v8.h -@@ -2414,7 +2414,7 @@ class V8EXPORT Extension { // NOLINT +@@ -2415,7 +2415,7 @@ class V8EXPORT Extension { // NOLINT const char** deps = 0); virtual ~Extension() { } virtual v8::Handle @@ -20,7 +20,7 @@ index 5f9e725..255b90b 100644 return v8::Handle(); } -@@ -3720,13 +3720,13 @@ class Internals { +@@ -3721,13 +3721,13 @@ class Internals { return *reinterpret_cast(addr); } diff --git a/src/v8/0008-Add-custom-object-compare-callback.patch b/src/v8/0008-Add-custom-object-compare-callback.patch index ecc6eaa..659cf4c 100644 --- a/src/v8/0008-Add-custom-object-compare-callback.patch +++ b/src/v8/0008-Add-custom-object-compare-callback.patch @@ -1,4 +1,4 @@ -From eb2dadf516823ec342e6d75a3a78b2af7b1dea85 Mon Sep 17 00:00:00 2001 +From bec11b8b7f89d135e7d9a823ac4fe98c70d017cf Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Mon, 27 Jun 2011 14:57:28 +1000 Subject: [PATCH 8/8] Add custom object compare callback @@ -28,10 +28,10 @@ instances. 12 files changed, 218 insertions(+), 3 deletions(-) diff --git a/include/v8.h b/include/v8.h -index 255b90b..52a5839 100644 +index 8891dab..d5d6972 100644 --- a/include/v8.h +++ b/include/v8.h -@@ -2364,6 +2364,12 @@ class V8EXPORT ObjectTemplate : public Template { +@@ -2365,6 +2365,12 @@ class V8EXPORT ObjectTemplate : public Template { bool HasExternalResource(); void SetHasExternalResource(bool value); @@ -44,7 +44,7 @@ index 255b90b..52a5839 100644 private: ObjectTemplate(); static Local New(Handle constructor); -@@ -2564,6 +2570,10 @@ typedef void (*FailedAccessCheckCallback)(Local target, +@@ -2565,6 +2571,10 @@ typedef void (*FailedAccessCheckCallback)(Local target, AccessType type, Local data); @@ -55,7 +55,7 @@ index 255b90b..52a5839 100644 // --- G a r b a g e C o l l e c t i o n C a l l b a c k s /** -@@ -2814,6 +2824,9 @@ class V8EXPORT V8 { +@@ -2815,6 +2825,9 @@ class V8EXPORT V8 { /** Callback function for reporting failed access checks.*/ static void SetFailedAccessCheckCallbackFunction(FailedAccessCheckCallback); @@ -66,7 +66,7 @@ index 255b90b..52a5839 100644 * Enables the host application to receive a notification before a * garbage collection. Allocations are not allowed in the diff --git a/src/api.cc b/src/api.cc -index ba487e8..930f338 100644 +index ff74efb..2436031 100644 --- a/src/api.cc +++ b/src/api.cc @@ -1321,6 +1321,16 @@ void ObjectTemplate::SetHasExternalResource(bool value) @@ -86,7 +86,7 @@ index ba487e8..930f338 100644 // --- S c r i p t D a t a --- -@@ -4628,6 +4638,15 @@ void V8::SetFailedAccessCheckCallbackFunction( +@@ -4632,6 +4642,15 @@ void V8::SetFailedAccessCheckCallbackFunction( isolate->SetFailedAccessCheckCallback(callback); } -- 2.7.4