deps: V8: cherry-pick 91f0cd0 · nodejs/node@bf572c7 (original) (raw)
`@@ -3,7 +3,9 @@
`
3
3
`// found in the LICENSE file.
`
4
4
``
5
5
`#include "src/wasm/module-instantiate.h"
`
``
6
+
6
7
`#include "src/asmjs/asm-js.h"
`
``
8
`+
#include "src/conversions-inl.h"
`
7
9
`#include "src/heap/heap-inl.h" // For CodeSpaceMemoryModificationScope.
`
8
10
`#include "src/property-descriptor.h"
`
9
11
`#include "src/utils.h"
`
`@@ -132,6 +134,7 @@ class InstanceBuilder {
`
132
134
`void LoadDataSegments(Handle instance);
`
133
135
``
134
136
`void WriteGlobalValue(const WasmGlobal& global, double value);
`
``
137
`+
void WriteGlobalValue(const WasmGlobal& global, int64_t num);
`
135
138
`void WriteGlobalValue(const WasmGlobal& global,
`
136
139
`Handle value);
`
137
140
``
`@@ -653,25 +656,34 @@ void InstanceBuilder::WriteGlobalValue(const WasmGlobal& global, double num) {
`
653
656
`switch (global.type) {
`
654
657
`case kWasmI32:
`
655
658
` WriteLittleEndianValue(GetRawGlobalPtr(global),
`
656
``
`-
static_cast(num));
`
``
659
`+
DoubleToInt32(num));
`
657
660
`break;
`
658
661
`case kWasmI64:
`
659
``
`-
WriteLittleEndianValue(GetRawGlobalPtr(global),
`
660
``
`-
static_cast(num));
`
``
662
`+
// The Wasm-BigInt proposal currently says that i64 globals may
`
``
663
`+
// only be initialized with BigInts. See:
`
``
664
`+
// https://github.com/WebAssembly/JS-BigInt-integration/issues/12
`
``
665
`+
UNREACHABLE();
`
661
666
`break;
`
662
667
`case kWasmF32:
`
663
668
` WriteLittleEndianValue(GetRawGlobalPtr(global),
`
664
``
`-
static_cast(num));
`
``
669
`+
DoubleToFloat32(num));
`
665
670
`break;
`
666
671
`case kWasmF64:
`
667
``
`-
WriteLittleEndianValue(GetRawGlobalPtr(global),
`
668
``
`-
static_cast(num));
`
``
672
`+
WriteLittleEndianValue(GetRawGlobalPtr(global), num);
`
669
673
`break;
`
670
674
`default:
`
671
675
`UNREACHABLE();
`
672
676
` }
`
673
677
`}
`
674
678
``
``
679
`+
void InstanceBuilder::WriteGlobalValue(const WasmGlobal& global, int64_t num) {
`
``
680
`+
TRACE("init [globals_start=%p + %u] = %" PRId64 ", type = %s\n",
`
``
681
`+
reinterpret_cast<void*>(raw_buffer_ptr(untagged_globals_, 0)),
`
``
682
`+
global.offset, num, ValueTypes::TypeName(global.type));
`
``
683
`+
DCHECK_EQ(kWasmI64, global.type);
`
``
684
`+
WriteLittleEndianValue(GetRawGlobalPtr(global), num);
`
``
685
`+
}
`
``
686
+
675
687
`void InstanceBuilder::WriteGlobalValue(const WasmGlobal& global,
`
676
688
`Handle value) {
`
677
689
`TRACE("init [globals_start=%p + %u] = ",
`
`@@ -1051,7 +1063,7 @@ bool InstanceBuilder::ProcessImportedGlobal(Handle instance,
`
1051
1063
`return true;
`
1052
1064
` }
`
1053
1065
``
1054
``
`-
if (value->IsNumber()) {
`
``
1066
`+
if (value->IsNumber() && global.type != kWasmI64) {
`
1055
1067
`WriteGlobalValue(global, value->Number());
`
1056
1068
`return true;
`
1057
1069
` }
`