| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 0fb1d2b commit ca60942
10 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -200,15 +200,15 @@ surface. It models the ABI categories that the generated trampoline knows how to | |||
| 200 | 200 | marshal directly: | |
| 201 | 201 | ||
| 202 | 202 | * `kVoid` | |
| 203 | - * `kBool` | ||
| 204 | 203 | * signed and unsigned 8-bit, 16-bit, 32-bit, and 64-bit integers | |
| 205 | 204 | * `kFloat32` | |
| 206 | 205 | * `kFloat64` | |
| 207 | 206 | * `kPointer` | |
| 208 | 207 | * `kBuffer` | |
| 209 | 208 | ||
| 210 | 209 | Public aliases are normalized in `FastScalarTypeFromName()` and | |
| 211 | - `FastArgTypeFromName()`. | ||
| 210 | + `FastArgTypeFromName()`. In particular, `bool` is normalized to `kUint8` to | ||
| 211 | + match its documented 8-bit unsigned integer semantics. | ||
| 212 | 212 | ||
| 213 | 213 | `pointer`, `ptr`, `string`, `str`, `buffer`, and `arraybuffer` all represent | |
| 214 | 214 | pointer-sized native values at the target ABI boundary. They differ in how | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -37,7 +37,7 @@ bool FastScalarTypeFromName(std::string_view type, FastFFIType* out) { | |||
| 37 | 37 | if (type == "void") { | |
| 38 | 38 | *out = FastFFIType::kVoid; | |
| 39 | 39 | } else if (type == "bool") { | |
| 40 | - *out = FastFFIType::kBool; | ||
| 40 | + *out = FastFFIType::kUint8; | ||
| 41 | 41 | } else if (IsTypeName(type, {"i8", "int8"})) { | |
| 42 | 42 | *out = FastFFIType::kInt8; | |
| 43 | 43 | } else if (IsTypeName(type, {"u8", "uint8"})) { | |
@@ -96,8 +96,6 @@ CTypeInfo::Type ToV8Type(FastFFIType type, bool is_return) { | |||
| 96 | 96 | switch (type) { | |
| 97 | 97 | case FastFFIType::kVoid: | |
| 98 | 98 | return CTypeInfo::Type::kVoid; | |
| 99 | - case FastFFIType::kBool: | ||
| 100 | - return CTypeInfo::Type::kBool; | ||
| 101 | 99 | case FastFFIType::kUint8: | |
| 102 | 100 | return CTypeInfo::Type::kUint32; | |
| 103 | 101 | case FastFFIType::kInt8: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -17,7 +17,6 @@ struct FFIFunction; | |||
| 17 | 17 | ||
| 18 | 18 | enum class FastFFIType : uint8_t { | |
| 19 | 19 | kVoid, | |
| 20 | - kBool, | ||
| 21 | 20 | kInt8, | |
| 22 | 21 | kUint8, | |
| 23 | 22 | kInt16, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -136,7 +136,6 @@ uint32_t UxthW(unsigned reg) { | |||
| 136 | 136 | // to the ABI width expected by the native target before the final call. | |
| 137 | 137 | bool EmitNarrow(uint32_t** cursor, FastFFIType type, unsigned reg) { | |
| 138 | 138 | switch (type) { | |
| 139 | - case FastFFIType::kBool: | ||
| 140 | 139 | case FastFFIType::kUint8: | |
| 141 | 140 | *(*cursor)++ = UxtbW(reg); | |
| 142 | 141 | return true; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -19,7 +19,6 @@ bool IsFloatType(FastFFIType type) { | |||
| 19 | 19 | ||
| 20 | 20 | bool IsNarrowType(FastFFIType type) { | |
| 21 | 21 | switch (type) { | |
| 22 | - case FastFFIType::kBool: | ||
| 23 | 22 | case FastFFIType::kInt8: | |
| 24 | 23 | case FastFFIType::kUint8: | |
| 25 | 24 | case FastFFIType::kInt16: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -23,7 +23,6 @@ bool IsFloatType(FastFFIType type) { | |||
| 23 | 23 | ||
| 24 | 24 | bool IsNarrowType(FastFFIType type) { | |
| 25 | 25 | switch (type) { | |
| 26 | - case FastFFIType::kBool: | ||
| 27 | 26 | case FastFFIType::kInt8: | |
| 28 | 27 | case FastFFIType::kUint8: | |
| 29 | 28 | case FastFFIType::kInt16: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -19,7 +19,6 @@ bool IsFloatType(FastFFIType type) { | |||
| 19 | 19 | ||
| 20 | 20 | bool IsNarrowType(FastFFIType type) { | |
| 21 | 21 | switch (type) { | |
| 22 | - case FastFFIType::kBool: | ||
| 23 | 22 | case FastFFIType::kInt8: | |
| 24 | 23 | case FastFFIType::kUint8: | |
| 25 | 24 | case FastFFIType::kInt16: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -19,7 +19,6 @@ bool IsFloatType(FastFFIType type) { | |||
| 19 | 19 | ||
| 20 | 20 | bool IsNarrowType(FastFFIType type) { | |
| 21 | 21 | switch (type) { | |
| 22 | - case FastFFIType::kBool: | ||
| 23 | 22 | case FastFFIType::kInt8: | |
| 24 | 23 | case FastFFIType::kUint8: | |
| 25 | 24 | case FastFFIType::kInt16: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -232,7 +232,6 @@ void EmitNarrowInstruction(uint8_t** cursor, uint8_t opcode, unsigned reg) { | |||
| 232 | 232 | // consumes the declared low 8/16 bits. | |
| 233 | 233 | bool EmitNarrowReturn(uint8_t** cursor, FastFFIType type, unsigned reg) { | |
| 234 | 234 | switch (type) { | |
| 235 | - case FastFFIType::kBool: | ||
| 236 | 235 | case FastFFIType::kUint8: | |
| 237 | 236 | EmitNarrowInstruction(cursor, 0xb6, reg); | |
| 238 | 237 | return true; | |
@@ -252,7 +251,6 @@ bool EmitNarrowReturn(uint8_t** cursor, FastFFIType type, unsigned reg) { | |||
| 252 | 251 | ||
| 253 | 252 | bool NeedsNarrow(FastFFIType type) { | |
| 254 | 253 | switch (type) { | |
| 255 | - case FastFFIType::kBool: | ||
| 256 | 254 | case FastFFIType::kUint8: | |
| 257 | 255 | case FastFFIType::kInt8: | |
| 258 | 256 | case FastFFIType::kUint16: | |
@@ -655,7 +653,6 @@ void EmitNarrowInstruction(uint8_t** cursor, uint8_t opcode, unsigned reg) { | |||
| 655 | 653 | ||
| 656 | 654 | bool EmitNarrowReturn(uint8_t** cursor, FastFFIType type, unsigned reg) { | |
| 657 | 655 | switch (type) { | |
| 658 | - case FastFFIType::kBool: | ||
| 659 | 656 | case FastFFIType::kUint8: | |
| 660 | 657 | EmitNarrowInstruction(cursor, 0xb6, reg); | |
| 661 | 658 | return true; | |
@@ -675,7 +672,6 @@ bool EmitNarrowReturn(uint8_t** cursor, FastFFIType type, unsigned reg) { | |||
| 675 | 672 | ||
| 676 | 673 | bool NeedsNarrow(FastFFIType type) { | |
| 677 | 674 | switch (type) { | |
| 678 | - case FastFFIType::kBool: | ||
| 679 | 675 | case FastFFIType::kUint8: | |
| 680 | 676 | case FastFFIType::kInt8: | |
| 681 | 677 | case FastFFIType::kUint16: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,4 +1,4 @@ | |||
| 1 | - // Flags: --experimental-ffi --expose-gc | ||
| 1 | + // Flags: --experimental-ffi --expose-gc --allow-natives-syntax | ||
| 2 | 2 | 'use strict'; | |
| 3 | 3 | const common = require('../common'); | |
| 4 | 4 | common.skipIfFFIMissing(); | |
@@ -62,8 +62,16 @@ test('ffi bool signatures use uint8 values', () => { | |||
| 62 | 62 | arguments: ['bool', 'bool'], | |
| 63 | 63 | return: 'bool', | |
| 64 | 64 | }); | |
| 65 | - assert.strictEqual(boolAdder(1, 0), 1); | ||
| 66 | - assert.throws(() => boolAdder(true, false), /Argument 0 must be a uint8/); | ||
| 65 | + function callBoolAdder(a, b) { | ||
| 66 | + return boolAdder(a, b); | ||
| 67 | + } | ||
| 68 | + | ||
| 69 | + eval('%PrepareFunctionForOptimization(callBoolAdder)'); | ||
| 70 | + assert.strictEqual(callBoolAdder(1, 0), 1); | ||
| 71 | + eval('%OptimizeFunctionOnNextCall(callBoolAdder)'); | ||
| 72 | + assert.strictEqual(callBoolAdder(1, 0), 1); | ||
| 73 | + assert.throws( | ||
| 74 | + () => callBoolAdder(true, false), /Argument 0 must be a uint8/); | ||
| 67 | 75 | } finally { | |
| 68 | 76 | lib.close(); | |
| 69 | 77 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments