~ubuntu-branches/ubuntu/vivid/emscripten/vivid-proposed

« back to all changes in this revision

Viewing changes to src/compiler.js

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2014-01-19 14:12:40 UTC
  • mfrom: (4.1.2 sid)
  • Revision ID: package-import@ubuntu.com-20140119141240-nfiw0p8033oitpfz
Tags: 1.9.0~20140119~7dc8c2f-1
* New snapshot release (Closes: #733714)
* Provide sources for javascript and flash. Done in orig-tar.sh
  Available in third_party/websockify/include/web-socket-js/src/
  (Closes: #735903)

Show diffs side-by-side

added added

removed removed

Lines of Context:
121
121
// *** Environment setup code ***
122
122
 
123
123
 
 
124
DEBUG_MEMORY = false;
 
125
 
124
126
// Basic utilities
125
127
 
126
128
load('utility.js');
132
134
var settings_file = arguments_[0];
133
135
var ll_file = arguments_[1];
134
136
phase = arguments_[2];
135
 
if (phase == 'pre') {
 
137
if (phase == 'pre' || phase == 'glue') {
136
138
  additionalLibraries = Array.prototype.slice.call(arguments_, 3);
137
139
} else {
138
140
  var forwardedDataFile = arguments_[3];
183
185
assert(!(USE_TYPED_ARRAYS === 2 && QUANTUM_SIZE !== 4), 'For USE_TYPED_ARRAYS == 2, must have normal QUANTUM_SIZE of 4');
184
186
if (ASM_JS) {
185
187
  assert(!ALLOW_MEMORY_GROWTH, 'Cannot grow asm.js heap');
186
 
  assert((TOTAL_MEMORY&(TOTAL_MEMORY-1)) == 0, 'asm.js heap must be power of 2');
187
188
}
188
189
assert(!(!NAMED_GLOBALS && BUILD_AS_SHARED_LIB), 'shared libraries must have named globals');
189
190
 
204
205
 
205
206
if (VERBOSE) printErr('VERBOSE is on, this generates a lot of output and can slow down compilation');
206
207
 
 
208
// Load struct and define information.
 
209
//try {
 
210
  var temp = JSON.parse(read(STRUCT_INFO));
 
211
//} catch(e) {
 
212
//  printErr('cannot load struct info at ' + STRUCT_INFO + ' : ' + e + ', trying in current dir');
 
213
//  temp = JSON.parse(read('struct_info.compiled.json'));
 
214
//}
 
215
C_STRUCTS = temp.structs;
 
216
C_DEFINES = temp.defines;
 
217
 
207
218
// Load compiler code
208
219
 
209
 
load('framework.js');
210
220
load('modules.js');
211
221
load('parseTools.js');
212
222
load('intertyper.js');
213
223
load('analyzer.js');
214
224
load('jsifier.js');
215
 
if (RELOOP) {
216
 
  load(RELOOPER);
 
225
if (phase == 'funcs' && RELOOP) { // XXX handle !singlePhase
 
226
  RelooperModule = { TOTAL_MEMORY: ceilPowerOfTwo(2*RELOOPER_BUFFER_SIZE) };
 
227
  //try {
 
228
    load(RELOOPER);
 
229
  //} catch(e) {
 
230
  //  printErr('cannot load relooper at ' + RELOOPER + ' : ' + e + ', trying in current dir');
 
231
  //  load('relooper.js');
 
232
  //}
217
233
  assert(typeof Relooper != 'undefined');
218
234
}
219
235
globalEval(processMacros(preprocess(read('runtime.js'))));
251
267
  function runPhase(currPhase) {
252
268
    //printErr('// JS compiler in action, phase ' + currPhase + typeof lines + (lines === null));
253
269
    phase = currPhase;
254
 
    if (phase != 'pre') {
 
270
    if (phase != 'pre' && phase != 'glue') {
255
271
      if (singlePhase) PassManager.load(read(forwardedDataFile));
256
272
 
257
273
      if (phase == 'funcs') {
267
283
    intertyped = null;
268
284
    JSify(analyzed);
269
285
 
 
286
    //dumpInterProf();
 
287
    //printErr(phase + ' paths (fast, slow): ' + [fastPaths, slowPaths]);
 
288
    B.print(phase);
 
289
 
270
290
    phase = null;
271
291
 
272
292
    if (DEBUG_MEMORY) {
289
309
  }
290
310
}
291
311
 
292
 
if (ll_file) {
293
 
  if (ll_file.indexOf(String.fromCharCode(10)) == -1) {
294
 
    compile(read(ll_file));
295
 
  } else {
296
 
    compile(ll_file); // we are given raw .ll
 
312
B = new Benchmarker();
 
313
 
 
314
try {
 
315
  if (ll_file) {
 
316
    if (phase === 'glue') {
 
317
      compile(';');
 
318
    } else if (ll_file.indexOf(String.fromCharCode(10)) == -1) {
 
319
      compile(read(ll_file));
 
320
    } else {
 
321
      compile(ll_file); // we are given raw .ll
 
322
    }
297
323
  }
 
324
} catch(err) {
 
325
  printErr('aborting from js compiler due to exception: ' + err + ' | ' + err.stack);
298
326
}
299
327
 
 
328
//var M = keys(tokenCacheMisses).map(function(m) { return [m, misses[m]] }).sort(function(a, b) { return a[1] - b[1] });
 
329
//printErr(dump(M.slice(M.length-10)));
 
330
//printErr('hits: ' + hits);
 
331