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

Unified Diff: src/hydrogen.cc

Issue 232873002: Partially fix semantics of Array.push() (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Add missing test case Created 6 years, 8 months 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/builtins.cc ('k') | src/string.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/hydrogen.cc
diff --git a/src/hydrogen.cc b/src/hydrogen.cc
index 20fd43c62816211a265d7f4bcd38b69533a8242b..153c3ae5af668c75d9b9e6003196df575e166b43 100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -6781,9 +6781,12 @@ HInstruction* HGraphBuilder::BuildConstantMapCheck(Handle<JSObject> constant,
HInstruction* HGraphBuilder::BuildCheckPrototypeMaps(Handle<JSObject> prototype,
Handle<JSObject> holder) {
- while (!prototype.is_identical_to(holder)) {
+ while (holder.is_null() || !prototype.is_identical_to(holder)) {
BuildConstantMapCheck(prototype, top_info());
- prototype = handle(JSObject::cast(prototype->GetPrototype()));
+ Object* next_prototype = prototype->GetPrototype();
+ if (next_prototype->IsNull()) return NULL;
+ CHECK(next_prototype->IsJSObject());
+ prototype = handle(JSObject::cast(next_prototype));
}
HInstruction* checked_object = BuildConstantMapCheck(prototype, top_info());
@@ -7661,6 +7664,17 @@ bool HOptimizedGraphBuilder::TryInlineBuiltinMethodCall(
ElementsKind elements_kind = receiver_map->elements_kind();
if (!IsFastElementsKind(elements_kind)) return false;
+ // If there may be elements accessors in the prototype chain, the fast
+ // inlined version can't be used.
+ if (receiver_map->DictionaryElementsInPrototypeChainOnly()) return false;
+ // If there currently can be no elements accessors on the prototype chain,
+ // it doesn't mean that there won't be any later. Install a full prototype
+ // chain check to trap element accessors being installed on the prototype
+ // chain, which would cause elements to go to dictionary mode and result
+ // in a map change.
+ Handle<JSObject> prototype(JSObject::cast(receiver_map->prototype()));
+ BuildCheckPrototypeMaps(prototype, Handle<JSObject>());
+
HValue* op_vals[] = {
context(),
// Receiver.
« no previous file with comments | « src/builtins.cc ('k') | src/string.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698