| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent d60d4c1 commit 1ac639a
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -36,7 +36,7 @@ | |||
| 36 | 36 | ||
| 37 | 37 | # Reset this number to 0 on major V8 upgrades. | |
| 38 | 38 | # Increment by one for each non-official patch applied to deps/v8. | |
| 39 | - 'v8_embedder_string': '-node.25', | ||
| 39 | + 'v8_embedder_string': '-node.26', | ||
| 40 | 40 | ||
| 41 | 41 | ##### V8 defaults for Node.js ##### | |
| 42 | 42 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4916,6 +4916,18 @@ void CodeGenerator::IncrementStackAccessCounter( | |||
| 4916 | 4916 | } | |
| 4917 | 4917 | } | |
| 4918 | 4918 | ||
| 4919 | + namespace { | ||
| 4920 | + | ||
| 4921 | + bool Is32BitOperand(InstructionOperand* operand) { | ||
| 4922 | + DCHECK(operand->IsStackSlot() || operand->IsRegister()); | ||
| 4923 | + MachineRepresentation mr = LocationOperand::cast(operand)->representation(); | ||
| 4924 | + return mr == MachineRepresentation::kWord32 || | ||
| 4925 | + mr == MachineRepresentation::kCompressed || | ||
| 4926 | + mr == MachineRepresentation::kCompressedPointer; | ||
| 4927 | + } | ||
| 4928 | + | ||
| 4929 | + } // namespace | ||
| 4930 | + | ||
| 4919 | 4931 | void CodeGenerator::AssembleMove(InstructionOperand* source, | |
| 4920 | 4932 | InstructionOperand* destination) { | |
| 4921 | 4933 | X64OperandConverter g(this, nullptr); | |
@@ -5032,18 +5044,18 @@ void CodeGenerator::AssembleMove(InstructionOperand* source, | |||
| 5032 | 5044 | case MoveType::kStackToRegister: { | |
| 5033 | 5045 | Operand src = g.ToOperand(source); | |
| 5034 | 5046 | if (source->IsStackSlot()) { | |
| 5035 | - MachineRepresentation mr = | ||
| 5036 | - LocationOperand::cast(source)->representation(); | ||
| 5037 | - const bool is_32_bit = mr == MachineRepresentation::kWord32 || | ||
| 5038 | - mr == MachineRepresentation::kCompressed || | ||
| 5039 | - mr == MachineRepresentation::kCompressedPointer; | ||
| 5040 | 5047 | // TODO(13581): Fix this for other code kinds (see | |
| 5041 | 5048 | // https://crbug.com/1356461). | |
| 5042 | - if (code_kind() == CodeKind::WASM_FUNCTION && is_32_bit) { | ||
| 5049 | + if (code_kind() == CodeKind::WASM_FUNCTION && Is32BitOperand(source) && | ||
| 5050 | + Is32BitOperand(destination)) { | ||
| 5043 | 5051 | // When we need only 32 bits, move only 32 bits. Benefits: | |
| 5044 | 5052 | // - Save a byte here and there (depending on the destination | |
| 5045 | 5053 | // register; "movl eax, ..." is smaller than "movq rax, ..."). | |
| 5046 | 5054 | // - Safeguard against accidental decompression of compressed slots. | |
| 5055 | + // We must check both {source} and {destination} to be 32-bit values, | ||
| 5056 | + // because treating 32-bit sources as 64-bit values can be perfectly | ||
| 5057 | + // fine as a result of virtual register renaming (to avoid redundant | ||
| 5058 | + // explicit zero-extensions that also happen implicitly). | ||
| 5047 | 5059 | __ movl(g.ToRegister(destination), src); | |
| 5048 | 5060 | } else { | |
| 5049 | 5061 | __ movq(g.ToRegister(destination), src); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,64 @@ | |||
| 1 | + // Copyright 2023 the V8 project authors. All rights reserved. | ||
| 2 | + // Use of this source code is governed by a BSD-style license that can be | ||
| 3 | + // found in the LICENSE file. | ||
| 4 | + | ||
| 5 | + d8.file.execute('test/mjsunit/wasm/wasm-module-builder.js'); | ||
| 6 | + | ||
| 7 | + let builder = new WasmModuleBuilder(); | ||
| 8 | + builder.addMemory(1, 1, false); | ||
| 9 | + builder.addDataSegment(0, [0x78, 0x56, 0x34, 0x12]); | ||
| 10 | + | ||
| 11 | + let spiller = builder.addFunction('spiller', kSig_v_v).addBody([]); | ||
| 12 | + | ||
| 13 | + builder.addFunction('main', kSig_l_v) | ||
| 14 | + .exportFunc() | ||
| 15 | + .addLocals(kWasmI64, 1) | ||
| 16 | + .addBody([ | ||
| 17 | + // Initialize {var0} to 0x12345678 via a zero-extended 32-bit load. | ||
| 18 | + kExprI32Const, 0, | ||
| 19 | + kExprI64LoadMem32U, 2, 0, | ||
| 20 | + kExprLocalSet, 0, | ||
| 21 | + kExprCallFunction, spiller.index, | ||
| 22 | + // The observable effect of this loop is that {var0} is left-shifted | ||
| 23 | + // until it ends in 0x..000000. The details are specifically crafted | ||
| 24 | + // to recreate a particular pattern of spill slot moves. | ||
| 25 | + kExprLoop, kWasmVoid, | ||
| 26 | + kExprI32Const, 0, | ||
| 27 | + kExprI32LoadMem, 2, 0, | ||
| 28 | + kExprI32Eqz, | ||
| 29 | + // This block is never taken; it only serves to influence register | ||
| 30 | + // allocator choices. | ||
| 31 | + kExprIf, kWasmVoid, | ||
| 32 | + kExprLocalGet, 0, | ||
| 33 | + kExprI64Const, 1, | ||
| 34 | + kExprI64And, | ||
| 35 | + kExprLocalSet, 0, | ||
| 36 | + kExprEnd, // if | ||
| 37 | + kExprLocalGet, 0, | ||
| 38 | + kExprI64Const, 1, | ||
| 39 | + kExprI64And, | ||
| 40 | + kExprI64Eqz, | ||
| 41 | + // This block is always taken; it is conditional in order to influence | ||
| 42 | + // register allocator choices. | ||
| 43 | + kExprIf, kWasmVoid, | ||
| 44 | + kExprLocalGet, 0, | ||
| 45 | + kExprI64Const, 8, | ||
| 46 | + kExprI64Shl, | ||
| 47 | + kExprLocalSet, 0, | ||
| 48 | + kExprEnd, // if | ||
| 49 | + kExprBlock, kWasmVoid, | ||
| 50 | + kExprLocalGet, 0, | ||
| 51 | + ...wasmI64Const(0xFFFFFF), | ||
| 52 | + kExprI64And, | ||
| 53 | + kExprI64Eqz, | ||
| 54 | + kExprI32Eqz, | ||
| 55 | + kExprCallFunction, spiller.index, | ||
| 56 | + kExprBrIf, 1, | ||
| 57 | + kExprEnd, // block | ||
| 58 | + kExprCallFunction, spiller.index, | ||
| 59 | + kExprEnd, // loop | ||
| 60 | + kExprLocalGet, 0, | ||
| 61 | + ]); | ||
| 62 | + | ||
| 63 | + let instance = builder.instantiate(); | ||
| 64 | + assertEquals("12345678000000", instance.exports.main().toString(16)); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments