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

Unified Diff: src/mirror-debugger.js

Issue 283373003: Use %DebugGetProperty in debug mirror to check for Promise. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 7 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 | src/promise.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/mirror-debugger.js
diff --git a/src/mirror-debugger.js b/src/mirror-debugger.js
index b140343f4858086237783e96755c955d1daecfc5..124347b7bd5b72cd7a977750b91a2d608aa951e2 100644
--- a/src/mirror-debugger.js
+++ b/src/mirror-debugger.js
@@ -21,10 +21,11 @@ function ClearMirrorCache() {
// Wrapper to check whether an object is a Promise. The call may not work
// if promises are not enabled.
-// TODO(yangguo): remove this wrapper once promises are enabled by default.
+// TODO(yangguo): remove try-catch once promises are enabled by default.
function ObjectIsPromise(value) {
try {
- return %IsPromise(value);
+ return IS_SPEC_OBJECT(value) &&
+ !IS_UNDEFINED(%DebugGetProperty(value, builtins.promiseStatus));
} catch (e) {
return false;
}
@@ -824,13 +825,12 @@ ObjectMirror.GetInternalProperties = function(value) {
}
return result;
} else if (ObjectIsPromise(value)) {
- var mirror = new PromiseMirror(value);
- var result = [];
- result.push(new InternalPropertyMirror("[[PromiseStatus]]",
- mirror.status()));
- result.push(new InternalPropertyMirror("[[PromiseValue]]",
- mirror.promiseValue()));
- return result;
+ var result = [];
+ result.push(new InternalPropertyMirror("[[PromiseStatus]]",
+ PromiseGetStatus_(value)));
+ result.push(new InternalPropertyMirror("[[PromiseValue]]",
+ PromiseGetValue_(value)));
+ return result;
}
return [];
}
@@ -1194,16 +1194,26 @@ function PromiseMirror(value) {
inherits(PromiseMirror, ObjectMirror);
-PromiseMirror.prototype.status = function() {
- var status = builtins.GetPromiseStatus(this.value_);
+function PromiseGetStatus_(value) {
+ var status = %DebugGetProperty(value, builtins.promiseStatus);
if (status == 0) return "pending";
if (status == 1) return "resolved";
return "rejected";
+}
+
+
+function PromiseGetValue_(value) {
+ return %DebugGetProperty(value, builtins.promiseValue);
+}
+
+
+PromiseMirror.prototype.status = function() {
+ return PromiseGetStatus_(this.value_);
};
PromiseMirror.prototype.promiseValue = function() {
- return builtins.GetPromiseValue(this.value_);
+ return MakeMirror(PromiseGetValue_(this.value_));
};
@@ -2524,7 +2534,7 @@ JSONProtocolSerializer.prototype.serializeObject_ = function(mirror, content,
if (mirror.isPromise()) {
// Add promise specific properties.
content.status = mirror.status();
- content.promiseValue = mirror.promiseValue();
+ content.promiseValue = this.serializeReference(mirror.promiseValue());
}
// Add actual properties - named properties followed by indexed properties.
« no previous file with comments | « no previous file | src/promise.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698