[dataview] Improve exception error messages
This CL makes the unoptimized DataView getter and setter methods output the right function name when throwing an exception, instead of a generic one. It also contains a little drive-by cleanup of the Torque code to keep it up to date with the language. Change-Id: I10eb37090a0206172e470b5958af6a5968f3836f Reviewed-on: https://chromium-review.googlesource.com/1146570 Commit-Queue: Théotime Grohens <theotime@google.com> Reviewed-by: Tobias Tebbi <tebbi@chromium.org> Cr-Commit-Position: refs/heads/master@{#54615}
This commit is contained in:
parent
485e0cee39
commit
fe45ddcc14
@ -11,6 +11,58 @@ module data_view {
|
||||
extern operator '.backing_store' macro LoadArrayBufferBackingStore(
|
||||
JSArrayBuffer): RawPtr;
|
||||
|
||||
macro MakeDataViewGetterNameString(kind: constexpr ElementsKind): String {
|
||||
if constexpr (kind == UINT8_ELEMENTS) {
|
||||
return 'DataView.prototype.getUint8';
|
||||
} else if constexpr (kind == INT8_ELEMENTS) {
|
||||
return 'DataView.prototype.getInt8';
|
||||
} else if constexpr (kind == UINT16_ELEMENTS) {
|
||||
return 'DataView.prototype.getUint16';
|
||||
} else if constexpr (kind == INT16_ELEMENTS) {
|
||||
return 'DataView.prototype.getInt16';
|
||||
} else if constexpr (kind == UINT32_ELEMENTS) {
|
||||
return 'DataView.prototype.getUint32';
|
||||
} else if constexpr (kind == INT32_ELEMENTS) {
|
||||
return 'DataView.prototype.getInt32';
|
||||
} else if constexpr (kind == FLOAT32_ELEMENTS) {
|
||||
return 'DataView.prototype.getFloat32';
|
||||
} else if constexpr (kind == FLOAT64_ELEMENTS) {
|
||||
return 'DataView.prototype.getFloat64';
|
||||
} else if constexpr (kind == BIGINT64_ELEMENTS) {
|
||||
return 'DataView.prototype.getBigInt64';
|
||||
} else if constexpr (kind == BIGUINT64_ELEMENTS) {
|
||||
return 'DataView.prototype.getBigUint64';
|
||||
} else {
|
||||
unreachable;
|
||||
}
|
||||
}
|
||||
|
||||
macro MakeDataViewSetterNameString(kind: constexpr ElementsKind): String {
|
||||
if constexpr (kind == UINT8_ELEMENTS) {
|
||||
return 'DataView.prototype.setUint8';
|
||||
} else if constexpr (kind == INT8_ELEMENTS) {
|
||||
return 'DataView.prototype.setInt8';
|
||||
} else if constexpr (kind == UINT16_ELEMENTS) {
|
||||
return 'DataView.prototype.setUint16';
|
||||
} else if constexpr (kind == INT16_ELEMENTS) {
|
||||
return 'DataView.prototype.setInt16';
|
||||
} else if constexpr (kind == UINT32_ELEMENTS) {
|
||||
return 'DataView.prototype.setUint32';
|
||||
} else if constexpr (kind == INT32_ELEMENTS) {
|
||||
return 'DataView.prototype.setInt32';
|
||||
} else if constexpr (kind == FLOAT32_ELEMENTS) {
|
||||
return 'DataView.prototype.setFloat32';
|
||||
} else if constexpr (kind == FLOAT64_ELEMENTS) {
|
||||
return 'DataView.prototype.setFloat64';
|
||||
} else if constexpr (kind == BIGINT64_ELEMENTS) {
|
||||
return 'DataView.prototype.setBigInt64';
|
||||
} else if constexpr (kind == BIGUINT64_ELEMENTS) {
|
||||
return 'DataView.prototype.setBigUint64';
|
||||
} else {
|
||||
unreachable;
|
||||
}
|
||||
}
|
||||
|
||||
macro WasNeutered(view: JSArrayBufferView): bool {
|
||||
return IsDetachedBuffer(view.buffer);
|
||||
}
|
||||
@ -184,11 +236,11 @@ module data_view {
|
||||
extern macro DataViewEncodeBigIntBits(constexpr bool,
|
||||
constexpr int31): intptr;
|
||||
|
||||
const kPositiveBigInt: constexpr bool generates 'false';
|
||||
const kNegativeBigInt: constexpr bool generates 'true';
|
||||
const kZeroDigitBigInt: constexpr int31 generates '0';
|
||||
const kOneDigitBigInt: constexpr int31 generates '1';
|
||||
const kTwoDigitBigInt: constexpr int31 generates '2';
|
||||
const kPositiveBigInt: constexpr bool = false;
|
||||
const kNegativeBigInt: constexpr bool = true;
|
||||
const kZeroDigitBigInt: constexpr int31 = 0;
|
||||
const kOneDigitBigInt: constexpr int31 = 1;
|
||||
const kTwoDigitBigInt: constexpr int31 = 2;
|
||||
|
||||
macro CreateEmptyBigInt(is_positive: bool, length: constexpr int31): BigInt {
|
||||
// Allocate a BigInt with the desired length (number of digits).
|
||||
@ -355,10 +407,8 @@ module data_view {
|
||||
requested_little_endian: Object,
|
||||
kind: constexpr ElementsKind): Numeric {
|
||||
|
||||
// TODO(theotime): add more specific method name to match
|
||||
// the former implementation.
|
||||
let data_view: JSDataView = ValidateDataView(
|
||||
context, receiver, 'get DataView.prototype.get');
|
||||
context, receiver, MakeDataViewGetterNameString(kind));
|
||||
|
||||
let getIndexSmi: Smi;
|
||||
try {
|
||||
@ -373,7 +423,8 @@ module data_view {
|
||||
let buffer: JSArrayBuffer = data_view.buffer;
|
||||
|
||||
if (IsDetachedBuffer(buffer)) {
|
||||
ThrowTypeError(context, kDetachedOperation, 'DataView.prototype.get');
|
||||
ThrowTypeError(context, kDetachedOperation,
|
||||
MakeDataViewGetterNameString(kind));
|
||||
}
|
||||
|
||||
let viewOffset: intptr = convert<intptr>(data_view.byte_offset);
|
||||
@ -664,10 +715,8 @@ module data_view {
|
||||
requested_little_endian: Object,
|
||||
kind: constexpr ElementsKind): Object {
|
||||
|
||||
// TODO(theotime): add more specific method name to match
|
||||
// the former implementation.
|
||||
let data_view: JSDataView = ValidateDataView(
|
||||
context, receiver, 'get DataView.prototype.get');
|
||||
context, receiver, MakeDataViewSetterNameString(kind));
|
||||
|
||||
let getIndexSmi: Smi;
|
||||
try {
|
||||
@ -692,7 +741,8 @@ module data_view {
|
||||
}
|
||||
|
||||
if (IsDetachedBuffer(buffer)) {
|
||||
ThrowTypeError(context, kDetachedOperation, 'DataView.prototype.get');
|
||||
ThrowTypeError(context, kDetachedOperation,
|
||||
MakeDataViewSetterNameString(kind));
|
||||
}
|
||||
|
||||
let viewOffset: intptr = convert<intptr>(data_view.byte_offset);
|
||||
|
@ -282,33 +282,33 @@ KNOWN_MAPS = {
|
||||
("RO_SPACE", 0x047b1): (171, "Tuple2Map"),
|
||||
("RO_SPACE", 0x04ae9): (161, "InterceptorInfoMap"),
|
||||
("RO_SPACE", 0x04bf1): (169, "ScriptMap"),
|
||||
("RO_SPACE", 0x095d1): (154, "AccessorInfoMap"),
|
||||
("RO_SPACE", 0x09621): (153, "AccessCheckInfoMap"),
|
||||
("RO_SPACE", 0x09671): (155, "AccessorPairMap"),
|
||||
("RO_SPACE", 0x096c1): (156, "AliasedArgumentsEntryMap"),
|
||||
("RO_SPACE", 0x09711): (157, "AllocationMementoMap"),
|
||||
("RO_SPACE", 0x09761): (158, "AsyncGeneratorRequestMap"),
|
||||
("RO_SPACE", 0x097b1): (159, "DebugInfoMap"),
|
||||
("RO_SPACE", 0x09801): (160, "FunctionTemplateInfoMap"),
|
||||
("RO_SPACE", 0x09851): (162, "InterpreterDataMap"),
|
||||
("RO_SPACE", 0x098a1): (163, "ModuleInfoEntryMap"),
|
||||
("RO_SPACE", 0x098f1): (164, "ModuleMap"),
|
||||
("RO_SPACE", 0x09941): (165, "ObjectTemplateInfoMap"),
|
||||
("RO_SPACE", 0x09991): (166, "PromiseCapabilityMap"),
|
||||
("RO_SPACE", 0x099e1): (167, "PromiseReactionMap"),
|
||||
("RO_SPACE", 0x09a31): (168, "PrototypeInfoMap"),
|
||||
("RO_SPACE", 0x09a81): (170, "StackFrameInfoMap"),
|
||||
("RO_SPACE", 0x09ad1): (172, "Tuple3Map"),
|
||||
("RO_SPACE", 0x09b21): (173, "ArrayBoilerplateDescriptionMap"),
|
||||
("RO_SPACE", 0x09b71): (174, "WasmDebugInfoMap"),
|
||||
("RO_SPACE", 0x09bc1): (175, "WasmExportedFunctionDataMap"),
|
||||
("RO_SPACE", 0x09c11): (176, "CallableTaskMap"),
|
||||
("RO_SPACE", 0x09c61): (177, "CallbackTaskMap"),
|
||||
("RO_SPACE", 0x09cb1): (178, "PromiseFulfillReactionJobTaskMap"),
|
||||
("RO_SPACE", 0x09d01): (179, "PromiseRejectReactionJobTaskMap"),
|
||||
("RO_SPACE", 0x09d51): (180, "PromiseResolveThenableJobTaskMap"),
|
||||
("RO_SPACE", 0x09da1): (181, "AllocationSiteMap"),
|
||||
("RO_SPACE", 0x09df1): (181, "AllocationSiteMap"),
|
||||
("RO_SPACE", 0x099c9): (154, "AccessorInfoMap"),
|
||||
("RO_SPACE", 0x09a19): (153, "AccessCheckInfoMap"),
|
||||
("RO_SPACE", 0x09a69): (155, "AccessorPairMap"),
|
||||
("RO_SPACE", 0x09ab9): (156, "AliasedArgumentsEntryMap"),
|
||||
("RO_SPACE", 0x09b09): (157, "AllocationMementoMap"),
|
||||
("RO_SPACE", 0x09b59): (158, "AsyncGeneratorRequestMap"),
|
||||
("RO_SPACE", 0x09ba9): (159, "DebugInfoMap"),
|
||||
("RO_SPACE", 0x09bf9): (160, "FunctionTemplateInfoMap"),
|
||||
("RO_SPACE", 0x09c49): (162, "InterpreterDataMap"),
|
||||
("RO_SPACE", 0x09c99): (163, "ModuleInfoEntryMap"),
|
||||
("RO_SPACE", 0x09ce9): (164, "ModuleMap"),
|
||||
("RO_SPACE", 0x09d39): (165, "ObjectTemplateInfoMap"),
|
||||
("RO_SPACE", 0x09d89): (166, "PromiseCapabilityMap"),
|
||||
("RO_SPACE", 0x09dd9): (167, "PromiseReactionMap"),
|
||||
("RO_SPACE", 0x09e29): (168, "PrototypeInfoMap"),
|
||||
("RO_SPACE", 0x09e79): (170, "StackFrameInfoMap"),
|
||||
("RO_SPACE", 0x09ec9): (172, "Tuple3Map"),
|
||||
("RO_SPACE", 0x09f19): (173, "ArrayBoilerplateDescriptionMap"),
|
||||
("RO_SPACE", 0x09f69): (174, "WasmDebugInfoMap"),
|
||||
("RO_SPACE", 0x09fb9): (175, "WasmExportedFunctionDataMap"),
|
||||
("RO_SPACE", 0x0a009): (176, "CallableTaskMap"),
|
||||
("RO_SPACE", 0x0a059): (177, "CallbackTaskMap"),
|
||||
("RO_SPACE", 0x0a0a9): (178, "PromiseFulfillReactionJobTaskMap"),
|
||||
("RO_SPACE", 0x0a0f9): (179, "PromiseRejectReactionJobTaskMap"),
|
||||
("RO_SPACE", 0x0a149): (180, "PromiseResolveThenableJobTaskMap"),
|
||||
("RO_SPACE", 0x0a199): (181, "AllocationSiteMap"),
|
||||
("RO_SPACE", 0x0a1e9): (181, "AllocationSiteMap"),
|
||||
("MAP_SPACE", 0x02201): (1057, "ExternalMap"),
|
||||
("MAP_SPACE", 0x02251): (1072, "JSMessageObjectMap"),
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user