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

Unified Diff: src/ic.cc

Issue 151199: Fix crash when calling non-function globals. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 6 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 | « no previous file | test/mjsunit/call-non-function.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ic.cc
===================================================================
--- src/ic.cc (revision 2327)
+++ src/ic.cc (working copy)
@@ -460,11 +460,10 @@
if (lookup->holder() != *global) return;
JSGlobalPropertyCell* cell =
JSGlobalPropertyCell::cast(global->GetPropertyCell(lookup));
- if (cell->value()->IsJSFunction()) {
- JSFunction* function = JSFunction::cast(cell->value());
- code = StubCache::ComputeCallGlobal(argc, in_loop, *name, *global,
- cell, function);
- }
+ if (!cell->value()->IsJSFunction()) return;
+ JSFunction* function = JSFunction::cast(cell->value());
+ code = StubCache::ComputeCallGlobal(argc, in_loop, *name, *global,
+ cell, function);
} else {
// There is only one shared stub for calling normalized
// properties. It does not traverse the prototype chain, so the
@@ -489,7 +488,7 @@
// If we're unable to compute the stub (not enough memory left), we
// simply avoid updating the caches.
- if (code->IsFailure()) return;
+ if (code == NULL || code->IsFailure()) return;
// Patch the call site depending on the state of the cache.
if (state == UNINITIALIZED ||
@@ -700,7 +699,7 @@
// If we're unable to compute the stub (not enough memory left), we
// simply avoid updating the caches.
- if (code->IsFailure()) return;
+ if (code == NULL || code->IsFailure()) return;
// Patch the call site depending on the state of the cache.
if (state == UNINITIALIZED || state == PREMONOMORPHIC ||
@@ -890,7 +889,7 @@
// If we're unable to compute the stub (not enough memory left), we
// simply avoid updating the caches.
- if (code->IsFailure()) return;
+ if (code == NULL || code->IsFailure()) return;
// Patch the call site depending on the state of the cache. Make
// sure to always rewrite from monomorphic to megamorphic.
@@ -1042,7 +1041,7 @@
// If we're unable to compute the stub (not enough memory left), we
// simply avoid updating the caches.
- if (code->IsFailure()) return;
+ if (code == NULL || code->IsFailure()) return;
// Patch the call site depending on the state of the cache.
if (state == UNINITIALIZED || state == MONOMORPHIC_PROTOTYPE_FAILURE) {
@@ -1164,7 +1163,7 @@
// If we're unable to compute the stub (not enough memory left), we
// simply avoid updating the caches.
- if (code->IsFailure()) return;
+ if (code == NULL || code->IsFailure()) return;
// Patch the call site depending on the state of the cache. Make
// sure to always rewrite from monomorphic to megamorphic.
« no previous file with comments | « no previous file | test/mjsunit/call-non-function.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698