9e7e66602f
Previously, the string set up by the embedder was eagerly passed to Uri.parse during Isolate startup. This is expensive both in time and memory footprint. This CL causes Uri.parse() to be called only when needed. This change will allow reducing the memory footprint of Fuchsia's Dart content handler on hello world by ~1MB. fixes #25603 R=asiva@google.com Review-Url: https://codereview.chromium.org/2988613002 .
95 lines
2.8 KiB
Dart
95 lines
2.8 KiB
Dart
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
import 'dart:core' hide Symbol;
|
|
import 'dart:typed_data' show Int32List;
|
|
|
|
@patch
|
|
List makeListFixedLength(List growableList)
|
|
native "Internal_makeListFixedLength";
|
|
|
|
@patch
|
|
List makeFixedListUnmodifiable(List fixedLengthList)
|
|
native "Internal_makeFixedListUnmodifiable";
|
|
|
|
class VMLibraryHooks {
|
|
// Example: "dart:isolate _Timer._factory"
|
|
static var timerFactory;
|
|
|
|
// Example: "dart:io _EventHandler._sendData"
|
|
static var eventHandlerSendData;
|
|
|
|
// A nullary closure that answers the current clock value in milliseconds.
|
|
// Example: "dart:io _EventHandler._timerMillisecondClock"
|
|
static var timerMillisecondClock;
|
|
|
|
// Implementation of Resource.readAsBytes.
|
|
static var resourceReadAsBytes;
|
|
|
|
// Implementation of package root/map provision.
|
|
static var packageRootString;
|
|
static var packageConfigString;
|
|
static var packageRootUriFuture;
|
|
static var packageConfigUriFuture;
|
|
static var resolvePackageUriFuture;
|
|
|
|
static var _computeScriptUri;
|
|
static var _cachedScript;
|
|
static set platformScript(var f) {
|
|
_computeScriptUri = f;
|
|
_cachedScript = null;
|
|
}
|
|
|
|
static get platformScript {
|
|
if (_cachedScript == null && _computeScriptUri != null) {
|
|
_cachedScript = _computeScriptUri();
|
|
}
|
|
return _cachedScript;
|
|
}
|
|
}
|
|
|
|
final bool is64Bit = _inquireIs64Bit();
|
|
|
|
bool _inquireIs64Bit() native "Internal_inquireIs64Bit";
|
|
|
|
bool _classRangeCheck(int cid, int lowerLimit, int upperLimit) {
|
|
return cid >= lowerLimit && cid <= upperLimit;
|
|
}
|
|
|
|
bool _classRangeCheckNegative(int cid, int lowerLimit, int upperLimit) {
|
|
return cid < lowerLimit || cid > upperLimit;
|
|
}
|
|
|
|
// Utility class now only used by the VM.
|
|
class Lists {
|
|
static void copy(List src, int srcStart, List dst, int dstStart, int count) {
|
|
if (srcStart < dstStart) {
|
|
for (int i = srcStart + count - 1, j = dstStart + count - 1;
|
|
i >= srcStart;
|
|
i--, j--) {
|
|
dst[j] = src[i];
|
|
}
|
|
} else {
|
|
for (int i = srcStart, j = dstStart; i < srcStart + count; i++, j++) {
|
|
dst[j] = src[i];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Prepend the parent type arguments (maybe null) to the function type
|
|
// arguments (may be null). The result is null if both input vectors are null
|
|
// or is a newly allocated and canonicalized vector of length 'len'.
|
|
_prependTypeArguments(functionTypeArguments, parentTypeArguments, len)
|
|
native "Internal_prependTypeArguments";
|
|
|
|
// Called by IRRegExpMacroAssembler::GrowStack.
|
|
Int32List _growRegExpStack(Int32List stack) {
|
|
final newStack = new Int32List(stack.length * 2);
|
|
for (int i = 0; i < stack.length; i++) {
|
|
newStack[i] = stack[i];
|
|
}
|
|
return newStack;
|
|
}
|