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

Side by Side Diff: lib/runtime/_rtti.js

Issue 1291623005: Skip type checks on native JavaScriptObjects (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Skip type checks on JSOs 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 | « lib/runtime/_operations.js ('k') | lib/runtime/_types.js » ('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 (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /* This library defines the association between runtime objects and 5 /* This library defines the association between runtime objects and
6 * runtime types. 6 * runtime types.
7 */ 7 */
8 8
9 dart_library.library('dart_runtime/_rtti', null, /* Imports */[ 9 dart_library.library('dart_runtime/_rtti', null, /* Imports */[
10 ], /* Lazy Imports */[ 10 ], /* Lazy Imports */[
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 */ 130 */
131 function realRuntimeType(obj) { 131 function realRuntimeType(obj) {
132 let result = checkPrimitiveType(obj); 132 let result = checkPrimitiveType(obj);
133 if (result !== null) return result; 133 if (result !== null) return result;
134 // TODO(vsm): Should we treat Dart and JS objects differently here? 134 // TODO(vsm): Should we treat Dart and JS objects differently here?
135 // E.g., we can check if obj instanceof core.Object to differentiate. 135 // E.g., we can check if obj instanceof core.Object to differentiate.
136 result = obj[_runtimeType]; 136 result = obj[_runtimeType];
137 if (result) return result; 137 if (result) return result;
138 result = obj.constructor; 138 result = obj.constructor;
139 if (result == Function) { 139 if (result == Function) {
140 return getFunctionType(obj); 140 // An undecorated Function should have come from
141 // JavaScript. Treat as untyped.
142 return types.jsobject;
141 } 143 }
142 return result; 144 return result;
143 } 145 }
144 exports.realRuntimeType = realRuntimeType; 146 exports.realRuntimeType = realRuntimeType;
145 147
146 function LazyTagged(infoFn) { 148 function LazyTagged(infoFn) {
147 class _Tagged { 149 class _Tagged {
148 get [_runtimeType]() {return infoFn();} 150 get [_runtimeType]() {return infoFn();}
149 } 151 }
150 return _Tagged; 152 return _Tagged;
(...skipping 20 matching lines...) Expand all
171 function getter() { 173 function getter() {
172 if (compute == null) return cache; 174 if (compute == null) return cache;
173 cache = compute(); 175 cache = compute();
174 compute = null; 176 compute = null;
175 return cache; 177 return cache;
176 } 178 }
177 tagComputed(value, getter); 179 tagComputed(value, getter);
178 } 180 }
179 exports.tagMemoized = tagMemoized; 181 exports.tagMemoized = tagMemoized;
180 }); 182 });
OLDNEW
« no previous file with comments | « lib/runtime/_operations.js ('k') | lib/runtime/_types.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698