OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Used for encoding f32 and double constants to bits. | 5 // Used for encoding f32 and double constants to bits. |
6 let __buffer = new ArrayBuffer(8); | 6 let __buffer = new ArrayBuffer(8); |
7 let byte_view = new Int8Array(__buffer); | 7 let byte_view = new Int8Array(__buffer); |
8 let f32_view = new Float32Array(__buffer); | 8 let f32_view = new Float32Array(__buffer); |
9 let f64_view = new Float64Array(__buffer); | 9 let f64_view = new Float64Array(__buffer); |
10 | 10 |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 section.emit_u8(global.mutable); | 352 section.emit_u8(global.mutable); |
353 if ((typeof global.init_index) == "undefined") { | 353 if ((typeof global.init_index) == "undefined") { |
354 // Emit a constant initializer. | 354 // Emit a constant initializer. |
355 switch (global.type) { | 355 switch (global.type) { |
356 case kWasmI32: | 356 case kWasmI32: |
357 section.emit_u8(kExprI32Const); | 357 section.emit_u8(kExprI32Const); |
358 section.emit_u32v(global.init); | 358 section.emit_u32v(global.init); |
359 break; | 359 break; |
360 case kWasmI64: | 360 case kWasmI64: |
361 section.emit_u8(kExprI64Const); | 361 section.emit_u8(kExprI64Const); |
362 section.emit_u8(global.init); | 362 section.emit_u32v(global.init); |
363 break; | 363 break; |
364 case kWasmF32: | 364 case kWasmF32: |
365 section.emit_u8(kExprF32Const); | 365 section.emit_u8(kExprF32Const); |
366 f32_view[0] = global.init; | 366 f32_view[0] = global.init; |
367 section.emit_u8(byte_view[0]); | 367 section.emit_u8(byte_view[0]); |
368 section.emit_u8(byte_view[1]); | 368 section.emit_u8(byte_view[1]); |
369 section.emit_u8(byte_view[2]); | 369 section.emit_u8(byte_view[2]); |
370 section.emit_u8(byte_view[3]); | 370 section.emit_u8(byte_view[3]); |
371 break; | 371 break; |
372 case kWasmF64: | 372 case kWasmF64: |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
546 } | 546 } |
547 return buffer; | 547 return buffer; |
548 } | 548 } |
549 | 549 |
550 instantiate(ffi) { | 550 instantiate(ffi) { |
551 let module = new WebAssembly.Module(this.toBuffer()); | 551 let module = new WebAssembly.Module(this.toBuffer()); |
552 let instance = new WebAssembly.Instance(module, ffi); | 552 let instance = new WebAssembly.Instance(module, ffi); |
553 return instance; | 553 return instance; |
554 } | 554 } |
555 } | 555 } |
OLD | NEW |