Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(811)

Unified Diff: src/objects.cc

Issue 2541113004: [Ignition/turbo] Add a NewWithSpread bytecode. (Closed)
Patch Set: Add todo Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/objects.h ('k') | src/runtime/runtime.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index 11114f9c04d007dc7c4309a23b43230135fbfedd..cbfe8132e5bcac2618f3591a93eebf000ffbe5ae 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -2175,6 +2175,35 @@ MaybeHandle<Object> Object::ArraySpeciesConstructor(
}
}
+bool Object::IterationHasObservableEffects() {
+ if (IsJSArray()) {
+ // Check that the spread arg has fast elements
+ JSArray* spread_array = JSArray::cast(this);
+ ElementsKind array_kind = spread_array->GetElementsKind();
+ Isolate* isolate = spread_array->GetIsolate();
+
+ // And that it has the orignal ArrayPrototype
+ JSObject* array_proto = JSObject::cast(spread_array->map()->prototype());
+ Map* iterator_map = isolate->initial_array_iterator_prototype()->map();
+
+ // Check that the iterator acts as expected.
+ // If IsArrayIteratorLookupChainIntact(), then we know that the initial
+ // ArrayIterator is being used. If the map of the prototype has changed,
+ // then take the slow path.
+ if (isolate->is_initial_array_prototype(array_proto) &&
+ isolate->IsArrayIteratorLookupChainIntact() &&
+ isolate->is_initial_array_iterator_prototype_map(iterator_map)) {
+ if (IsFastPackedElementsKind(array_kind)) {
+ return false;
+ }
+ if (IsFastHoleyElementsKind(array_kind) &&
+ isolate->IsFastArrayConstructorPrototypeChainIntact()) {
+ return false;
+ }
+ }
+ }
+ return true;
+}
void Object::ShortPrint(FILE* out) {
OFStream os(out);
« no previous file with comments | « src/objects.h ('k') | src/runtime/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698