Skip to content

Commit

Permalink
upgrade webkit (#13192)
Browse files Browse the repository at this point in the history
Co-authored-by: Dylan Conway <[email protected]>
Co-authored-by: Zack Radisic <[email protected]>
  • Loading branch information
3 people authored Aug 13, 2024
1 parent b972ed6 commit 3a245dd
Show file tree
Hide file tree
Showing 35 changed files with 265 additions and 133 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@
},
"files.associations": {
"*.idl": "cpp",
"array": "cpp",
},
"C_Cpp.files.exclude": {
"**/.vscode": true,
Expand Down
3 changes: 1 addition & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ cmake_policy(SET CMP0067 NEW)

set(CMAKE_POLICY_DEFAULT_CMP0069 NEW)
set(Bun_VERSION "1.1.23")
set(WEBKIT_TAG a060f087c2232fb20d82c321d21e074e735d3261)
set(WEBKIT_TAG 1cdc5e606ad7d451853f75a068a320148385f397)

set(BUN_WORKDIR "${CMAKE_CURRENT_BINARY_DIR}")
message(STATUS "Configuring Bun ${Bun_VERSION} in ${BUN_WORKDIR}")
Expand Down Expand Up @@ -1030,7 +1030,6 @@ add_compile_definitions(
"LIBUS_USE_BORINGSSL=1"
"WITH_BORINGSSL=1"
"STATICALLY_LINKED_WITH_JavaScriptCore=1"
"STATICALLY_LINKED_WITH_WTF=1"
"STATICALLY_LINKED_WITH_BMALLOC=1"
"BUILDING_WITH_CMAKE=1"
"JSC_OBJC_API_ENABLED=0"
Expand Down
5 changes: 5 additions & 0 deletions docs/api/binary-data.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,11 @@ The following classes are typed arrays, along with a description of how they int

---

- [`Float16Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float16Array)
- Every two (2) bytes are interpreted as a 16-bit floating point number. Range -6.104e5 to 6.55e4.

---

- [`Float32Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float32Array)
- Every four (4) bytes are interpreted as a 32-bit floating point number. Range -3.4e38 to 3.4e38.

Expand Down
10 changes: 9 additions & 1 deletion src/bun.js/ConsoleObject.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1175,6 +1175,7 @@ pub const Formatter = struct {
.Uint16Array,
.Int32Array,
.Uint32Array,
.Float16Array,
.Float32Array,
.Float64Array,
.BigInt64Array,
Expand Down Expand Up @@ -2122,7 +2123,7 @@ pub const Formatter = struct {
}
},
.Array => {
const len = @as(u32, @truncate(value.getLength(this.globalThis)));
const len = value.getLength(this.globalThis);

// TODO: DerivedArray does not get passed along in JSType, and it's not clear why.
// if (jsType == .DerivedArray) {
Expand Down Expand Up @@ -3087,6 +3088,13 @@ pub const Formatter = struct {
@as([]align(std.meta.alignment([]u32)) u32, @alignCast(std.mem.bytesAsSlice(u32, slice))),
enable_ansi_colors,
),
.Float16Array => this.writeTypedArray(
*@TypeOf(writer),
&writer,
f16,
@as([]align(std.meta.alignment([]f16)) f16, @alignCast(std.mem.bytesAsSlice(f16, slice))),
enable_ansi_colors,
),
.Float32Array => this.writeTypedArray(
*@TypeOf(writer),
&writer,
Expand Down
1 change: 1 addition & 0 deletions src/bun.js/api/BunObject.zig
Original file line number Diff line number Diff line change
Expand Up @@ -3720,6 +3720,7 @@ const HashObject = struct {
.Uint16Array,
.Int32Array,
.Uint32Array,
.Float16Array,
.Float32Array,
.Float64Array,
.BigInt64Array,
Expand Down
13 changes: 6 additions & 7 deletions src/bun.js/api/bun/udp_socket.zig
Original file line number Diff line number Diff line change
Expand Up @@ -496,20 +496,19 @@ pub const UDPSocket = struct {
};

const payload_arg = arguments.ptr[0];
var payload = brk: {
var payload_str = JSC.ZigString.Slice.empty;
defer payload_str.deinit();
const payload = brk: {
if (payload_arg.asArrayBuffer(globalThis)) |array_buffer| {
break :brk bun.JSC.ZigString.Slice{
.ptr = array_buffer.ptr,
.len = array_buffer.len,
};
break :brk array_buffer.slice();
} else if (payload_arg.isString()) {
break :brk payload_arg.asString().toSlice(globalThis, bun.default_allocator);
payload_str = payload_arg.asString().toSlice(globalThis, bun.default_allocator);
break :brk payload_str.slice();
} else {
globalThis.throwInvalidArguments("Expected ArrayBufferView or string as first argument", .{});
return .zero;
}
};
defer payload.deinit();

var addr: std.posix.sockaddr.storage = std.mem.zeroes(std.posix.sockaddr.storage);
const addr_ptr = brk: {
Expand Down
12 changes: 8 additions & 4 deletions src/bun.js/base.zig
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,9 @@ pub const JSStringList = std.ArrayList(js.JSStringRef);

pub const ArrayBuffer = extern struct {
ptr: [*]u8 = undefined,
offset: u32 = 0,
len: u32 = 0,
byte_len: u32 = 0,
offset: usize = 0,
len: usize = 0,
byte_len: usize = 0,
typed_array_type: JSC.JSValue.JSType = .Cell,
value: JSC.JSValue = JSC.JSValue.zero,
shared: bool = false,
Expand Down Expand Up @@ -1353,6 +1353,7 @@ pub const BinaryType = enum(u4) {
Int8Array,
Int16Array,
Int32Array,
Float16Array,
Float32Array,
Float64Array,
// DataView,
Expand All @@ -1363,6 +1364,7 @@ pub const BinaryType = enum(u4) {
.Buffer => .Uint8Array,
// .DataView => .DataView,
.Float32Array => .Float32Array,
.Float16Array => .Float16Array,
.Float64Array => .Float64Array,
.Int16Array => .Int16Array,
.Int32Array => .Int32Array,
Expand All @@ -1384,6 +1386,7 @@ pub const BinaryType = enum(u4) {
.{ "Buffer", .Buffer },
// .{ "DataView", .DataView },
.{ "Float32Array", .Float32Array },
.{ "Float16Array", .Float16Array },
.{ "Float64Array", .Float64Array },
.{ "Int16Array", .Int16Array },
.{ "Int32Array", .Int32Array },
Expand All @@ -1394,6 +1397,7 @@ pub const BinaryType = enum(u4) {
.{ "arraybuffer", .ArrayBuffer },
.{ "buffer", .Buffer },
// .{ "dataview", .DataView },
.{ "float16array", .Float16Array },
.{ "float32array", .Float32Array },
.{ "float64array", .Float64Array },
.{ "int16array", .Int16Array },
Expand Down Expand Up @@ -1426,7 +1430,7 @@ pub const BinaryType = enum(u4) {
.Uint8Array => return JSC.ArrayBuffer.create(globalThis, bytes, .Uint8Array),

// These aren't documented, but they are supported
.Uint16Array, .Uint32Array, .Int8Array, .Int16Array, .Int32Array, .Float32Array, .Float64Array => {
.Uint16Array, .Uint32Array, .Int8Array, .Int16Array, .Int32Array, .Float16Array, .Float32Array, .Float64Array => {
const buffer = JSC.ArrayBuffer.create(globalThis, bytes, .ArrayBuffer);
return JSC.JSValue.c(JSC.C.JSObjectMakeTypedArrayWithArrayBuffer(globalThis, this.toTypedArrayType(), buffer.asObjectRef(), null));
},
Expand Down
1 change: 1 addition & 0 deletions src/bun.js/bindings/JSBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2299,6 +2299,7 @@ JSC_DEFINE_HOST_FUNCTION(constructJSBuffer, (JSC::JSGlobalObject * lexicalGlobal
case Int8ArrayType:
case Int16ArrayType:
case Int32ArrayType:
case Float16ArrayType:
case Float32ArrayType:
case Float64ArrayType:
case BigInt64ArrayType:
Expand Down
4 changes: 4 additions & 0 deletions src/bun.js/bindings/KeyObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__createPrivateKey, (JSC::JSGlobalObject * glo
case Int8ArrayType:
case Int16ArrayType:
case Int32ArrayType:
case Float16ArrayType:
case Float32ArrayType:
case Float64ArrayType:
case BigInt64ArrayType:
Expand Down Expand Up @@ -939,6 +940,7 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__createPublicKey, (JSC::JSGlobalObject * glob
case Int8ArrayType:
case Int16ArrayType:
case Int32ArrayType:
case Float16ArrayType:
case Float32ArrayType:
case Float64ArrayType:
case BigInt64ArrayType:
Expand Down Expand Up @@ -1272,6 +1274,7 @@ JSC_DEFINE_HOST_FUNCTION(KeyObject__createSecretKey, (JSC::JSGlobalObject * lexi
case Int8ArrayType:
case Int16ArrayType:
case Int32ArrayType:
case Float16ArrayType:
case Float32ArrayType:
case Float64ArrayType:
case BigInt64ArrayType:
Expand Down Expand Up @@ -1328,6 +1331,7 @@ static ExceptionOr<Vector<uint8_t>> KeyObject__GetBuffer(JSValue bufferArg)
case Int8ArrayType:
case Int16ArrayType:
case Int32ArrayType:
case Float16ArrayType:
case Float32ArrayType:
case Float64ArrayType:
case BigInt64ArrayType:
Expand Down
11 changes: 11 additions & 0 deletions src/bun.js/bindings/SQLClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,17 @@ static JSC::JSValue toJS(JSC::VM& vm, JSC::JSGlobalObject* globalObject, DataCel
}
return array;
}
case JSC::JSType::Float16ArrayType: {
JSC::JSFloat16Array* array = JSC::JSFloat16Array::createUninitialized(globalObject, globalObject->typedArrayStructure(TypedArrayType::TypeFloat16, false), length);
if (UNLIKELY(array == nullptr)) {
return {};
}

if (length > 0) {
memcpy(array->vector(), reinterpret_cast<void*>(cell.value.typed_array.data), length * 2); // sizeof(float16_t)
}
return array;
}
case JSC::JSType::Float32ArrayType: {
JSC::JSFloat32Array* array = JSC::JSFloat32Array::createUninitialized(globalObject, globalObject->typedArrayStructure(TypedArrayType::TypeFloat32, false), length);
if (UNLIKELY(array == nullptr)) {
Expand Down
5 changes: 4 additions & 1 deletion src/bun.js/bindings/bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1049,6 +1049,7 @@ bool Bun__deepEquals(JSC__JSGlobalObject* globalObject, JSValue v1, JSValue v2,
case Uint16ArrayType:
case Int32ArrayType:
case Uint32ArrayType:
case Float16ArrayType:
case Float32ArrayType:
case Float64ArrayType:
case BigInt64ArrayType:
Expand Down Expand Up @@ -1872,7 +1873,7 @@ extern "C" JSC__JSValue ZigString__toJSONObject(const ZigString* strPtr, JSC::JS
if (str.isNull()) {
// isNull() will be true for empty strings and for strings which are too long.
// So we need to check the length is plausibly due to a long string.
if (strPtr->len > Bun__syntheticAllocationLimit) {
if (strPtr->len > Bun__stringSyntheticAllocationLimit) {
scope.throwException(globalObject, Bun::createError(globalObject, Bun::ErrorCode::ERR_STRING_TOO_LONG, "Cannot parse a JSON string longer than 2^32-1 characters"_s));
return {};
}
Expand Down Expand Up @@ -2026,6 +2027,7 @@ double JSC__JSValue__getLengthIfPropertyExistsInternal(JSC__JSValue value, JSC__
case JSC::JSType::Uint16ArrayType:
case JSC::JSType::Int32ArrayType:
case JSC::JSType::Uint32ArrayType:
case JSC::JSType::Float16ArrayType:
case JSC::JSType::Float32ArrayType:
case JSC::JSType::Float64ArrayType:
case JSC::JSType::BigInt64ArrayType:
Expand Down Expand Up @@ -2768,6 +2770,7 @@ bool JSC__JSValue__asArrayBuffer_(JSC__JSValue JSValue0, JSC__JSGlobalObject* ar
case JSC::JSType::Uint16ArrayType:
case JSC::JSType::Int32ArrayType:
case JSC::JSType::Uint32ArrayType:
case JSC::JSType::Float16ArrayType:
case JSC::JSType::Float32ArrayType:
case JSC::JSType::Float64ArrayType:
case JSC::JSType::BigInt64ArrayType:
Expand Down
73 changes: 39 additions & 34 deletions src/bun.js/bindings/bindings.zig
Original file line number Diff line number Diff line change
Expand Up @@ -3430,40 +3430,41 @@ pub const JSValue = enum(JSValueReprInt) {
Uint16Array = 43,
Int32Array = 44,
Uint32Array = 45,
Float32Array = 46,
Float64Array = 47,
BigInt64Array = 48,
BigUint64Array = 49,
DataView = 50,
GlobalObject = 51,
GlobalLexicalEnvironment = 52,
LexicalEnvironment = 53,
ModuleEnvironment = 54,
StrictEvalActivation = 55,
WithScope = 56,
ModuleNamespaceObject = 57,
ShadowRealm = 58,
RegExpObject = 59,
JSDate = 60,
ProxyObject = 61,
JSGenerator = 62,
JSAsyncGenerator = 63,
JSArrayIterator = 64,
JSMapIterator = 65,
JSSetIterator = 66,
JSStringIterator = 67,
JSPromise = 68,
JSMap = 69,
JSSet = 70,
JSWeakMap = 71,
JSWeakSet = 72,
WebAssemblyModule = 73,
WebAssemblyInstance = 74,
WebAssemblyGCObject = 75,
StringObject = 76,
DerivedStringObject = 77,

InternalFieldTuple,
Float16Array = 46,
Float32Array = 47,
Float64Array = 48,
BigInt64Array = 49,
BigUint64Array = 50,
DataView = 51,
GlobalObject = 52,
GlobalLexicalEnvironment = 53,
LexicalEnvironment = 54,
ModuleEnvironment = 55,
StrictEvalActivation = 56,
WithScope = 57,
ModuleNamespaceObject = 58,
ShadowRealm = 59,
RegExpObject = 60,
JSDate = 61,
ProxyObject = 62,
JSGenerator = 63,
JSAsyncGenerator = 64,
JSArrayIterator = 65,
JSMapIterator = 66,
JSSetIterator = 67,
JSStringIterator = 68,
JSPromise = 69,
JSMap = 70,
JSSet = 71,
JSWeakMap = 72,
JSWeakSet = 73,
WebAssemblyModule = 74,
WebAssemblyInstance = 75,
WebAssemblyGCObject = 76,
StringObject = 77,
DerivedStringObject = 78,

InternalFieldTuple = 79,

MaxJS = 0b11111111,
Event = 0b11101111,
Expand All @@ -3490,6 +3491,7 @@ pub const JSValue = enum(JSValueReprInt) {
.Event,
.FinalObject,
.Float32Array,
.Float16Array,
.Float64Array,
.GlobalObject,
.Int16Array,
Expand Down Expand Up @@ -3546,6 +3548,7 @@ pub const JSValue = enum(JSValueReprInt) {
.BigInt64Array,
.BigUint64Array,
.Float32Array,
.Float16Array,
.Float64Array,
.Int16Array,
.Int32Array,
Expand Down Expand Up @@ -3641,6 +3644,7 @@ pub const JSValue = enum(JSValueReprInt) {
.BigInt64Array,
.BigUint64Array,
.Float32Array,
.Float16Array,
.Float64Array,
.Int16Array,
.Int32Array,
Expand Down Expand Up @@ -3682,6 +3686,7 @@ pub const JSValue = enum(JSValueReprInt) {
.BigInt64Array,
.BigUint64Array,
.Float32Array,
.Float16Array,
.Float64Array,
.Int16Array,
.Int32Array,
Expand Down
6 changes: 3 additions & 3 deletions src/bun.js/bindings/headers-handwritten.h
Original file line number Diff line number Diff line change
Expand Up @@ -298,9 +298,9 @@ using Uint8Array_alias = JSC::JSUint8Array;

typedef struct {
char* ptr;
uint32_t offset;
uint32_t len;
uint32_t byte_len;
size_t offset;
size_t len;
size_t byte_len;
uint8_t cell_type;
int64_t _value;
bool shared;
Expand Down
Loading

0 comments on commit 3a245dd

Please sign in to comment.