diff options
author | Feng Qian <fqian@google.com> | 2009-08-07 12:03:03 -0700 |
---|---|---|
committer | Feng Qian <fqian@google.com> | 2009-08-07 12:03:03 -0700 |
commit | 7bf2e49eb8b62459a5eec743bacb7cddff4ec1fa (patch) | |
tree | a07d27581960b4cee2326029c08de8b312aac09d /V8Binding/v8/src/messages.js | |
parent | 3b019d46a57ef711ce94c60fe542baa7c22c4995 (diff) | |
download | external_webkit-7bf2e49eb8b62459a5eec743bacb7cddff4ec1fa.zip external_webkit-7bf2e49eb8b62459a5eec743bacb7cddff4ec1fa.tar.gz external_webkit-7bf2e49eb8b62459a5eec743bacb7cddff4ec1fa.tar.bz2 |
Get a new V8 revision with performance improvement in ARM compiler.
http://v8.googlecode.com/svn/branches/bleeding_edge@2654
This is a clean drop without local changes.
Diffstat (limited to 'V8Binding/v8/src/messages.js')
-rw-r--r-- | V8Binding/v8/src/messages.js | 41 |
1 files changed, 25 insertions, 16 deletions
diff --git a/V8Binding/v8/src/messages.js b/V8Binding/v8/src/messages.js index 870c969..fd505ff 100644 --- a/V8Binding/v8/src/messages.js +++ b/V8Binding/v8/src/messages.js @@ -561,20 +561,24 @@ function GetStackTraceLine(recv, fun, pos, isGlobal) { var kAddMessageAccessorsMarker = { }; // Defines accessors for a property that is calculated the first time -// the property is read and then replaces the accessor with the value. -// Also, setting the property causes the accessors to be deleted. +// the property is read. function DefineOneShotAccessor(obj, name, fun) { // Note that the accessors consistently operate on 'obj', not 'this'. // Since the object may occur in someone else's prototype chain we // can't rely on 'this' being the same as 'obj'. + var hasBeenSet = false; + var value; obj.__defineGetter__(name, function () { - var value = fun(obj); - obj[name] = value; + if (hasBeenSet) { + return value; + } + hasBeenSet = true; + value = fun(obj); return value; }); obj.__defineSetter__(name, function (v) { - delete obj[name]; - obj[name] = v; + hasBeenSet = true; + value = v; }); } @@ -833,22 +837,25 @@ function DefineError(f) { } else if (!IS_UNDEFINED(m)) { this.message = ToString(m); } - var stackTraceLimit = $Error.stackTraceLimit; - if (stackTraceLimit) { - // Cap the limit to avoid extremely big traces - if (stackTraceLimit < 0 || stackTraceLimit > 10000) - stackTraceLimit = 10000; - var raw_stack = %CollectStackTrace(f, stackTraceLimit); - DefineOneShotAccessor(this, 'stack', function (obj) { - return FormatRawStackTrace(obj, raw_stack); - }); - } + captureStackTrace(this, f); } else { return new f(m); } }); } +function captureStackTrace(obj, cons_opt) { + var stackTraceLimit = $Error.stackTraceLimit; + if (!stackTraceLimit) return; + if (stackTraceLimit < 0 || stackTraceLimit > 10000) + stackTraceLimit = 10000; + var raw_stack = %CollectStackTrace(cons_opt ? cons_opt : captureStackTrace, + stackTraceLimit); + DefineOneShotAccessor(obj, 'stack', function (obj) { + return FormatRawStackTrace(obj, raw_stack); + }); +}; + $Math.__proto__ = global.Object.prototype; DefineError(function Error() { }); @@ -859,6 +866,8 @@ DefineError(function ReferenceError() { }); DefineError(function EvalError() { }); DefineError(function URIError() { }); +$Error.captureStackTrace = captureStackTrace; + // Setup extra properties of the Error.prototype object. $Error.prototype.message = ''; |