Revision: 6727
Author: [email protected]
Date: Thu Feb 10 04:33:51 2011
Log: Check holder before optimizing calls to global functions.
In the case where the function is not found in the global object,
we have to generate a generic call.
BUG=v8:1106
TEST=mjsunit/regress/regress-1106.js
Review URL: http://codereview.chromium.org/6483010
http://code.google.com/p/v8/source/detail?r=6727
Modified:
/branches/bleeding_edge/src/ast.cc
/branches/bleeding_edge/test/mjsunit/regress/regress-1106.js
=======================================
--- /branches/bleeding_edge/src/ast.cc Wed Feb 2 06:02:58 2011
+++ /branches/bleeding_edge/src/ast.cc Thu Feb 10 04:33:51 2011
@@ -618,7 +618,9 @@
cell_ = Handle<JSGlobalPropertyCell>::null();
LookupResult lookup;
global->Lookup(*name, &lookup);
- if (lookup.IsProperty() && lookup.type() == NORMAL) {
+ if (lookup.IsProperty() &&
+ lookup.type() == NORMAL &&
+ lookup.holder() == *global) {
cell_ = Handle<JSGlobalPropertyCell>(global->GetPropertyCell(&lookup));
if (cell_->value()->IsJSFunction()) {
Handle<JSFunction> candidate(JSFunction::cast(cell_->value()));
=======================================
--- /branches/bleeding_edge/test/mjsunit/regress/regress-1106.js Wed Feb 9
07:50:39 2011
+++ /branches/bleeding_edge/test/mjsunit/regress/regress-1106.js Thu Feb 10
04:33:51 2011
@@ -40,3 +40,11 @@
for (i=0 ; i < 100000; ++i) {
assertEquals(5, f());
}
+
+// Test calls on functions defined in the prototype of the global object.
+x.gee = function() { return 42; }
+function g() { return gee(); }
+
+for (i=0 ; i < 100000; ++i) {
+ assertEquals(42, g());
+}
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev