Perform HasFastProperties check on prototypes when computing call targets in Crankshaft, part 2.

The previous fix was for "real" calls, this one is for getters. It is a bit
unfortunate that this has to be fixed twice: We should really break up
Call::ComputeTarget into a predicate and 1 or 2 getters, so code can be reused.

The regression test has been modified a bit to make things more uniform.

Review URL: https://chromiumcodereview.appspot.com/10702164

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@12053 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent e26128ac
...@@ -5637,6 +5637,7 @@ static void LookupInPrototypes(Handle<Map> map, ...@@ -5637,6 +5637,7 @@ static void LookupInPrototypes(Handle<Map> map,
LookupResult* lookup) { LookupResult* lookup) {
while (map->prototype()->IsJSObject()) { while (map->prototype()->IsJSObject()) {
Handle<JSObject> holder(JSObject::cast(map->prototype())); Handle<JSObject> holder(JSObject::cast(map->prototype()));
if (!holder->HasFastProperties()) break;
map = Handle<Map>(holder->map()); map = Handle<Map>(holder->map());
map->LookupDescriptor(*holder, *name, lookup); map->LookupDescriptor(*holder, *name, lookup);
if (lookup->IsFound()) return; if (lookup->IsFound()) return;
......
...@@ -27,26 +27,42 @@ ...@@ -27,26 +27,42 @@
// Flags: --allow-natives-syntax // Flags: --allow-natives-syntax
var A = { function ToDictionaryMode(x) {
foo: function() { assertUnreachable(); } %OptimizeObjectForAddingMultipleProperties(x, 100);
} }
var B = { var A, B, C;
b: 2,
foo: function() { return 1; }
}
B.__proto__ = A;
var C = {}; // The initial bug report was about calling a know function...
C.__proto__ = B; A = {};
Object.defineProperty(A, "foo", { value: function() { assertUnreachable(); }});
function bar(x) { B = Object.create(A);
return x.foo(); Object.defineProperty(B, "foo", { value: function() { return 111; }});
}
for (var i = 0; i < 3; i++) { C = Object.create(B);
assertEquals(1, bar(C));
} function bar(x) { return x.foo(); }
%OptimizeObjectForAddingMultipleProperties(B, 100); // Force dictionary mode.
assertEquals(111, bar(C));
assertEquals(111, bar(C));
ToDictionaryMode(B);
%OptimizeFunctionOnNextCall(bar); %OptimizeFunctionOnNextCall(bar);
assertEquals(1, bar(C)); assertEquals(111, bar(C));
// Although this was not in the initial bug report: The same for getters...
A = {};
Object.defineProperty(A, "baz", { get: function() { assertUnreachable(); }});
B = Object.create(A);
Object.defineProperty(B, "baz", { get: function() { return 111; }});
C = Object.create(B);
function boo(x) { return x.baz; }
assertEquals(111, boo(C));
assertEquals(111, boo(C));
ToDictionaryMode(B);
%OptimizeFunctionOnNextCall(boo);
assertEquals(111, boo(C));
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment