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

Unified Diff: src/apinatives.js

Issue 18096: Experimental: merge from bleeding_edge. Merge up to and including... (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/toiger/
Patch Set: Created 11 years, 11 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/api.cc ('k') | src/assembler.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/apinatives.js
===================================================================
--- src/apinatives.js (revision 1085)
+++ src/apinatives.js (working copy)
@@ -59,23 +59,33 @@
function InstantiateFunction(data, name) {
+ // We need a reference to kApiFunctionCache in the stack frame
+ // if we need to bail out from a stack overflow.
+ var cache = kApiFunctionCache;
var serialNumber = %GetTemplateField(data, kApiSerialNumberOffset);
- if (!(serialNumber in kApiFunctionCache)) {
- kApiFunctionCache[serialNumber] = null;
- var fun = %CreateApiFunction(data);
- if (name) %FunctionSetName(fun, name);
- kApiFunctionCache[serialNumber] = fun;
- var prototype = %GetTemplateField(data, kApiPrototypeTemplateOffset);
- fun.prototype = prototype ? Instantiate(prototype) : {};
- %SetProperty(fun.prototype, "constructor", fun, DONT_ENUM);
- var parent = %GetTemplateField(data, kApiParentTemplateOffset);
- if (parent) {
- var parent_fun = Instantiate(parent);
- fun.prototype.__proto__ = parent_fun.prototype;
+ var isFunctionCached =
+ (serialNumber in cache) && (cache[serialNumber] != kUninitialized);
+ if (!isFunctionCached) {
+ try {
+ cache[serialNumber] = null;
+ var fun = %CreateApiFunction(data);
+ if (name) %FunctionSetName(fun, name);
+ cache[serialNumber] = fun;
+ var prototype = %GetTemplateField(data, kApiPrototypeTemplateOffset);
+ fun.prototype = prototype ? Instantiate(prototype) : {};
+ %SetProperty(fun.prototype, "constructor", fun, DONT_ENUM);
+ var parent = %GetTemplateField(data, kApiParentTemplateOffset);
+ if (parent) {
+ var parent_fun = Instantiate(parent);
+ fun.prototype.__proto__ = parent_fun.prototype;
+ }
+ ConfigureTemplateInstance(fun, data);
+ } catch (e) {
+ cache[serialNumber] = kUninitialized;
+ throw e;
}
- ConfigureTemplateInstance(fun, data);
}
- return kApiFunctionCache[serialNumber];
+ return cache[serialNumber];
}
« no previous file with comments | « src/api.cc ('k') | src/assembler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698