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

Unified Diff: dart/sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart

Issue 23452029: Address comments from CL 23304012. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: emitConvertToFastObjectFunction Created 7 years, 3 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 | dart/sdk/lib/_internal/compiler/implementation/js_backend/emitter_no_eval.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart
diff --git a/dart/sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart b/dart/sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart
index c93307282b5a5ec17d010fe493d9dab0fd1f90bd..e1873d3284ea482dfb0ef7e0ce9beabf57439ffb 100644
--- a/dart/sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart
+++ b/dart/sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart
@@ -4,6 +4,7 @@
part of js_backend;
+/// Enables debugging of fast/slow objects using V8-specific primitives.
const DEBUG_FAST_OBJECTS = false;
/**
@@ -703,7 +704,8 @@ class CodeEmitterTask extends CompilerTask {
optional(
DEBUG_FAST_OBJECTS,
- js(r'print("Number of classes: " + Object.getOwnPropertyNames($$).length)')),
+ js(r'print("Number of classes: "'
+ ' + Object.getOwnPropertyNames($$).length)')),
js.forIn('cls', 'collectedClasses', [
js.if_('hasOwnProperty.call(collectedClasses, cls)', [
@@ -3730,9 +3732,9 @@ class CodeEmitterTask extends CompilerTask {
buffer.write('];$n');
}
- void emitInstancify() {
+ void emitConvertToFastObjectFunction() {
mainBuffer.add(r'''
-function instancify(properties) {
+function convertToFastObject(properties) {
function makeConstructor() {
var str = "{\n";
var hasOwnProperty = Object.prototype.hasOwnProperty;
@@ -3766,6 +3768,11 @@ function instancify(properties) {
}
for (String globalObject in Namer.reservedGlobalObjectNames) {
+ // The global objects start as so-called "slow objects". For V8, this
+ // means that it won't try to make map transitions as we add properties
+ // to these objects. Later on, we attempt to turn these objects into
+ // fast objects by calling "convertToFastObject" (see
+ // [emitConvertToFastObjectFunction]).
mainBuffer
..write('var ${globalObject}$_=$_{}$N')
..write('delete ${globalObject}.x$N');
@@ -3994,9 +4001,9 @@ function instancify(properties) {
mainBuffer.add(
'${namer.CURRENT_ISOLATE}$_=${_}new ${namer.isolateName}()$N');
- emitInstancify();
+ emitConvertToFastObjectFunction();
for (String globalObject in Namer.reservedGlobalObjectNames) {
- mainBuffer.add('$globalObject = instancify($globalObject)$N');
+ mainBuffer.add('$globalObject = convertToFastObject($globalObject)$N');
}
if (DEBUG_FAST_OBJECTS) {
ClassElement primitives =
@@ -4007,6 +4014,7 @@ function instancify(properties) {
String printHelperName = namer.isolateAccess(printHelper);
mainBuffer.add('''
+// The following only works on V8 when run with option "--allow-natives-syntax".
if (typeof $printHelperName === "function") {
$printHelperName("Size of global helper object: "
+ String(Object.getOwnPropertyNames(H).length)
« no previous file with comments | « no previous file | dart/sdk/lib/_internal/compiler/implementation/js_backend/emitter_no_eval.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698