Reviewers: Igor Sheludko, Toon Verwaest,

Message:
PTAL

Description:
Check for cached transition to ExternalArray elements kind.

[email protected],[email protected]
BUG=v8:3337
LOG=Y

Please review this at https://codereview.chromium.org/291193011/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files (+25, -1 lines):
  M src/objects.cc
  M test/cctest/test-api.cc


Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index 68151dbf324c99699c880545606ec874734412f7..6d94c1006b1c582a0cfdd25e762383a7e6f40167 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -3379,9 +3379,16 @@ static Map* FindClosestElementsTransition(Map* map, ElementsKind to_kind) {
       ? to_kind
       : TERMINAL_FAST_ELEMENTS_KIND;

-  // Support for legacy API.
+  // Support for legacy API: SetIndexedPropertiesTo{External,Pixel}Data
+  // allows to change elements from arbitrary kind to any
+ // ExternalArray elements kind. Satisfy its requirements, checking whether
+  // we already have the cached transition.
   if (IsExternalArrayElementsKind(to_kind) &&
       !IsFixedTypedArrayElementsKind(map->elements_kind())) {
+    if (map->HasElementsTransition()) {
+        Map* next_map = map->elements_transition_map();
+        if (next_map->elements_kind() == to_kind) return next_map;
+    }
     return map;
   }

Index: test/cctest/test-api.cc
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index 003a51134dc3fa35d9be4017fa1702171c76ee0d..aecd1405708575017ee1d5bb90e3807f501df065 100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -21404,6 +21404,23 @@ THREADED_TEST(Regress142088) {
 }


+THREADED_TEST(Regress3337) {
+  LocalContext context;
+  v8::Isolate* isolate = context->GetIsolate();
+  v8::HandleScope scope(isolate);
+  Local<v8::Object> o1 = Object::New(isolate);
+  Local<v8::Object> o2 = Object::New(isolate);
+  i::Handle<i::JSObject> io1 = v8::Utils::OpenHandle(*o1);
+  i::Handle<i::JSObject> io2 = v8::Utils::OpenHandle(*o2);
+  CHECK(io1->map() == io2->map());
+  o1->SetIndexedPropertiesToExternalArrayData(
+      NULL, v8::kExternalUint32Array, 0);
+  o2->SetIndexedPropertiesToExternalArrayData(
+      NULL, v8::kExternalUint32Array, 0);
+  CHECK(io1->map() == io2->map());
+}
+
+
 THREADED_TEST(Regress137496) {
   i::FLAG_expose_gc = true;
   LocalContext context;


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to