mirror of
https://github.com/systemjs/systemjs.git
synced 2026-01-18 14:53:14 +00:00
add irhydra, play with resolving deoptimizations
This commit is contained in:
parent
bb62e580dd
commit
1cd38fe0b0
2
.gitignore
vendored
2
.gitignore
vendored
@ -2,3 +2,5 @@ node_modules
|
||||
.DS_Store
|
||||
dist
|
||||
bower_components
|
||||
code.asm
|
||||
hydrogen.cfg
|
||||
|
||||
16
irhydra/load.js
Normal file
16
irhydra/load.js
Normal file
@ -0,0 +1,16 @@
|
||||
var System = require('../');
|
||||
|
||||
function load () {
|
||||
var loader = new System.constructor();
|
||||
return loader.import('./test/tests/register-circular1.js');
|
||||
}
|
||||
|
||||
var i = 100;
|
||||
|
||||
function again () {
|
||||
i--;
|
||||
if (i)
|
||||
return load().then(again);
|
||||
}
|
||||
|
||||
again();
|
||||
@ -38,6 +38,7 @@
|
||||
"test": "npm run test:babel && npm run test:traceur && npm run test:typescript",
|
||||
"test:traceur": "mocha test/test-traceur.js -u tdd --reporter dot",
|
||||
"test:babel": "mocha test/test-babel.js -u tdd --reporter dot",
|
||||
"test:typescript": "mocha test/test-typescript.js -u tdd --reporter dot"
|
||||
"test:typescript": "mocha test/test-typescript.js -u tdd --reporter dot",
|
||||
"irhydra": "node --trace-hydrogen --trace-phase=Z --trace-deopt --code-comments --hydrogen-track-positions --redirect-code-traces --redirect-code-traces-to=code.asm --print-opt-code --trace_hydrogen_file=hydrogen.cfg irhydra/load.js"
|
||||
}
|
||||
}
|
||||
|
||||
@ -188,18 +188,6 @@ export function readMemberExpression (p, value) {
|
||||
return value;
|
||||
}
|
||||
|
||||
function checkMap (p) {
|
||||
var name = this.name;
|
||||
// can add ':' here if we want paths to match the behaviour of map
|
||||
if (name.substr(0, p.length) === p && (name.length === p.length || name[p.length] === '/' || p[p.length - 1] === '/' || p[p.length - 1] === ':')) {
|
||||
var curLen = p.split('/').length;
|
||||
if (curLen > this.len) {
|
||||
this.match = p;
|
||||
this.len = curLen;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function normalizePaths (config) {
|
||||
for (var p in config.paths) {
|
||||
if (!Object.hasOwnProperty.call(config.paths, p))
|
||||
@ -214,9 +202,7 @@ export function normalizePaths (config) {
|
||||
}
|
||||
|
||||
// separate out paths cache as a baseURL lock process
|
||||
export function applyPaths (config, key) {
|
||||
var paths = config.paths;
|
||||
|
||||
export function applyPaths (baseURL, paths, key) {
|
||||
var mapMatch = getMapMatch(paths, key);
|
||||
if (mapMatch) {
|
||||
var target = paths[mapMatch] + key.substr(mapMatch.length);
|
||||
@ -225,17 +211,26 @@ export function applyPaths (config, key) {
|
||||
if (resolved !== undefined)
|
||||
return resolved;
|
||||
|
||||
resolved = target;
|
||||
return baseURL + target;
|
||||
}
|
||||
else if (key.indexOf(':') !== -1) {
|
||||
return key;
|
||||
}
|
||||
else {
|
||||
resolved = key;
|
||||
return baseURL + key;
|
||||
}
|
||||
}
|
||||
|
||||
// plain paths map, or plain to begin with -> baseURL
|
||||
return config.baseURL + resolved;
|
||||
function checkMap (p) {
|
||||
var name = this.name;
|
||||
// can add ':' here if we want paths to match the behaviour of map
|
||||
if (name.substr(0, p.length) === p && (name.length === p.length || name[p.length] === '/' || p[p.length - 1] === '/' || p[p.length - 1] === ':')) {
|
||||
var curLen = p.split('/').length;
|
||||
if (curLen > this.len) {
|
||||
this.match = p;
|
||||
this.len = curLen;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function getMapMatch (map, name) {
|
||||
|
||||
@ -138,7 +138,7 @@ export function coreResolve (config, key, parentKey, doMap) {
|
||||
if (relativeResolved) {
|
||||
if (!config.pathsLocked)
|
||||
normalizePaths(config);
|
||||
return applyPaths(config, relativeResolved, true);
|
||||
return applyPaths(config.baseURL, config.paths, relativeResolved);
|
||||
}
|
||||
|
||||
// plain keys not starting with './', 'x://' and '/' go through custom resolution
|
||||
@ -162,7 +162,7 @@ export function coreResolve (config, key, parentKey, doMap) {
|
||||
|
||||
if (!config.pathsLocked)
|
||||
normalizePaths(config);
|
||||
return applyPaths(config, key, false);
|
||||
return applyPaths(config.baseURL, config.paths, key);
|
||||
}
|
||||
|
||||
function pluginResolve (config, key, parentKey, metadata, parentMetadata) {
|
||||
|
||||
@ -48,7 +48,8 @@ systemJSPrototype[RESOLVE] = function (key, parentKey) {
|
||||
.then(function (resolved) {
|
||||
// then apply paths
|
||||
// baseURL is fallback
|
||||
return applyPaths(loader[CONFIG], resolved || key);
|
||||
var config = loader[CONFIG];
|
||||
return applyPaths(config.baseURL, config.paths, resolved || key);
|
||||
});
|
||||
};
|
||||
|
||||
@ -61,7 +62,8 @@ systemJSPrototype.resolveSync = function (key, parentKey) {
|
||||
resolved = this[PLAIN_RESOLVE_SYNC](key, parentKey);
|
||||
|
||||
// then apply paths
|
||||
return applyPaths(this[CONFIG], resolved || key);
|
||||
var config = this[CONFIG];
|
||||
return applyPaths(config.baseURL, config.paths, resolved || key);
|
||||
};
|
||||
|
||||
systemJSPrototype[PLAIN_RESOLVE] = systemJSPrototype[PLAIN_RESOLVE_SYNC] = plainResolve;
|
||||
@ -92,7 +94,7 @@ systemJSPrototype.config = function (cfg) {
|
||||
// object submap
|
||||
else {
|
||||
// normalize parent with URL and paths only
|
||||
var resolvedParent = resolveIfNotPlain(p, baseURI) || applyPaths(config, p);
|
||||
var resolvedParent = resolveIfNotPlain(p, baseURI) || applyPaths(config.baseURL, config.paths, p);
|
||||
extend(config.submap[resolvedParent] || (config.submap[resolvedParent] = {}), v);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user