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

Side by Side Diff: src/debug/mirrors.js

Issue 1293493004: Unify symbols sharing across native scripts and runtime. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase Created 5 years, 4 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 unified diff | Download patch
« no previous file with comments | « src/contexts.h ('k') | src/heap/heap.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2012 the V8 project authors. All rights reserved. 1 // Copyright 2006-2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 (function(global, utils) { 5 (function(global, utils) {
6 "use strict"; 6 "use strict";
7 7
8 // ---------------------------------------------------------------------------- 8 // ----------------------------------------------------------------------------
9 // Imports 9 // Imports
10 10
11 var FunctionSourceString; 11 var FunctionSourceString;
12 var GlobalArray = global.Array; 12 var GlobalArray = global.Array;
13 var IsNaN = global.isNaN; 13 var IsNaN = global.isNaN;
14 var JSONStringify = global.JSON.stringify; 14 var JSONStringify = global.JSON.stringify;
15 var MathMin = global.Math.min; 15 var MathMin = global.Math.min;
16 var promiseStatusSymbol = utils.GetPrivateSymbol("promise_status_symbol");
17 var promiseValueSymbol = utils.GetPrivateSymbol("promise_value_symbol");
16 var ToBoolean; 18 var ToBoolean;
17 var ToString; 19 var ToString;
18 20
19 utils.Import(function(from) { 21 utils.Import(function(from) {
20 FunctionSourceString = from.FunctionSourceString; 22 FunctionSourceString = from.FunctionSourceString;
21 ToBoolean = from.ToBoolean; 23 ToBoolean = from.ToBoolean;
22 ToString = from.ToString; 24 ToString = from.ToString;
23 }); 25 });
24 26
25 // ---------------------------------------------------------------------------- 27 // ----------------------------------------------------------------------------
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 mirror_cache_ = []; 104 mirror_cache_ = [];
103 } 105 }
104 106
105 107
106 // Wrapper to check whether an object is a Promise. The call may not work 108 // Wrapper to check whether an object is a Promise. The call may not work
107 // if promises are not enabled. 109 // if promises are not enabled.
108 // TODO(yangguo): remove try-catch once promises are enabled by default. 110 // TODO(yangguo): remove try-catch once promises are enabled by default.
109 function ObjectIsPromise(value) { 111 function ObjectIsPromise(value) {
110 try { 112 try {
111 return IS_SPEC_OBJECT(value) && 113 return IS_SPEC_OBJECT(value) &&
112 !IS_UNDEFINED(%DebugGetProperty(value, builtins.$promiseStatus)); 114 !IS_UNDEFINED(%DebugGetProperty(value, promiseStatusSymbol));
113 } catch (e) { 115 } catch (e) {
114 return false; 116 return false;
115 } 117 }
116 } 118 }
117 119
118 120
119 /** 121 /**
120 * Returns the mirror for a specified value or object. 122 * Returns the mirror for a specified value or object.
121 * 123 *
122 * @param {value or Object} value the value or object to retreive the mirror for 124 * @param {value or Object} value the value or object to retreive the mirror for
(...skipping 1196 matching lines...) Expand 10 before | Expand all | Expand 10 after
1319 * @constructor 1321 * @constructor
1320 * @extends ObjectMirror 1322 * @extends ObjectMirror
1321 */ 1323 */
1322 function PromiseMirror(value) { 1324 function PromiseMirror(value) {
1323 %_CallFunction(this, value, MirrorType.PROMISE_TYPE, ObjectMirror); 1325 %_CallFunction(this, value, MirrorType.PROMISE_TYPE, ObjectMirror);
1324 } 1326 }
1325 inherits(PromiseMirror, ObjectMirror); 1327 inherits(PromiseMirror, ObjectMirror);
1326 1328
1327 1329
1328 function PromiseGetStatus_(value) { 1330 function PromiseGetStatus_(value) {
1329 var status = %DebugGetProperty(value, builtins.$promiseStatus); 1331 var status = %DebugGetProperty(value, promiseStatusSymbol);
1330 if (status == 0) return "pending"; 1332 if (status == 0) return "pending";
1331 if (status == 1) return "resolved"; 1333 if (status == 1) return "resolved";
1332 return "rejected"; 1334 return "rejected";
1333 } 1335 }
1334 1336
1335 1337
1336 function PromiseGetValue_(value) { 1338 function PromiseGetValue_(value) {
1337 return %DebugGetProperty(value, builtins.$promiseValue); 1339 return %DebugGetProperty(value, promiseValueSymbol);
1338 } 1340 }
1339 1341
1340 1342
1341 PromiseMirror.prototype.status = function() { 1343 PromiseMirror.prototype.status = function() {
1342 return PromiseGetStatus_(this.value_); 1344 return PromiseGetStatus_(this.value_);
1343 }; 1345 };
1344 1346
1345 1347
1346 PromiseMirror.prototype.promiseValue = function() { 1348 PromiseMirror.prototype.promiseValue = function() {
1347 return MakeMirror(PromiseGetValue_(this.value_)); 1349 return MakeMirror(PromiseGetValue_(this.value_));
(...skipping 1759 matching lines...) Expand 10 before | Expand all | Expand 10 after
3107 // Functions needed by the debugger runtime. 3109 // Functions needed by the debugger runtime.
3108 utils.InstallFunctions(utils, DONT_ENUM, [ 3110 utils.InstallFunctions(utils, DONT_ENUM, [
3109 "ClearMirrorCache", ClearMirrorCache 3111 "ClearMirrorCache", ClearMirrorCache
3110 ]); 3112 ]);
3111 3113
3112 // Export to debug.js 3114 // Export to debug.js
3113 utils.Export(function(to) { 3115 utils.Export(function(to) {
3114 to.MirrorType = MirrorType; 3116 to.MirrorType = MirrorType;
3115 }); 3117 });
3116 }) 3118 })
OLDNEW
« no previous file with comments | « src/contexts.h ('k') | src/heap/heap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698