Commit 613e29b1 authored by jgruber's avatar jgruber Committed by Commit bot

Move family of MakeError functions to C++

These were the final remnants of error code written in JavaScript.

BUG=

Review-Url: https://codereview.chromium.org/2222893002
Cr-Commit-Position: refs/heads/master@{#38475}
parent c1ae15d9
......@@ -1051,6 +1051,15 @@ static void InstallError(Isolate* isolate, Handle<JSObject> global,
}
}
static void InstallMakeError(Isolate* isolate, Handle<Code> code,
int context_index) {
Handle<JSFunction> function =
isolate->factory()->NewFunction(isolate->factory()->empty_string(), code,
JS_OBJECT_TYPE, JSObject::kHeaderSize);
function->shared()->DontAdaptArguments();
isolate->native_context()->set(context_index, *function);
}
// This is only called if we are not using snapshots. The equivalent
// work in the snapshot case is done in HookUpGlobalObject.
void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
......@@ -1600,6 +1609,8 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
{ // -- E r r o r
InstallError(isolate, global, factory->Error_string(),
Context::ERROR_FUNCTION_INDEX);
InstallMakeError(isolate, isolate->builtins()->MakeError(),
Context::MAKE_ERROR_INDEX);
}
{ // -- E v a l E r r o r
......@@ -1610,6 +1621,8 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
{ // -- R a n g e E r r o r
InstallError(isolate, global, factory->RangeError_string(),
Context::RANGE_ERROR_FUNCTION_INDEX);
InstallMakeError(isolate, isolate->builtins()->MakeRangeError(),
Context::MAKE_RANGE_ERROR_INDEX);
}
{ // -- R e f e r e n c e E r r o r
......@@ -1620,16 +1633,22 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
{ // -- S y n t a x E r r o r
InstallError(isolate, global, factory->SyntaxError_string(),
Context::SYNTAX_ERROR_FUNCTION_INDEX);
InstallMakeError(isolate, isolate->builtins()->MakeSyntaxError(),
Context::MAKE_SYNTAX_ERROR_INDEX);
}
{ // -- T y p e E r r o r
InstallError(isolate, global, factory->TypeError_string(),
Context::TYPE_ERROR_FUNCTION_INDEX);
InstallMakeError(isolate, isolate->builtins()->MakeTypeError(),
Context::MAKE_TYPE_ERROR_INDEX);
}
{ // -- U R I E r r o r
InstallError(isolate, global, factory->URIError_string(),
Context::URI_ERROR_FUNCTION_INDEX);
InstallMakeError(isolate, isolate->builtins()->MakeURIError(),
Context::MAKE_URI_ERROR_INDEX);
}
// Initialize the embedder data slot.
......@@ -2477,7 +2496,7 @@ void Bootstrapper::ExportFromRuntime(Isolate* isolate,
// Builtin functions for Script.
Handle<JSFunction> script_fun = InstallFunction(
container, "Script", JS_VALUE_TYPE, JSValue::kSize,
isolate->initial_object_prototype(), Builtins::kIllegal);
isolate->initial_object_prototype(), Builtins::kUnsupportedThrower);
Handle<JSObject> prototype =
factory->NewJSObject(isolate->object_function(), TENURED);
Accessors::FunctionSetPrototype(script_fun, prototype).Assert();
......@@ -2714,13 +2733,6 @@ void Bootstrapper::ExportFromRuntime(Isolate* isolate,
Accessors::FunctionSetPrototype(callsite_fun, proto).Assert();
}
}
{ // -- E r r o r
Handle<JSFunction> make_err_fun = InstallFunction(
container, "make_generic_error", JS_OBJECT_TYPE, JSObject::kHeaderSize,
isolate->initial_object_prototype(), Builtins::kMakeGenericError);
make_err_fun->shared()->DontAdaptArguments();
}
}
......
......@@ -81,23 +81,54 @@ BUILTIN(ErrorPrototypeToString) {
ErrorUtils::ToString(isolate, args.receiver()));
}
BUILTIN(MakeGenericError) {
HandleScope scope(isolate);
namespace {
Handle<Object> constructor = args.atOrUndefined(isolate, 1);
Handle<Object> template_index = args.atOrUndefined(isolate, 2);
Handle<Object> arg0 = args.atOrUndefined(isolate, 3);
Handle<Object> arg1 = args.atOrUndefined(isolate, 4);
Handle<Object> arg2 = args.atOrUndefined(isolate, 5);
Object* MakeGenericError(Isolate* isolate, BuiltinArguments args,
Handle<JSFunction> constructor) {
Handle<Object> template_index = args.atOrUndefined(isolate, 1);
Handle<Object> arg0 = args.atOrUndefined(isolate, 2);
Handle<Object> arg1 = args.atOrUndefined(isolate, 3);
Handle<Object> arg2 = args.atOrUndefined(isolate, 4);
DCHECK(constructor->IsJSFunction());
DCHECK(template_index->IsSmi());
RETURN_RESULT_OR_FAILURE(
isolate, ErrorUtils::MakeGenericError(isolate, constructor,
Smi::cast(*template_index)->value(),
arg0, arg1, arg2, SKIP_NONE));
}
} // namespace
BUILTIN(MakeError) {
HandleScope scope(isolate);
return MakeGenericError(isolate, args, isolate->error_function());
}
BUILTIN(MakeRangeError) {
HandleScope scope(isolate);
return MakeGenericError(isolate, args, isolate->range_error_function());
}
BUILTIN(MakeSyntaxError) {
HandleScope scope(isolate);
return MakeGenericError(isolate, args, isolate->syntax_error_function());
}
BUILTIN(MakeTypeError) {
HandleScope scope(isolate);
return MakeGenericError(isolate, args, isolate->type_error_function());
}
BUILTIN(MakeURIError) {
HandleScope scope(isolate);
Handle<JSFunction> constructor = isolate->uri_error_function();
Handle<Object> undefined = isolate->factory()->undefined_value();
const int template_index = MessageTemplate::kURIMalformed;
RETURN_RESULT_OR_FAILURE(
isolate,
ErrorUtils::MakeGenericError(
isolate, Handle<JSFunction>::cast(constructor),
Smi::cast(*template_index)->value(), arg0, arg1, arg2, SKIP_FIRST));
ErrorUtils::MakeGenericError(isolate, constructor, template_index,
undefined, undefined, undefined, SKIP_NONE));
}
} // namespace internal
......
......@@ -319,7 +319,11 @@ namespace internal {
CPP(ErrorConstructor) \
CPP(ErrorCaptureStackTrace) \
CPP(ErrorPrototypeToString) \
CPP(MakeGenericError) \
CPP(MakeError) \
CPP(MakeRangeError) \
CPP(MakeSyntaxError) \
CPP(MakeTypeError) \
CPP(MakeURIError) \
\
/* Function */ \
CPP(FunctionConstructor) \
......
......@@ -37,8 +37,11 @@ enum ContextLookupFlags {
#define NATIVE_CONTEXT_INTRINSIC_FUNCTIONS(V) \
V(IS_ARRAYLIKE, JSFunction, is_arraylike) \
V(GET_TEMPLATE_CALL_SITE_INDEX, JSFunction, get_template_call_site) \
V(MAKE_ERROR_INDEX, JSFunction, make_error) \
V(MAKE_RANGE_ERROR_INDEX, JSFunction, make_range_error) \
V(MAKE_SYNTAX_ERROR_INDEX, JSFunction, make_syntax_error) \
V(MAKE_TYPE_ERROR_INDEX, JSFunction, make_type_error) \
V(MAKE_URI_ERROR_INDEX, JSFunction, make_uri_error) \
V(OBJECT_DEFINE_PROPERTIES, JSFunction, object_define_properties) \
V(OBJECT_DEFINE_PROPERTY, JSFunction, object_define_property) \
V(OBJECT_FREEZE, JSFunction, object_freeze) \
......
......@@ -15,8 +15,6 @@ var IsNaN = global.isNaN;
var JSONParse = global.JSON.parse;
var JSONStringify = global.JSON.stringify;
var LookupMirror = global.LookupMirror;
var MakeError;
var MakeTypeError;
var MakeMirror = global.MakeMirror;
var MakeMirrorSerializer = global.MakeMirrorSerializer;
var MathMin = global.Math.min;
......@@ -26,8 +24,6 @@ var ParseInt = global.parseInt;
var ValueMirror = global.ValueMirror;
utils.Import(function(from) {
MakeError = from.MakeError;
MakeTypeError = from.MakeTypeError;
MirrorType = from.MirrorType;
});
......@@ -247,7 +243,7 @@ function ScriptBreakPoint(type, script_id_or_name, opt_line, opt_column,
} else if (type == Debug.ScriptBreakPointType.ScriptRegExp) {
this.script_regexp_object_ = new GlobalRegExp(script_id_or_name);
} else {
throw MakeError(kDebugger, "Unexpected breakpoint type " + type);
throw %make_error(kDebugger, "Unexpected breakpoint type " + type);
}
this.line_ = opt_line || 0;
this.column_ = opt_column;
......@@ -370,7 +366,7 @@ ScriptBreakPoint.prototype.matchesScript = function(script) {
} else if (this.type_ == Debug.ScriptBreakPointType.ScriptRegExp) {
return this.script_regexp_object_.test(script.nameOrSourceURL());
} else {
throw MakeError(kDebugger, "Unexpected breakpoint type " + this.type_);
throw %make_error(kDebugger, "Unexpected breakpoint type " + this.type_);
}
}
};
......@@ -466,7 +462,7 @@ function GetScriptBreakPoints(script) {
Debug.setListener = function(listener, opt_data) {
if (!IS_FUNCTION(listener) && !IS_UNDEFINED(listener) && !IS_NULL(listener)) {
throw MakeTypeError(kDebuggerType);
throw %make_type_error(kDebuggerType);
}
%SetDebugEventListener(listener, opt_data);
};
......@@ -516,13 +512,13 @@ Debug.scriptSource = function(func_or_script_name) {
Debug.source = function(f) {
if (!IS_FUNCTION(f)) throw MakeTypeError(kDebuggerType);
if (!IS_FUNCTION(f)) throw %make_type_error(kDebuggerType);
return %FunctionGetSourceCode(f);
};
Debug.sourcePosition = function(f) {
if (!IS_FUNCTION(f)) throw MakeTypeError(kDebuggerType);
if (!IS_FUNCTION(f)) throw %make_type_error(kDebuggerType);
return %FunctionGetScriptSourcePosition(f);
};
......@@ -576,10 +572,10 @@ Debug.findBreakPointActualLocations = function(break_point_number) {
};
Debug.setBreakPoint = function(func, opt_line, opt_column, opt_condition) {
if (!IS_FUNCTION(func)) throw MakeTypeError(kDebuggerType);
if (!IS_FUNCTION(func)) throw %make_type_error(kDebuggerType);
// Break points in API functions are not supported.
if (%FunctionIsAPIFunction(func)) {
throw MakeError(kDebugger, 'Cannot set break point in native code.');
throw %make_error(kDebugger, 'Cannot set break point in native code.');
}
// Find source position.
var source_position =
......@@ -588,7 +584,7 @@ Debug.setBreakPoint = function(func, opt_line, opt_column, opt_condition) {
var script = %FunctionGetScript(func);
// Break in builtin JavaScript code is not supported.
if (script.type == Debug.ScriptType.Native) {
throw MakeError(kDebugger, 'Cannot set break point in native code.');
throw %make_error(kDebugger, 'Cannot set break point in native code.');
}
// If the script for the function has a name convert this to a script break
// point.
......@@ -664,7 +660,7 @@ Debug.clearBreakPoint = function(break_point_number) {
return %ClearBreakPoint(break_point);
} else {
break_point = this.findScriptBreakPoint(break_point_number, true);
if (!break_point) throw MakeError(kDebugger, 'Invalid breakpoint');
if (!break_point) throw %make_error(kDebugger, 'Invalid breakpoint');
}
};
......@@ -816,7 +812,7 @@ Debug.isBreakOnUncaughtException = function() {
};
Debug.showBreakPoints = function(f, full, opt_position_alignment) {
if (!IS_FUNCTION(f)) throw MakeError(kDebuggerType);
if (!IS_FUNCTION(f)) throw %make_error(kDebuggerType);
var source = full ? this.scriptSource(f) : this.source(f);
var offset = full ? 0 : this.sourcePosition(f);
var position_alignment = IS_UNDEFINED(opt_position_alignment)
......@@ -890,7 +886,7 @@ ExecutionState.prototype.prepareStep = function(action) {
action === Debug.StepAction.StepFrame) {
return %PrepareStep(this.break_id, action);
}
throw MakeTypeError(kDebuggerType);
throw %make_type_error(kDebuggerType);
};
ExecutionState.prototype.evaluateGlobal = function(source, disable_break,
......@@ -908,7 +904,7 @@ ExecutionState.prototype.frame = function(opt_index) {
// If no index supplied return the selected frame.
if (opt_index == null) opt_index = this.selected_frame;
if (opt_index < 0 || opt_index >= this.frameCount()) {
throw MakeTypeError(kDebuggerFrame);
throw %make_type_error(kDebuggerFrame);
}
return new FrameMirror(this.break_id, opt_index);
};
......@@ -916,7 +912,7 @@ ExecutionState.prototype.frame = function(opt_index) {
ExecutionState.prototype.setSelectedFrame = function(index) {
var i = TO_NUMBER(index);
if (i < 0 || i >= this.frameCount()) {
throw MakeTypeError(kDebuggerFrame);
throw %make_type_error(kDebuggerFrame);
}
this.selected_frame = i;
};
......@@ -1290,16 +1286,16 @@ DebugCommandProcessor.prototype.processDebugJSONRequest = function(
response = this.createResponse(request);
if (!request.type) {
throw MakeError(kDebugger, 'Type not specified');
throw %make_error(kDebugger, 'Type not specified');
}
if (request.type != 'request') {
throw MakeError(kDebugger,
throw %make_error(kDebugger,
"Illegal type '" + request.type + "' in request");
}
if (!request.command) {
throw MakeError(kDebugger, 'Command not specified');
throw %make_error(kDebugger, 'Command not specified');
}
if (request.arguments) {
......@@ -1319,7 +1315,7 @@ DebugCommandProcessor.prototype.processDebugJSONRequest = function(
if (IS_FUNCTION(handler)) {
%_Call(handler, this, request, response);
} else {
throw MakeError(kDebugger,
throw %make_error(kDebugger,
'Unknown command "' + request.command + '" in request');
}
} catch (e) {
......@@ -1371,7 +1367,7 @@ DebugCommandProcessor.prototype.continueRequest_ = function(request, response) {
} else if (stepaction == 'out') {
action = Debug.StepAction.StepOut;
} else {
throw MakeError(kDebugger,
throw %make_error(kDebugger,
'Invalid stepaction argument "' + stepaction + '".');
}
}
......@@ -1491,7 +1487,7 @@ DebugCommandProcessor.prototype.setBreakPointRequest_ =
response.body.type = 'scriptRegExp';
response.body.script_regexp = break_point.script_regexp_object().source;
} else {
throw MakeError(kDebugger,
throw %make_error(kDebugger,
"Unexpected breakpoint type: " + break_point.type());
}
response.body.line = break_point.line();
......@@ -1625,7 +1621,7 @@ DebugCommandProcessor.prototype.listBreakpointsRequest_ = function(
description.type = 'scriptRegExp';
description.script_regexp = break_point.script_regexp_object().source;
} else {
throw MakeError(kDebugger,
throw %make_error(kDebugger,
"Unexpected breakpoint type: " + break_point.type());
}
array.push(description);
......@@ -1774,7 +1770,7 @@ DebugCommandProcessor.prototype.resolveFrameFromScopeDescription_ =
if (scope_description && !IS_UNDEFINED(scope_description.frameNumber)) {
var frame_index = scope_description.frameNumber;
if (frame_index < 0 || this.exec_state_.frameCount() <= frame_index) {
throw MakeTypeError(kDebuggerFrame);
throw %make_type_error(kDebuggerFrame);
}
return this.exec_state_.frame(frame_index);
} else {
......@@ -1790,21 +1786,21 @@ DebugCommandProcessor.prototype.resolveScopeHolder_ =
function(scope_description) {
if (scope_description && "functionHandle" in scope_description) {
if (!IS_NUMBER(scope_description.functionHandle)) {
throw MakeError(kDebugger, 'Function handle must be a number');
throw %make_error(kDebugger, 'Function handle must be a number');
}
var function_mirror = LookupMirror(scope_description.functionHandle);
if (!function_mirror) {
throw MakeError(kDebugger, 'Failed to find function object by handle');
throw %make_error(kDebugger, 'Failed to find function object by handle');
}
if (!function_mirror.isFunction()) {
throw MakeError(kDebugger,
throw %make_error(kDebugger,
'Value of non-function type is found by handle');
}
return function_mirror;
} else {
// No frames no scopes.
if (this.exec_state_.frameCount() == 0) {
throw MakeError(kDebugger, 'No scopes');
throw %make_error(kDebugger, 'No scopes');
}
// Get the frame for which the scopes are requested.
......@@ -1857,7 +1853,7 @@ DebugCommandProcessor.resolveValue_ = function(value_description) {
if ("handle" in value_description) {
var value_mirror = LookupMirror(value_description.handle);
if (!value_mirror) {
throw MakeError(kDebugger, "Failed to resolve value by handle, ' #" +
throw %make_error(kDebugger, "Failed to resolve value by handle, ' #" +
value_description.handle + "# not found");
}
return value_mirror.value();
......@@ -1869,7 +1865,7 @@ DebugCommandProcessor.resolveValue_ = function(value_description) {
} if (value_description.type == MirrorType.STRING_TYPE) {
return TO_STRING(value_description.stringDescription);
} else {
throw MakeError(kDebugger, "Unknown type");
throw %make_error(kDebugger, "Unknown type");
}
} else if ("value" in value_description) {
return value_description.value;
......@@ -1878,7 +1874,7 @@ DebugCommandProcessor.resolveValue_ = function(value_description) {
} else if (value_description.type == MirrorType.NULL_TYPE) {
return null;
} else {
throw MakeError(kDebugger, "Failed to parse value description");
throw %make_error(kDebugger, "Failed to parse value description");
}
};
......
......@@ -11,7 +11,6 @@
var GlobalArray = global.Array;
var IsNaN = global.isNaN;
var JSONStringify = global.JSON.stringify;
var MakeError;
var MapEntries;
var MapIteratorNext;
var promiseStateSymbol = utils.ImportNow("promise_state_symbol");
......@@ -20,7 +19,6 @@ var SetIteratorNext;
var SetValues;
utils.Import(function(from) {
MakeError = from.MakeError;
MapEntries = from.MapEntries;
MapIteratorNext = from.MapIteratorNext;
SetIteratorNext = from.SetIteratorNext;
......@@ -192,7 +190,7 @@ function MakeMirror(value, opt_transient) {
*/
function LookupMirror(handle) {
if (!mirror_cache_enabled_) {
throw MakeError(kDebugger, "Mirror cache is disabled");
throw %make_error(kDebugger, "Mirror cache is disabled");
}
return mirror_cache_[handle];
}
......@@ -2241,7 +2239,7 @@ ScopeDetails.prototype.setVariableValueImpl = function(name, new_value) {
raw_res = %SetScopeVariableValue(this.fun_value_, null, null, this.index_,
name, new_value);
}
if (!raw_res) throw MakeError(kDebugger, "Failed to set variable value");
if (!raw_res) throw %make_error(kDebugger, "Failed to set variable value");
};
......@@ -2340,7 +2338,7 @@ ScriptMirror.prototype.source = function() {
ScriptMirror.prototype.setSource = function(source) {
if (!IS_STRING(source)) throw MakeError(kDebugger, "Source is not a string");
if (!IS_STRING(source)) throw %make_error(kDebugger, "Source is not a string");
%DebugSetScriptSource(this.script_, source);
};
......@@ -2660,7 +2658,7 @@ JSONProtocolSerializer.prototype.serialize_ = function(mirror, reference,
case MirrorType.PROPERTY_TYPE:
case MirrorType.INTERNAL_PROPERTY_TYPE:
throw MakeError(kDebugger,
throw %make_error(kDebugger,
'PropertyMirror cannot be serialized independently');
break;
......
......@@ -20,14 +20,9 @@ var arrayIteratorObjectSymbol =
var GlobalArray = global.Array;
var IteratorPrototype = utils.ImportNow("IteratorPrototype");
var iteratorSymbol = utils.ImportNow("iterator_symbol");
var MakeTypeError;
var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
var GlobalTypedArray = %object_get_prototype_of(global.Uint8Array);
utils.Import(function(from) {
MakeTypeError = from.MakeTypeError;
})
// -----------------------------------------------------------------------
function ArrayIterator() {}
......@@ -63,7 +58,7 @@ function ArrayIteratorNext() {
if (!IS_RECEIVER(iterator) ||
!HAS_DEFINED_PRIVATE(iterator, arrayIteratorNextIndexSymbol)) {
throw MakeTypeError(kIncompatibleMethodReceiver,
throw %make_type_error(kIncompatibleMethodReceiver,
'Array Iterator.prototype.next', this);
}
......@@ -111,19 +106,19 @@ function ArrayKeys() {
// TODO(littledan): Check for detached TypedArray in these three methods
function TypedArrayEntries() {
if (!IS_TYPEDARRAY(this)) throw MakeTypeError(kNotTypedArray);
if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray);
return %_Call(ArrayEntries, this);
}
function TypedArrayValues() {
if (!IS_TYPEDARRAY(this)) throw MakeTypeError(kNotTypedArray);
if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray);
return %_Call(ArrayValues, this);
}
function TypedArrayKeys() {
if (!IS_TYPEDARRAY(this)) throw MakeTypeError(kNotTypedArray);
if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray);
return %_Call(ArrayKeys, this);
}
......
......@@ -16,7 +16,6 @@ var GetMethod;
var GlobalArray = global.Array;
var InternalArray = utils.InternalArray;
var InternalPackedArray = utils.InternalPackedArray;
var MakeTypeError;
var MaxSimple;
var MinSimple;
var ObjectHasOwnProperty;
......@@ -28,7 +27,6 @@ var unscopablesSymbol = utils.ImportNow("unscopables_symbol");
utils.Import(function(from) {
GetIterator = from.GetIterator;
GetMethod = from.GetMethod;
MakeTypeError = from.MakeTypeError;
MaxSimple = from.MaxSimple;
MinSimple = from.MinSimple;
ObjectHasOwnProperty = from.ObjectHasOwnProperty;
......@@ -424,7 +422,7 @@ function ArrayPush() {
// Subtract n from kMaxSafeInteger rather than testing m + n >
// kMaxSafeInteger. n may already be kMaxSafeInteger. In that case adding
// e.g., 1 would not be safe.
if (m > kMaxSafeInteger - n) throw MakeTypeError(kPushPastSafeLength, m, n);
if (m > kMaxSafeInteger - n) throw %make_type_error(kPushPastSafeLength, m, n);
for (var i = 0; i < m; i++) {
array[i+n] = arguments[i];
......@@ -546,7 +544,7 @@ function ArrayShift() {
return;
}
if (%object_is_sealed(array)) throw MakeTypeError(kArrayFunctionsOnSealed);
if (%object_is_sealed(array)) throw %make_type_error(kArrayFunctionsOnSealed);
var first = array[0];
......@@ -673,9 +671,9 @@ function ArraySplice(start, delete_count) {
var num_elements_to_add = num_arguments > 2 ? num_arguments - 2 : 0;
if (del_count != num_elements_to_add && %object_is_sealed(array)) {
throw MakeTypeError(kArrayFunctionsOnSealed);
throw %make_type_error(kArrayFunctionsOnSealed);
} else if (del_count > 0 && %object_is_frozen(array)) {
throw MakeTypeError(kArrayFunctionsOnFrozen);
throw %make_type_error(kArrayFunctionsOnFrozen);
}
var changed_elements = del_count;
......@@ -1031,14 +1029,14 @@ function ArrayFilter(f, receiver) {
// loop will not affect the looping and side effects are visible.
var array = TO_OBJECT(this);
var length = TO_LENGTH(array.length);
if (!IS_CALLABLE(f)) throw MakeTypeError(kCalledNonCallable, f);
if (!IS_CALLABLE(f)) throw %make_type_error(kCalledNonCallable, f);
var result = ArraySpeciesCreate(array, 0);
return InnerArrayFilter(f, receiver, array, length, result);
}
function InnerArrayForEach(f, receiver, array, length) {
if (!IS_CALLABLE(f)) throw MakeTypeError(kCalledNonCallable, f);
if (!IS_CALLABLE(f)) throw %make_type_error(kCalledNonCallable, f);
if (IS_UNDEFINED(receiver)) {
for (var i = 0; i < length; i++) {
......@@ -1070,7 +1068,7 @@ function ArrayForEach(f, receiver) {
function InnerArraySome(f, receiver, array, length) {
if (!IS_CALLABLE(f)) throw MakeTypeError(kCalledNonCallable, f);
if (!IS_CALLABLE(f)) throw %make_type_error(kCalledNonCallable, f);
for (var i = 0; i < length; i++) {
if (i in array) {
......@@ -1096,7 +1094,7 @@ function ArraySome(f, receiver) {
function InnerArrayEvery(f, receiver, array, length) {
if (!IS_CALLABLE(f)) throw MakeTypeError(kCalledNonCallable, f);
if (!IS_CALLABLE(f)) throw %make_type_error(kCalledNonCallable, f);
for (var i = 0; i < length; i++) {
if (i in array) {
......@@ -1125,7 +1123,7 @@ function ArrayMap(f, receiver) {
// loop will not affect the looping and side effects are visible.
var array = TO_OBJECT(this);
var length = TO_LENGTH(array.length);
if (!IS_CALLABLE(f)) throw MakeTypeError(kCalledNonCallable, f);
if (!IS_CALLABLE(f)) throw %make_type_error(kCalledNonCallable, f);
var result = ArraySpeciesCreate(array, length);
for (var i = 0; i < length; i++) {
if (i in array) {
......@@ -1264,7 +1262,7 @@ function ArrayLastIndexOf(element, index) {
function InnerArrayReduce(callback, current, array, length, argumentsLength) {
if (!IS_CALLABLE(callback)) {
throw MakeTypeError(kCalledNonCallable, callback);
throw %make_type_error(kCalledNonCallable, callback);
}
var i = 0;
......@@ -1275,7 +1273,7 @@ function InnerArrayReduce(callback, current, array, length, argumentsLength) {
break find_initial;
}
}
throw MakeTypeError(kReduceNoInitial);
throw %make_type_error(kReduceNoInitial);
}
for (; i < length; i++) {
......@@ -1303,7 +1301,7 @@ function ArrayReduce(callback, current) {
function InnerArrayReduceRight(callback, current, array, length,
argumentsLength) {
if (!IS_CALLABLE(callback)) {
throw MakeTypeError(kCalledNonCallable, callback);
throw %make_type_error(kCalledNonCallable, callback);
}
var i = length - 1;
......@@ -1314,7 +1312,7 @@ function InnerArrayReduceRight(callback, current, array, length,
break find_initial;
}
}
throw MakeTypeError(kReduceNoInitial);
throw %make_type_error(kReduceNoInitial);
}
for (; i >= 0; i--) {
......@@ -1400,7 +1398,7 @@ function ArrayCopyWithin(target, start, end) {
function InnerArrayFind(predicate, thisArg, array, length) {
if (!IS_CALLABLE(predicate)) {
throw MakeTypeError(kCalledNonCallable, predicate);
throw %make_type_error(kCalledNonCallable, predicate);
}
for (var i = 0; i < length; i++) {
......@@ -1427,7 +1425,7 @@ function ArrayFind(predicate, thisArg) {
function InnerArrayFindIndex(predicate, thisArg, array, length) {
if (!IS_CALLABLE(predicate)) {
throw MakeTypeError(kCalledNonCallable, predicate);
throw %make_type_error(kCalledNonCallable, predicate);
}
for (var i = 0; i < length; i++) {
......@@ -1472,7 +1470,7 @@ function InnerArrayFill(value, start, end, array, length) {
}
if ((end - i) > 0 && %object_is_frozen(array)) {
throw MakeTypeError(kArrayFunctionsOnFrozen);
throw %make_type_error(kArrayFunctionsOnFrozen);
}
for (; i < end; i++)
......@@ -1499,7 +1497,7 @@ function ArrayFrom(arrayLike, mapfn, receiver) {
if (mapping) {
if (!IS_CALLABLE(mapfn)) {
throw MakeTypeError(kCalledNonCallable, mapfn);
throw %make_type_error(kCalledNonCallable, mapfn);
}
}
......
......@@ -12,14 +12,12 @@
// Imports
var GlobalArrayBuffer = global.ArrayBuffer;
var MakeTypeError;
var MaxSimple;
var MinSimple;
var SpeciesConstructor;
var speciesSymbol = utils.ImportNow("species_symbol");
utils.Import(function(from) {
MakeTypeError = from.MakeTypeError;
MaxSimple = from.MaxSimple;
MinSimple = from.MinSimple;
SpeciesConstructor = from.SpeciesConstructor;
......@@ -30,7 +28,7 @@ utils.Import(function(from) {
// ES6 Draft 15.13.5.5.3
function ArrayBufferSlice(start, end) {
if (!IS_ARRAYBUFFER(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver,
throw %make_type_error(kIncompatibleMethodReceiver,
'ArrayBuffer.prototype.slice', this);
}
......@@ -60,17 +58,17 @@ function ArrayBufferSlice(start, end) {
var constructor = SpeciesConstructor(this, GlobalArrayBuffer, true);
var result = new constructor(newLen);
if (!IS_ARRAYBUFFER(result)) {
throw MakeTypeError(kIncompatibleMethodReceiver,
throw %make_type_error(kIncompatibleMethodReceiver,
'ArrayBuffer.prototype.slice', result);
}
// Checks for detached source/target ArrayBuffers are done inside of
// %ArrayBufferSliceImpl; the reordering of checks does not violate
// the spec because all exceptions thrown are TypeErrors.
if (result === this) {
throw MakeTypeError(kArrayBufferSpeciesThis);
throw %make_type_error(kArrayBufferSpeciesThis);
}
if (%_ArrayBufferGetByteLength(result) < newLen) {
throw MakeTypeError(kArrayBufferTooShort);
throw %make_type_error(kArrayBufferTooShort);
}
%ArrayBufferSliceImpl(this, result, first, newLen);
......
......@@ -14,15 +14,10 @@
var GlobalMap = global.Map;
var GlobalSet = global.Set;
var iteratorSymbol = utils.ImportNow("iterator_symbol");
var MakeTypeError;
var MapIterator = utils.ImportNow("MapIterator");
var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
var SetIterator = utils.ImportNow("SetIterator");
utils.Import(function(from) {
MakeTypeError = from.MakeTypeError;
});
// -------------------------------------------------------------------
function SetIteratorConstructor(set, kind) {
......@@ -32,7 +27,7 @@ function SetIteratorConstructor(set, kind) {
function SetIteratorNextJS() {
if (!IS_SET_ITERATOR(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver,
throw %make_type_error(kIncompatibleMethodReceiver,
'Set Iterator.prototype.next', this);
}
......@@ -57,7 +52,7 @@ function SetIteratorNextJS() {
function SetEntries() {
if (!IS_SET(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver,
throw %make_type_error(kIncompatibleMethodReceiver,
'Set.prototype.entries', this);
}
return new SetIterator(this, ITERATOR_KIND_ENTRIES);
......@@ -66,7 +61,7 @@ function SetEntries() {
function SetValues() {
if (!IS_SET(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver,
throw %make_type_error(kIncompatibleMethodReceiver,
'Set.prototype.values', this);
}
return new SetIterator(this, ITERATOR_KIND_VALUES);
......@@ -100,7 +95,7 @@ function MapIteratorConstructor(map, kind) {
function MapIteratorNextJS() {
if (!IS_MAP_ITERATOR(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver,
throw %make_type_error(kIncompatibleMethodReceiver,
'Map Iterator.prototype.next', this);
}
......@@ -126,7 +121,7 @@ function MapIteratorNextJS() {
function MapEntries() {
if (!IS_MAP(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver,
throw %make_type_error(kIncompatibleMethodReceiver,
'Map.prototype.entries', this);
}
return new MapIterator(this, ITERATOR_KIND_ENTRIES);
......@@ -135,7 +130,7 @@ function MapEntries() {
function MapKeys() {
if (!IS_MAP(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver,
throw %make_type_error(kIncompatibleMethodReceiver,
'Map.prototype.keys', this);
}
return new MapIterator(this, ITERATOR_KIND_KEYS);
......@@ -144,7 +139,7 @@ function MapKeys() {
function MapValues() {
if (!IS_MAP(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver,
throw %make_type_error(kIncompatibleMethodReceiver,
'Map.prototype.values', this);
}
return new MapIterator(this, ITERATOR_KIND_VALUES);
......
......@@ -15,7 +15,6 @@ var GlobalObject = global.Object;
var GlobalSet = global.Set;
var hashCodeSymbol = utils.ImportNow("hash_code_symbol");
var MathRandom;
var MakeTypeError;
var MapIterator;
var NumberIsNaN;
var SetIterator;
......@@ -24,7 +23,6 @@ var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
utils.Import(function(from) {
MathRandom = from.MathRandom;
MakeTypeError = from.MakeTypeError;
MapIterator = from.MapIterator;
NumberIsNaN = from.NumberIsNaN;
SetIterator = from.SetIterator;
......@@ -127,7 +125,7 @@ function GetHash(key) {
function SetConstructor(iterable) {
if (IS_UNDEFINED(new.target)) {
throw MakeTypeError(kConstructorNotFunction, "Set");
throw %make_type_error(kConstructorNotFunction, "Set");
}
%_SetInitialize(this);
......@@ -135,7 +133,7 @@ function SetConstructor(iterable) {
if (!IS_NULL_OR_UNDEFINED(iterable)) {
var adder = this.add;
if (!IS_CALLABLE(adder)) {
throw MakeTypeError(kPropertyNotFunction, adder, 'add', this);
throw %make_type_error(kPropertyNotFunction, adder, 'add', this);
}
for (var value of iterable) {
......@@ -147,7 +145,7 @@ function SetConstructor(iterable) {
function SetAdd(key) {
if (!IS_SET(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver, 'Set.prototype.add', this);
throw %make_type_error(kIncompatibleMethodReceiver, 'Set.prototype.add', this);
}
// Normalize -0 to +0 as required by the spec.
// Even though we use SameValueZero as the comparison for the keys we don't
......@@ -187,7 +185,7 @@ function SetAdd(key) {
function SetHas(key) {
if (!IS_SET(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver, 'Set.prototype.has', this);
throw %make_type_error(kIncompatibleMethodReceiver, 'Set.prototype.has', this);
}
var table = %_JSCollectionGetTable(this);
var numBuckets = ORDERED_HASH_TABLE_BUCKET_COUNT(table);
......@@ -199,7 +197,7 @@ function SetHas(key) {
function SetDelete(key) {
if (!IS_SET(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver,
throw %make_type_error(kIncompatibleMethodReceiver,
'Set.prototype.delete', this);
}
var table = %_JSCollectionGetTable(this);
......@@ -222,7 +220,7 @@ function SetDelete(key) {
function SetGetSize() {
if (!IS_SET(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver,
throw %make_type_error(kIncompatibleMethodReceiver,
'Set.prototype.size', this);
}
var table = %_JSCollectionGetTable(this);
......@@ -232,7 +230,7 @@ function SetGetSize() {
function SetClearJS() {
if (!IS_SET(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver,
throw %make_type_error(kIncompatibleMethodReceiver,
'Set.prototype.clear', this);
}
%_SetClear(this);
......@@ -241,11 +239,11 @@ function SetClearJS() {
function SetForEach(f, receiver) {
if (!IS_SET(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver,
throw %make_type_error(kIncompatibleMethodReceiver,
'Set.prototype.forEach', this);
}
if (!IS_CALLABLE(f)) throw MakeTypeError(kCalledNonCallable, f);
if (!IS_CALLABLE(f)) throw %make_type_error(kCalledNonCallable, f);
var iterator = new SetIterator(this, ITERATOR_KIND_VALUES);
var key;
......@@ -291,7 +289,7 @@ utils.InstallFunctions(GlobalSet.prototype, DONT_ENUM, [
function MapConstructor(iterable) {
if (IS_UNDEFINED(new.target)) {
throw MakeTypeError(kConstructorNotFunction, "Map");
throw %make_type_error(kConstructorNotFunction, "Map");
}
%_MapInitialize(this);
......@@ -299,12 +297,12 @@ function MapConstructor(iterable) {
if (!IS_NULL_OR_UNDEFINED(iterable)) {
var adder = this.set;
if (!IS_CALLABLE(adder)) {
throw MakeTypeError(kPropertyNotFunction, adder, 'set', this);
throw %make_type_error(kPropertyNotFunction, adder, 'set', this);
}
for (var nextItem of iterable) {
if (!IS_RECEIVER(nextItem)) {
throw MakeTypeError(kIteratorValueNotAnObject, nextItem);
throw %make_type_error(kIteratorValueNotAnObject, nextItem);
}
%_Call(adder, this, nextItem[0], nextItem[1]);
}
......@@ -314,7 +312,7 @@ function MapConstructor(iterable) {
function MapGet(key) {
if (!IS_MAP(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver,
throw %make_type_error(kIncompatibleMethodReceiver,
'Map.prototype.get', this);
}
var table = %_JSCollectionGetTable(this);
......@@ -329,7 +327,7 @@ function MapGet(key) {
function MapSet(key, value) {
if (!IS_MAP(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver,
throw %make_type_error(kIncompatibleMethodReceiver,
'Map.prototype.set', this);
}
// Normalize -0 to +0 as required by the spec.
......@@ -377,7 +375,7 @@ function MapSet(key, value) {
function MapHas(key) {
if (!IS_MAP(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver,
throw %make_type_error(kIncompatibleMethodReceiver,
'Map.prototype.has', this);
}
var table = %_JSCollectionGetTable(this);
......@@ -389,7 +387,7 @@ function MapHas(key) {
function MapDelete(key) {
if (!IS_MAP(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver,
throw %make_type_error(kIncompatibleMethodReceiver,
'Map.prototype.delete', this);
}
var table = %_JSCollectionGetTable(this);
......@@ -412,7 +410,7 @@ function MapDelete(key) {
function MapGetSize() {
if (!IS_MAP(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver,
throw %make_type_error(kIncompatibleMethodReceiver,
'Map.prototype.size', this);
}
var table = %_JSCollectionGetTable(this);
......@@ -422,7 +420,7 @@ function MapGetSize() {
function MapClearJS() {
if (!IS_MAP(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver,
throw %make_type_error(kIncompatibleMethodReceiver,
'Map.prototype.clear', this);
}
%_MapClear(this);
......@@ -431,11 +429,11 @@ function MapClearJS() {
function MapForEach(f, receiver) {
if (!IS_MAP(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver,
throw %make_type_error(kIncompatibleMethodReceiver,
'Map.prototype.forEach', this);
}
if (!IS_CALLABLE(f)) throw MakeTypeError(kCalledNonCallable, f);
if (!IS_CALLABLE(f)) throw %make_type_error(kCalledNonCallable, f);
var iterator = new MapIterator(this, ITERATOR_KIND_ENTRIES);
var value_array = [UNDEFINED, UNDEFINED];
......
......@@ -12,14 +12,10 @@
// Imports
var GlobalObject = global.Object;
var MakeRangeError;
var MakeTypeError;
var MaxSimple;
var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
utils.Import(function(from) {
MakeTypeError = from.MakeTypeError;
MakeRangeError = from.MakeRangeError;
MaxSimple = from.MaxSimple;
});
......@@ -28,14 +24,14 @@ utils.Import(function(from) {
function CheckSharedIntegerTypedArray(ia) {
if (!%IsSharedIntegerTypedArray(ia)) {
throw MakeTypeError(kNotIntegerSharedTypedArray, ia);
throw %make_type_error(kNotIntegerSharedTypedArray, ia);
}
}
function CheckSharedInteger32TypedArray(ia) {
CheckSharedIntegerTypedArray(ia);
if (!%IsSharedInteger32TypedArray(ia)) {
throw MakeTypeError(kNotInt32SharedTypedArray, ia);
throw %make_type_error(kNotInt32SharedTypedArray, ia);
}
}
......@@ -44,10 +40,10 @@ function ValidateIndex(index, length) {
var numberIndex = TO_NUMBER(index);
var accessIndex = TO_INTEGER(numberIndex);
if (numberIndex !== accessIndex) {
throw MakeRangeError(kInvalidAtomicAccessIndex);
throw %make_range_error(kInvalidAtomicAccessIndex);
}
if (accessIndex < 0 || accessIndex >= length) {
throw MakeRangeError(kInvalidAtomicAccessIndex);
throw %make_range_error(kInvalidAtomicAccessIndex);
}
return accessIndex;
}
......
......@@ -12,13 +12,8 @@
// Imports
var GlobalSIMD = global.SIMD;
var MakeTypeError;
var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
utils.Import(function(from) {
MakeTypeError = from.MakeTypeError;
});
// -------------------------------------------------------------------
macro SIMD_FLOAT_TYPES(FUNCTION)
......@@ -64,7 +59,7 @@ function NAMECheckJS(a) {
function NAMEToString() {
var value = %ValueOf(this);
if (typeof(value) !== 'TYPE') {
throw MakeTypeError(kIncompatibleMethodReceiver,
throw %make_type_error(kIncompatibleMethodReceiver,
"NAME.prototype.toString", this);
}
var str = "SIMD.NAME(";
......@@ -78,7 +73,7 @@ function NAMEToString() {
function NAMEToLocaleString() {
var value = %ValueOf(this);
if (typeof(value) !== 'TYPE') {
throw MakeTypeError(kIncompatibleMethodReceiver,
throw %make_type_error(kIncompatibleMethodReceiver,
"NAME.prototype.toLocaleString", this);
}
var str = "SIMD.NAME(";
......@@ -92,7 +87,7 @@ function NAMEToLocaleString() {
function NAMEValueOf() {
var value = %ValueOf(this);
if (typeof(value) !== 'TYPE') {
throw MakeTypeError(kIncompatibleMethodReceiver,
throw %make_type_error(kIncompatibleMethodReceiver,
"NAME.prototype.valueOf", this);
}
return value;
......@@ -434,7 +429,7 @@ SIMD_X16_TYPES(DECLARE_X16_FUNCTIONS)
function Float32x4Constructor(c0, c1, c2, c3) {
if (!IS_UNDEFINED(new.target)) {
throw MakeTypeError(kNotConstructor, "Float32x4");
throw %make_type_error(kNotConstructor, "Float32x4");
}
return %CreateFloat32x4(TO_NUMBER(c0), TO_NUMBER(c1),
TO_NUMBER(c2), TO_NUMBER(c3));
......@@ -443,7 +438,7 @@ function Float32x4Constructor(c0, c1, c2, c3) {
function Int32x4Constructor(c0, c1, c2, c3) {
if (!IS_UNDEFINED(new.target)) {
throw MakeTypeError(kNotConstructor, "Int32x4");
throw %make_type_error(kNotConstructor, "Int32x4");
}
return %CreateInt32x4(TO_NUMBER(c0), TO_NUMBER(c1),
TO_NUMBER(c2), TO_NUMBER(c3));
......@@ -452,7 +447,7 @@ function Int32x4Constructor(c0, c1, c2, c3) {
function Uint32x4Constructor(c0, c1, c2, c3) {
if (!IS_UNDEFINED(new.target)) {
throw MakeTypeError(kNotConstructor, "Uint32x4");
throw %make_type_error(kNotConstructor, "Uint32x4");
}
return %CreateUint32x4(TO_NUMBER(c0), TO_NUMBER(c1),
TO_NUMBER(c2), TO_NUMBER(c3));
......@@ -461,7 +456,7 @@ function Uint32x4Constructor(c0, c1, c2, c3) {
function Bool32x4Constructor(c0, c1, c2, c3) {
if (!IS_UNDEFINED(new.target)) {
throw MakeTypeError(kNotConstructor, "Bool32x4");
throw %make_type_error(kNotConstructor, "Bool32x4");
}
return %CreateBool32x4(c0, c1, c2, c3);
}
......@@ -469,7 +464,7 @@ function Bool32x4Constructor(c0, c1, c2, c3) {
function Int16x8Constructor(c0, c1, c2, c3, c4, c5, c6, c7) {
if (!IS_UNDEFINED(new.target)) {
throw MakeTypeError(kNotConstructor, "Int16x8");
throw %make_type_error(kNotConstructor, "Int16x8");
}
return %CreateInt16x8(TO_NUMBER(c0), TO_NUMBER(c1),
TO_NUMBER(c2), TO_NUMBER(c3),
......@@ -480,7 +475,7 @@ function Int16x8Constructor(c0, c1, c2, c3, c4, c5, c6, c7) {
function Uint16x8Constructor(c0, c1, c2, c3, c4, c5, c6, c7) {
if (!IS_UNDEFINED(new.target)) {
throw MakeTypeError(kNotConstructor, "Uint16x8");
throw %make_type_error(kNotConstructor, "Uint16x8");
}
return %CreateUint16x8(TO_NUMBER(c0), TO_NUMBER(c1),
TO_NUMBER(c2), TO_NUMBER(c3),
......@@ -491,7 +486,7 @@ function Uint16x8Constructor(c0, c1, c2, c3, c4, c5, c6, c7) {
function Bool16x8Constructor(c0, c1, c2, c3, c4, c5, c6, c7) {
if (!IS_UNDEFINED(new.target)) {
throw MakeTypeError(kNotConstructor, "Bool16x8");
throw %make_type_error(kNotConstructor, "Bool16x8");
}
return %CreateBool16x8(c0, c1, c2, c3, c4, c5, c6, c7);
}
......@@ -500,7 +495,7 @@ function Bool16x8Constructor(c0, c1, c2, c3, c4, c5, c6, c7) {
function Int8x16Constructor(c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11,
c12, c13, c14, c15) {
if (!IS_UNDEFINED(new.target)) {
throw MakeTypeError(kNotConstructor, "Int8x16");
throw %make_type_error(kNotConstructor, "Int8x16");
}
return %CreateInt8x16(TO_NUMBER(c0), TO_NUMBER(c1),
TO_NUMBER(c2), TO_NUMBER(c3),
......@@ -516,7 +511,7 @@ function Int8x16Constructor(c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11,
function Uint8x16Constructor(c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11,
c12, c13, c14, c15) {
if (!IS_UNDEFINED(new.target)) {
throw MakeTypeError(kNotConstructor, "Uint8x16");
throw %make_type_error(kNotConstructor, "Uint8x16");
}
return %CreateUint8x16(TO_NUMBER(c0), TO_NUMBER(c1),
TO_NUMBER(c2), TO_NUMBER(c3),
......@@ -532,7 +527,7 @@ function Uint8x16Constructor(c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11,
function Bool8x16Constructor(c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11,
c12, c13, c14, c15) {
if (!IS_UNDEFINED(new.target)) {
throw MakeTypeError(kNotConstructor, "Bool8x16");
throw %make_type_error(kNotConstructor, "Bool8x16");
}
return %CreateBool8x16(c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12,
c13, c14, c15);
......
......@@ -10,11 +10,6 @@
// Imports
var GlobalString = global.String;
var MakeTypeError;
utils.Import(function(from) {
MakeTypeError = from.MakeTypeError;
});
// -------------------------------------------------------------------
// http://tc39.github.io/proposal-string-pad-start-end/
......
......@@ -31,9 +31,6 @@ var InternalArray = utils.InternalArray;
var InternalRegExpMatch;
var InternalRegExpReplace
var IsNaN;
var MakeError;
var MakeRangeError;
var MakeTypeError;
var ObjectHasOwnProperty = utils.ImportNow("ObjectHasOwnProperty");
var OverrideFunction = utils.OverrideFunction;
var patternSymbol = utils.ImportNow("intl_pattern_symbol");
......@@ -49,9 +46,6 @@ utils.Import(function(from) {
ArrayJoin = from.ArrayJoin;
ArrayPush = from.ArrayPush;
IsNaN = from.IsNaN;
MakeError = from.MakeError;
MakeRangeError = from.MakeRangeError;
MakeTypeError = from.MakeTypeError;
InternalRegExpMatch = from.InternalRegExpMatch;
InternalRegExpReplace = from.InternalRegExpReplace;
StringIndexOf = from.StringIndexOf;
......@@ -92,7 +86,7 @@ function AddBoundMethod(obj, methodName, implementation, length, type) {
// associated with all functions returned from AddBoundMethod.
var getter = ANONYMOUS_FUNCTION(function() {
if (!%IsInitializedIntlObjectOfType(this, type)) {
throw MakeTypeError(kMethodCalledOnWrongObject, methodName);
throw %make_type_error(kMethodCalledOnWrongObject, methodName);
}
if (IS_UNDEFINED(this[internalName])) {
var boundMethod;
......@@ -270,7 +264,7 @@ function GetTimezoneNameLocationPartRE() {
*/
function supportedLocalesOf(service, locales, options) {
if (IS_NULL(InternalRegExpMatch(GetServiceRE(), service))) {
throw MakeError(kWrongServiceType, service);
throw %make_error(kWrongServiceType, service);
}
// Provide defaults if matcher was not specified.
......@@ -284,7 +278,7 @@ function supportedLocalesOf(service, locales, options) {
if (!IS_UNDEFINED(matcher)) {
matcher = TO_STRING(matcher);
if (matcher !== 'lookup' && matcher !== 'best fit') {
throw MakeRangeError(kLocaleMatcher, matcher);
throw %make_range_error(kLocaleMatcher, matcher);
}
} else {
matcher = 'best fit';
......@@ -356,7 +350,7 @@ function bestFitSupportedLocalesOf(requestedLocales, availableLocales) {
* is out of range for that property it throws RangeError.
*/
function getGetOption(options, caller) {
if (IS_UNDEFINED(options)) throw MakeError(kDefaultOptionsMissing, caller);
if (IS_UNDEFINED(options)) throw %make_error(kDefaultOptionsMissing, caller);
var getOption = function getOption(property, type, values, defaultValue) {
if (!IS_UNDEFINED(options[property])) {
......@@ -372,11 +366,11 @@ function getGetOption(options, caller) {
value = TO_NUMBER(value);
break;
default:
throw MakeError(kWrongValueType);
throw %make_error(kWrongValueType);
}
if (!IS_UNDEFINED(values) && %_Call(ArrayIndexOf, values, value) === -1) {
throw MakeRangeError(kValueOutOfRange, value, caller, property);
throw %make_range_error(kValueOutOfRange, value, caller, property);
}
return value;
......@@ -425,7 +419,7 @@ function resolveLocale(service, requestedLocales, options) {
*/
function lookupMatcher(service, requestedLocales) {
if (IS_NULL(InternalRegExpMatch(GetServiceRE(), service))) {
throw MakeError(kWrongServiceType, service);
throw %make_error(kWrongServiceType, service);
}
// Cache these, they don't ever change per service.
......@@ -702,7 +696,7 @@ function toTitleCaseWord(word) {
*/
function toTitleCaseTimezoneLocation(location) {
var match = InternalRegExpMatch(GetTimezoneNameLocationPartRE(), location)
if (IS_NULL(match)) throw MakeRangeError(kExpectedLocation, location);
if (IS_NULL(match)) throw %make_range_error(kExpectedLocation, location);
var result = toTitleCaseWord(match[1]);
if (!IS_UNDEFINED(match[2]) && 2 < match.length) {
......@@ -729,7 +723,7 @@ function canonicalizeLanguageTag(localeID) {
// null is typeof 'object' so we have to do extra check.
if ((!IS_STRING(localeID) && !IS_RECEIVER(localeID)) ||
IS_NULL(localeID)) {
throw MakeTypeError(kLanguageID);
throw %make_type_error(kLanguageID);
}
// Optimize for the most common case; a language code alone in
......@@ -742,12 +736,12 @@ function canonicalizeLanguageTag(localeID) {
var localeString = TO_STRING(localeID);
if (isValidLanguageTag(localeString) === false) {
throw MakeRangeError(kInvalidLanguageTag, localeString);
throw %make_range_error(kInvalidLanguageTag, localeString);
}
var tag = %CanonicalizeLanguageTag(localeString);
if (tag === 'invalid-tag') {
throw MakeRangeError(kInvalidLanguageTag, localeString);
throw %make_range_error(kInvalidLanguageTag, localeString);
}
return tag;
......@@ -897,7 +891,7 @@ var resolvedAccessor = {
*/
function initializeCollator(collator, locales, options) {
if (%IsInitializedIntlObject(collator)) {
throw MakeTypeError(kReinitializeIntl, "Collator");
throw %make_type_error(kReinitializeIntl, "Collator");
}
if (IS_UNDEFINED(options)) {
......@@ -1023,11 +1017,11 @@ InstallConstructor(Intl, 'Collator', function() {
*/
InstallFunction(Intl.Collator.prototype, 'resolvedOptions', function() {
if (!IS_UNDEFINED(new.target)) {
throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor);
throw %make_type_error(kOrdinaryFunctionCalledAsConstructor);
}
if (!%IsInitializedIntlObjectOfType(this, 'collator')) {
throw MakeTypeError(kResolvedOptionsCalledOnNonObject, "Collator");
throw %make_type_error(kResolvedOptionsCalledOnNonObject, "Collator");
}
var coll = this;
......@@ -1055,7 +1049,7 @@ InstallFunction(Intl.Collator.prototype, 'resolvedOptions', function() {
*/
InstallFunction(Intl.Collator, 'supportedLocalesOf', function(locales) {
if (!IS_UNDEFINED(new.target)) {
throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor);
throw %make_type_error(kOrdinaryFunctionCalledAsConstructor);
}
return supportedLocalesOf('collator', locales, arguments[1]);
......@@ -1101,7 +1095,7 @@ function getNumberOption(options, property, min, max, fallback) {
if (!IS_UNDEFINED(value)) {
value = TO_NUMBER(value);
if (NUMBER_IS_NAN(value) || value < min || value > max) {
throw MakeRangeError(kPropertyValueOutOfRange, property);
throw %make_range_error(kPropertyValueOutOfRange, property);
}
return %math_floor(value);
}
......@@ -1125,7 +1119,7 @@ var patternAccessor = {
*/
function initializeNumberFormat(numberFormat, locales, options) {
if (%IsInitializedIntlObject(numberFormat)) {
throw MakeTypeError(kReinitializeIntl, "NumberFormat");
throw %make_type_error(kReinitializeIntl, "NumberFormat");
}
if (IS_UNDEFINED(options)) {
......@@ -1142,11 +1136,11 @@ function initializeNumberFormat(numberFormat, locales, options) {
var currency = getOption('currency', 'string');
if (!IS_UNDEFINED(currency) && !isWellFormedCurrencyCode(currency)) {
throw MakeRangeError(kInvalidCurrencyCode, currency);
throw %make_range_error(kInvalidCurrencyCode, currency);
}
if (internalOptions.style === 'currency' && IS_UNDEFINED(currency)) {
throw MakeTypeError(kCurrencyCode);
throw %make_type_error(kCurrencyCode);
}
var currencyDisplay = getOption(
......@@ -1268,11 +1262,11 @@ InstallConstructor(Intl, 'NumberFormat', function() {
*/
InstallFunction(Intl.NumberFormat.prototype, 'resolvedOptions', function() {
if (!IS_UNDEFINED(new.target)) {
throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor);
throw %make_type_error(kOrdinaryFunctionCalledAsConstructor);
}
if (!%IsInitializedIntlObjectOfType(this, 'numberformat')) {
throw MakeTypeError(kResolvedOptionsCalledOnNonObject, "NumberFormat");
throw %make_type_error(kResolvedOptionsCalledOnNonObject, "NumberFormat");
}
var format = this;
......@@ -1318,7 +1312,7 @@ InstallFunction(Intl.NumberFormat.prototype, 'resolvedOptions', function() {
*/
InstallFunction(Intl.NumberFormat, 'supportedLocalesOf', function(locales) {
if (!IS_UNDEFINED(new.target)) {
throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor);
throw %make_type_error(kOrdinaryFunctionCalledAsConstructor);
}
return supportedLocalesOf('numberformat', locales, arguments[1]);
......@@ -1555,7 +1549,7 @@ function toDateTimeOptions(options, required, defaults) {
function initializeDateTimeFormat(dateFormat, locales, options) {
if (%IsInitializedIntlObject(dateFormat)) {
throw MakeTypeError(kReinitializeIntl, "DateTimeFormat");
throw %make_type_error(kReinitializeIntl, "DateTimeFormat");
}
if (IS_UNDEFINED(options)) {
......@@ -1623,7 +1617,7 @@ function initializeDateTimeFormat(dateFormat, locales, options) {
requestedLocale, {skeleton: ldmlString, timeZone: tz}, resolved);
if (resolved.timeZone === "Etc/Unknown") {
throw MakeRangeError(kUnsupportedTimeZone, tz);
throw %make_range_error(kUnsupportedTimeZone, tz);
}
%MarkAsInitializedIntlObjectOfType(dateFormat, 'dateformat', formatter);
......@@ -1662,11 +1656,11 @@ InstallConstructor(Intl, 'DateTimeFormat', function() {
*/
InstallFunction(Intl.DateTimeFormat.prototype, 'resolvedOptions', function() {
if (!IS_UNDEFINED(new.target)) {
throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor);
throw %make_type_error(kOrdinaryFunctionCalledAsConstructor);
}
if (!%IsInitializedIntlObjectOfType(this, 'dateformat')) {
throw MakeTypeError(kResolvedOptionsCalledOnNonObject, "DateTimeFormat");
throw %make_type_error(kResolvedOptionsCalledOnNonObject, "DateTimeFormat");
}
/**
......@@ -1731,7 +1725,7 @@ InstallFunction(Intl.DateTimeFormat.prototype, 'resolvedOptions', function() {
*/
InstallFunction(Intl.DateTimeFormat, 'supportedLocalesOf', function(locales) {
if (!IS_UNDEFINED(new.target)) {
throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor);
throw %make_type_error(kOrdinaryFunctionCalledAsConstructor);
}
return supportedLocalesOf('dateformat', locales, arguments[1]);
......@@ -1752,7 +1746,7 @@ function formatDate(formatter, dateValue) {
dateMs = TO_NUMBER(dateValue);
}
if (!NUMBER_IS_FINITE(dateMs)) throw MakeRangeError(kDateRange);
if (!NUMBER_IS_FINITE(dateMs)) throw %make_range_error(kDateRange);
return %InternalDateFormat(%GetImplFromInitializedIntlObject(formatter),
new GlobalDate(dateMs));
......@@ -1800,7 +1794,7 @@ function canonicalizeTimeZoneID(tzID) {
// We expect only _, '-' and / beside ASCII letters.
// All inputs should conform to Area/Location(/Location)* from now on.
var match = InternalRegExpMatch(GetTimezoneNameCheckRE(), tzID);
if (IS_NULL(match)) throw MakeRangeError(kExpectedTimezoneID, tzID);
if (IS_NULL(match)) throw %make_range_error(kExpectedTimezoneID, tzID);
var result = toTitleCaseTimezoneLocation(match[1]) + '/' +
toTitleCaseTimezoneLocation(match[2]);
......@@ -1822,7 +1816,7 @@ function canonicalizeTimeZoneID(tzID) {
*/
function initializeBreakIterator(iterator, locales, options) {
if (%IsInitializedIntlObject(iterator)) {
throw MakeTypeError(kReinitializeIntl, "v8BreakIterator");
throw %make_type_error(kReinitializeIntl, "v8BreakIterator");
}
if (IS_UNDEFINED(options)) {
......@@ -1884,11 +1878,11 @@ InstallConstructor(Intl, 'v8BreakIterator', function() {
InstallFunction(Intl.v8BreakIterator.prototype, 'resolvedOptions',
function() {
if (!IS_UNDEFINED(new.target)) {
throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor);
throw %make_type_error(kOrdinaryFunctionCalledAsConstructor);
}
if (!%IsInitializedIntlObjectOfType(this, 'breakiterator')) {
throw MakeTypeError(kResolvedOptionsCalledOnNonObject, "v8BreakIterator");
throw %make_type_error(kResolvedOptionsCalledOnNonObject, "v8BreakIterator");
}
var segmenter = this;
......@@ -1913,7 +1907,7 @@ InstallFunction(Intl.v8BreakIterator.prototype, 'resolvedOptions',
InstallFunction(Intl.v8BreakIterator, 'supportedLocalesOf',
function(locales) {
if (!IS_UNDEFINED(new.target)) {
throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor);
throw %make_type_error(kOrdinaryFunctionCalledAsConstructor);
}
return supportedLocalesOf('breakiterator', locales, arguments[1]);
......@@ -2062,11 +2056,11 @@ function LocaleConvertCase(s, locales, isToUpper) {
*/
OverrideFunction(GlobalString.prototype, 'localeCompare', function(that) {
if (!IS_UNDEFINED(new.target)) {
throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor);
throw %make_type_error(kOrdinaryFunctionCalledAsConstructor);
}
if (IS_NULL_OR_UNDEFINED(this)) {
throw MakeTypeError(kMethodInvokedOnNullOrUndefined);
throw %make_type_error(kMethodInvokedOnNullOrUndefined);
}
var locales = arguments[1];
......@@ -2087,7 +2081,7 @@ OverrideFunction(GlobalString.prototype, 'localeCompare', function(that) {
OverrideFunction(GlobalString.prototype, 'normalize', function() {
if (!IS_UNDEFINED(new.target)) {
throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor);
throw %make_type_error(kOrdinaryFunctionCalledAsConstructor);
}
CHECK_OBJECT_COERCIBLE(this, "String.prototype.normalize");
......@@ -2100,7 +2094,7 @@ OverrideFunction(GlobalString.prototype, 'normalize', function() {
var normalizationForm = %_Call(ArrayIndexOf, NORMALIZATION_FORMS, form);
if (normalizationForm === -1) {
throw MakeRangeError(kNormalizationForm,
throw %make_range_error(kNormalizationForm,
%_Call(ArrayJoin, NORMALIZATION_FORMS, ', '));
}
......@@ -2110,7 +2104,7 @@ OverrideFunction(GlobalString.prototype, 'normalize', function() {
function ToLowerCaseI18N() {
if (!IS_UNDEFINED(new.target)) {
throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor);
throw %make_type_error(kOrdinaryFunctionCalledAsConstructor);
}
CHECK_OBJECT_COERCIBLE(this, "String.prototype.toLowerCase");
var s = TO_STRING(this);
......@@ -2119,7 +2113,7 @@ function ToLowerCaseI18N() {
function ToUpperCaseI18N() {
if (!IS_UNDEFINED(new.target)) {
throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor);
throw %make_type_error(kOrdinaryFunctionCalledAsConstructor);
}
CHECK_OBJECT_COERCIBLE(this, "String.prototype.toUpperCase");
var s = TO_STRING(this);
......@@ -2128,7 +2122,7 @@ function ToUpperCaseI18N() {
function ToLocaleLowerCaseI18N(locales) {
if (!IS_UNDEFINED(new.target)) {
throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor);
throw %make_type_error(kOrdinaryFunctionCalledAsConstructor);
}
CHECK_OBJECT_COERCIBLE(this, "String.prototype.toLocaleLowerCase");
return LocaleConvertCase(TO_STRING(this), locales, false);
......@@ -2138,7 +2132,7 @@ function ToLocaleLowerCaseI18N(locales) {
function ToLocaleUpperCaseI18N(locales) {
if (!IS_UNDEFINED(new.target)) {
throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor);
throw %make_type_error(kOrdinaryFunctionCalledAsConstructor);
}
CHECK_OBJECT_COERCIBLE(this, "String.prototype.toLocaleUpperCase");
return LocaleConvertCase(TO_STRING(this), locales, true);
......@@ -2165,11 +2159,11 @@ utils.Export(function(to) {
*/
OverrideFunction(GlobalNumber.prototype, 'toLocaleString', function() {
if (!IS_UNDEFINED(new.target)) {
throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor);
throw %make_type_error(kOrdinaryFunctionCalledAsConstructor);
}
if (!(this instanceof GlobalNumber) && typeof(this) !== 'number') {
throw MakeTypeError(kMethodInvokedOnWrongType, "Number");
throw %make_type_error(kMethodInvokedOnWrongType, "Number");
}
var locales = arguments[0];
......@@ -2185,7 +2179,7 @@ OverrideFunction(GlobalNumber.prototype, 'toLocaleString', function() {
*/
function toLocaleDateTime(date, locales, options, required, defaults, service) {
if (!(date instanceof GlobalDate)) {
throw MakeTypeError(kMethodInvokedOnWrongType, "Date");
throw %make_type_error(kMethodInvokedOnWrongType, "Date");
}
if (IsNaN(date)) return 'Invalid Date';
......@@ -2206,7 +2200,7 @@ function toLocaleDateTime(date, locales, options, required, defaults, service) {
*/
OverrideFunction(GlobalDate.prototype, 'toLocaleString', function() {
if (!IS_UNDEFINED(new.target)) {
throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor);
throw %make_type_error(kOrdinaryFunctionCalledAsConstructor);
}
var locales = arguments[0];
......@@ -2224,7 +2218,7 @@ OverrideFunction(GlobalDate.prototype, 'toLocaleString', function() {
*/
OverrideFunction(GlobalDate.prototype, 'toLocaleDateString', function() {
if (!IS_UNDEFINED(new.target)) {
throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor);
throw %make_type_error(kOrdinaryFunctionCalledAsConstructor);
}
var locales = arguments[0];
......@@ -2242,7 +2236,7 @@ OverrideFunction(GlobalDate.prototype, 'toLocaleDateString', function() {
*/
OverrideFunction(GlobalDate.prototype, 'toLocaleTimeString', function() {
if (!IS_UNDEFINED(new.target)) {
throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor);
throw %make_type_error(kOrdinaryFunctionCalledAsConstructor);
}
var locales = arguments[0];
......
......@@ -84,7 +84,7 @@ macro IS_CALLABLE(arg) = (typeof(arg) === 'function');
# Macro for ES6 CheckObjectCoercible
# Will throw a TypeError of the form "[functionName] called on null or undefined".
macro CHECK_OBJECT_COERCIBLE(arg, functionName) = if (IS_NULL(%IS_VAR(arg)) || IS_UNDEFINED(arg)) throw MakeTypeError(kCalledOnNullOrUndefined, functionName);
macro CHECK_OBJECT_COERCIBLE(arg, functionName) = if (IS_NULL(%IS_VAR(arg)) || IS_UNDEFINED(arg)) throw %make_type_error(kCalledOnNullOrUndefined, functionName);
# Inline macros. Use %IS_VAR to make sure arg is evaluated only once.
macro NUMBER_IS_NAN(arg) = (!%_IsSmi(%IS_VAR(arg)) && !(arg == arg));
......
......@@ -11,15 +11,10 @@
// -------------------------------------------------------------------
// Imports
var MakeGenericError = utils.ImportNow("make_generic_error");
var GlobalError = global.Error;
var GlobalRangeError = global.RangeError;
var GlobalSyntaxError = global.SyntaxError;
var GlobalTypeError = global.TypeError;
var GlobalURIError = global.URIError;
var Script = utils.ImportNow("Script");
// -------------------------------------------------------------------
// Script
/**
* Set up the Script function and constructor.
......@@ -27,40 +22,6 @@ var Script = utils.ImportNow("Script");
%FunctionSetInstanceClassName(Script, 'Script');
%AddNamedProperty(Script.prototype, 'constructor', Script,
DONT_ENUM | DONT_DELETE | READ_ONLY);
%SetCode(Script, function(x) {
// Script objects can only be created by the VM.
throw MakeError(kUnsupported);
});
function GetLineNumber(message) {
var start_position = %MessageGetStartPosition(message);
if (start_position == -1) return kNoLineNumberInfo;
var script = %MessageGetScript(message);
var location = script.locationFromPosition(start_position, true);
if (location == null) return kNoLineNumberInfo;
return location.line + 1;
}
//Returns the offset of the given position within the containing line.
function GetColumnNumber(message) {
var script = %MessageGetScript(message);
var start_position = %MessageGetStartPosition(message);
var location = script.locationFromPosition(start_position, true);
if (location == null) return -1;
return location.column;
}
// Returns the source code line containing the given source
// position, or the empty string if the position is invalid.
function GetSourceLine(message) {
var script = %MessageGetScript(message);
var start_position = %MessageGetStartPosition(message);
var location = script.locationFromPosition(start_position, true);
if (location == null) return "";
return location.sourceText;
}
/**
......@@ -112,43 +73,43 @@ utils.SetUpLockedPrototype(Script, [
]
);
// ----------------------------------------------------------------------------
// Error implementation
// -------------------------------------------------------------------
// Message
function MakeError(type, arg0, arg1, arg2) {
return MakeGenericError(GlobalError, type, arg0, arg1, arg2);
function GetLineNumber(message) {
var start_position = %MessageGetStartPosition(message);
if (start_position == -1) return kNoLineNumberInfo;
var script = %MessageGetScript(message);
var location = script.locationFromPosition(start_position, true);
if (location == null) return kNoLineNumberInfo;
return location.line + 1;
}
function MakeRangeError(type, arg0, arg1, arg2) {
return MakeGenericError(GlobalRangeError, type, arg0, arg1, arg2);
}
function MakeSyntaxError(type, arg0, arg1, arg2) {
return MakeGenericError(GlobalSyntaxError, type, arg0, arg1, arg2);
//Returns the offset of the given position within the containing line.
function GetColumnNumber(message) {
var script = %MessageGetScript(message);
var start_position = %MessageGetStartPosition(message);
var location = script.locationFromPosition(start_position, true);
if (location == null) return -1;
return location.column;
}
function MakeTypeError(type, arg0, arg1, arg2) {
return MakeGenericError(GlobalTypeError, type, arg0, arg1, arg2);
}
function MakeURIError() {
return MakeGenericError(GlobalURIError, kURIMalformed);
// Returns the source code line containing the given source
// position, or the empty string if the position is invalid.
function GetSourceLine(message) {
var script = %MessageGetScript(message);
var start_position = %MessageGetStartPosition(message);
var location = script.locationFromPosition(start_position, true);
if (location == null) return "";
return location.sourceText;
}
%InstallToContext([
"make_range_error", MakeRangeError,
"make_type_error", MakeTypeError,
"message_get_column_number", GetColumnNumber,
"message_get_line_number", GetLineNumber,
"message_get_source_line", GetSourceLine,
]);
utils.Export(function(to) {
to.MakeError = MakeError;
to.MakeRangeError = MakeRangeError;
to.MakeSyntaxError = MakeSyntaxError;
to.MakeTypeError = MakeTypeError;
to.MakeURIError = MakeURIError;
});
});
......@@ -191,9 +191,6 @@ function PostNatives(utils) {
"IntlParseDate",
"IntlParseNumber",
"IsNaN",
"MakeError",
"MakeRangeError",
"MakeTypeError",
"MapEntries",
"MapIterator",
"MapIteratorNext",
......
......@@ -12,7 +12,6 @@
// Imports
var InternalArray = utils.InternalArray;
var MakeTypeError;
var promiseCombinedDeferredSymbol =
utils.ImportNow("promise_combined_deferred_symbol");
var promiseHasHandlerSymbol =
......@@ -31,7 +30,6 @@ var speciesSymbol = utils.ImportNow("species_symbol");
var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
utils.Import(function(from) {
MakeTypeError = from.MakeTypeError;
SpeciesConstructor = from.SpeciesConstructor;
});
......@@ -79,9 +77,9 @@ var GlobalPromise = function Promise(executor) {
if (executor === promiseRawSymbol) {
return %_NewObject(GlobalPromise, new.target);
}
if (IS_UNDEFINED(new.target)) throw MakeTypeError(kNotAPromise, this);
if (IS_UNDEFINED(new.target)) throw %make_type_error(kNotAPromise, this);
if (!IS_CALLABLE(executor)) {
throw MakeTypeError(kResolverNotAFunction, executor);
throw %make_type_error(kResolverNotAFunction, executor);
}
var promise = PromiseInit(%_NewObject(GlobalPromise, new.target));
......@@ -240,7 +238,7 @@ function PromiseCreate() {
// Promise Resolve Functions, steps 6-13
function ResolvePromise(promise, resolution) {
if (resolution === promise) {
return RejectPromise(promise, MakeTypeError(kPromiseCyclic, resolution));
return RejectPromise(promise, %make_type_error(kPromiseCyclic, resolution));
}
if (IS_RECEIVER(resolution)) {
// 25.4.1.3.2 steps 8-12
......@@ -337,13 +335,13 @@ function NewPromiseCapability(C) {
var result = {promise: UNDEFINED, resolve: UNDEFINED, reject: UNDEFINED };
result.promise = new C((resolve, reject) => {
if (!IS_UNDEFINED(result.resolve) || !IS_UNDEFINED(result.reject))
throw MakeTypeError(kPromiseExecutorAlreadyInvoked);
throw %make_type_error(kPromiseExecutorAlreadyInvoked);
result.resolve = resolve;
result.reject = reject;
});
if (!IS_CALLABLE(result.resolve) || !IS_CALLABLE(result.reject))
throw MakeTypeError(kPromiseNonCallable);
throw %make_type_error(kPromiseNonCallable);
return result;
}
......@@ -364,7 +362,7 @@ function PromiseAccept(x) {
// Promise.reject ( x )
function PromiseReject(r) {
if (!IS_RECEIVER(this)) {
throw MakeTypeError(kCalledOnNonObject, PromiseResolve);
throw %make_type_error(kCalledOnNonObject, PromiseResolve);
}
if (this === GlobalPromise) {
// Optimized case, avoid extra closure.
......@@ -437,7 +435,7 @@ function PerformPromiseThen(promise, onResolve, onReject, resultCapability) {
function PromiseThen(onResolve, onReject) {
var status = GET_PRIVATE(this, promiseStateSymbol);
if (IS_UNDEFINED(status)) {
throw MakeTypeError(kNotAPromise, this);
throw %make_type_error(kNotAPromise, this);
}
var constructor = SpeciesConstructor(this, GlobalPromise);
......@@ -464,7 +462,7 @@ function PromiseCatch(onReject) {
// Promise.resolve ( x )
function PromiseResolve(x) {
if (!IS_RECEIVER(this)) {
throw MakeTypeError(kCalledOnNonObject, PromiseResolve);
throw %make_type_error(kCalledOnNonObject, PromiseResolve);
}
if (IsPromise(x) && x.constructor === this) return x;
......@@ -484,7 +482,7 @@ function PromiseResolve(x) {
// Promise.all ( iterable )
function PromiseAll(iterable) {
if (!IS_RECEIVER(this)) {
throw MakeTypeError(kCalledOnNonObject, "Promise.all");
throw %make_type_error(kCalledOnNonObject, "Promise.all");
}
var deferred = NewPromiseCapability(this);
......@@ -535,7 +533,7 @@ function PromiseAll(iterable) {
// Promise.race ( iterable )
function PromiseRace(iterable) {
if (!IS_RECEIVER(this)) {
throw MakeTypeError(kCalledOnNonObject, PromiseRace);
throw %make_type_error(kCalledOnNonObject, PromiseRace);
}
var deferred = NewPromiseCapability(this);
......
......@@ -16,7 +16,6 @@ var GlobalRegExp = global.RegExp;
var GlobalRegExpPrototype;
var InternalArray = utils.InternalArray;
var InternalPackedArray = utils.InternalPackedArray;
var MakeTypeError;
var MaxSimple;
var MinSimple;
var matchSymbol = utils.ImportNow("match_symbol");
......@@ -28,7 +27,6 @@ var SpeciesConstructor;
utils.Import(function(from) {
ExpandReplacement = from.ExpandReplacement;
MakeTypeError = from.MakeTypeError;
MaxSimple = from.MaxSimple;
MinSimple = from.MinSimple;
SpeciesConstructor = from.SpeciesConstructor;
......@@ -114,12 +112,12 @@ function RegExpConstructor(pattern, flags) {
// ES#sec-regexp.prototype.compile RegExp.prototype.compile (pattern, flags)
function RegExpCompileJS(pattern, flags) {
if (!IS_REGEXP(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver,
throw %make_type_error(kIncompatibleMethodReceiver,
"RegExp.prototype.compile", this);
}
if (IS_REGEXP(pattern)) {
if (!IS_UNDEFINED(flags)) throw MakeTypeError(kRegExpFlags);
if (!IS_UNDEFINED(flags)) throw %make_type_error(kRegExpFlags);
flags = PatternFlags(pattern);
pattern = REGEXP_SOURCE(pattern);
......@@ -180,7 +178,7 @@ function RegExpExecNoTests(regexp, string, start) {
// RegExp.prototype.exec ( string )
function RegExpSubclassExecJS(string) {
if (!IS_REGEXP(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver,
throw %make_type_error(kIncompatibleMethodReceiver,
'RegExp.prototype.exec', this);
}
......@@ -226,7 +224,7 @@ function RegExpSubclassExecJS(string) {
// Legacy implementation of RegExp.prototype.exec
function RegExpExecJS(string) {
if (!IS_REGEXP(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver,
throw %make_type_error(kIncompatibleMethodReceiver,
'RegExp.prototype.exec', this);
}
......@@ -273,7 +271,7 @@ function RegExpSubclassExec(regexp, string, exec) {
if (IS_CALLABLE(exec)) {
var result = %_Call(exec, regexp, string);
if (!IS_RECEIVER(result) && !IS_NULL(result)) {
throw MakeTypeError(kInvalidRegExpExecResult);
throw %make_type_error(kInvalidRegExpExecResult);
}
return result;
}
......@@ -293,7 +291,7 @@ var regexp_val;
// else implements.
function RegExpTest(string) {
if (!IS_REGEXP(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver,
throw %make_type_error(kIncompatibleMethodReceiver,
'RegExp.prototype.test', this);
}
string = TO_STRING(string);
......@@ -344,7 +342,7 @@ function RegExpTest(string) {
// ES#sec-regexp.prototype.test RegExp.prototype.test ( S )
function RegExpSubclassTest(string) {
if (!IS_RECEIVER(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver,
throw %make_type_error(kIncompatibleMethodReceiver,
'RegExp.prototype.test', this);
}
string = TO_STRING(string);
......@@ -368,7 +366,7 @@ function TrimRegExp(regexp) {
function RegExpToString() {
if (!IS_RECEIVER(this)) {
throw MakeTypeError(
throw %make_type_error(
kIncompatibleMethodReceiver, 'RegExp.prototype.toString', this);
}
if (this === GlobalRegExpPrototype) {
......@@ -392,7 +390,7 @@ function AtSurrogatePair(subject, index) {
function RegExpSplit(string, limit) {
// TODO(yangguo): allow non-regexp receivers.
if (!IS_REGEXP(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver,
throw %make_type_error(kIncompatibleMethodReceiver,
"RegExp.prototype.@@split", this);
}
var separator = this;
......@@ -466,7 +464,7 @@ function RegExpSplit(string, limit) {
// RegExp.prototype [ @@split ] ( string, limit )
function RegExpSubclassSplit(string, limit) {
if (!IS_RECEIVER(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver,
throw %make_type_error(kIncompatibleMethodReceiver,
"RegExp.prototype.@@split", this);
}
string = TO_STRING(string);
......@@ -542,7 +540,7 @@ function RegExpSubclassSplit(string, limit) {
// RegExp.prototype [ @@match ] ( string )
function RegExpSubclassMatch(string) {
if (!IS_RECEIVER(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver,
throw %make_type_error(kIncompatibleMethodReceiver,
"RegExp.prototype.@@match", this);
}
string = TO_STRING(string);
......@@ -700,7 +698,7 @@ function StringReplaceNonGlobalRegExpWithFunction(subject, regexp, replace) {
function RegExpReplace(string, replace) {
if (!IS_REGEXP(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver,
throw %make_type_error(kIncompatibleMethodReceiver,
"RegExp.prototype.@@replace", this);
}
var subject = TO_STRING(string);
......@@ -856,7 +854,7 @@ function SetAdvancedStringIndex(regexp, string, unicode) {
// RegExp.prototype [ @@replace ] ( string, replaceValue )
function RegExpSubclassReplace(string, replace) {
if (!IS_RECEIVER(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver,
throw %make_type_error(kIncompatibleMethodReceiver,
"RegExp.prototype.@@replace", this);
}
string = TO_STRING(string);
......@@ -941,7 +939,7 @@ function RegExpSubclassReplace(string, replace) {
// RegExp.prototype [ @@search ] ( string )
function RegExpSubclassSearch(string) {
if (!IS_RECEIVER(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver,
throw %make_type_error(kIncompatibleMethodReceiver,
"RegExp.prototype.@@search", this);
}
string = TO_STRING(string);
......@@ -1019,7 +1017,7 @@ function RegExpMakeCaptureGetter(n) {
// ES6 21.2.5.3.
function RegExpGetFlags() {
if (!IS_RECEIVER(this)) {
throw MakeTypeError(
throw %make_type_error(
kRegExpNonObject, "RegExp.prototype.flags", TO_STRING(this));
}
var result = '';
......@@ -1040,7 +1038,7 @@ function RegExpGetGlobal() {
%IncrementUseCounter(kRegExpPrototypeOldFlagGetter);
return UNDEFINED;
}
throw MakeTypeError(kRegExpNonRegExp, "RegExp.prototype.global");
throw %make_type_error(kRegExpNonRegExp, "RegExp.prototype.global");
}
return TO_BOOLEAN(REGEXP_GLOBAL(this));
}
......@@ -1055,7 +1053,7 @@ function RegExpGetIgnoreCase() {
%IncrementUseCounter(kRegExpPrototypeOldFlagGetter);
return UNDEFINED;
}
throw MakeTypeError(kRegExpNonRegExp, "RegExp.prototype.ignoreCase");
throw %make_type_error(kRegExpNonRegExp, "RegExp.prototype.ignoreCase");
}
return TO_BOOLEAN(REGEXP_IGNORE_CASE(this));
}
......@@ -1069,7 +1067,7 @@ function RegExpGetMultiline() {
%IncrementUseCounter(kRegExpPrototypeOldFlagGetter);
return UNDEFINED;
}
throw MakeTypeError(kRegExpNonRegExp, "RegExp.prototype.multiline");
throw %make_type_error(kRegExpNonRegExp, "RegExp.prototype.multiline");
}
return TO_BOOLEAN(REGEXP_MULTILINE(this));
}
......@@ -1083,7 +1081,7 @@ function RegExpGetSource() {
%IncrementUseCounter(kRegExpPrototypeSourceGetter);
return "(?:)";
}
throw MakeTypeError(kRegExpNonRegExp, "RegExp.prototype.source");
throw %make_type_error(kRegExpNonRegExp, "RegExp.prototype.source");
}
return REGEXP_SOURCE(this);
}
......@@ -1098,7 +1096,7 @@ function RegExpGetSticky() {
%IncrementUseCounter(kRegExpPrototypeStickyGetter);
return UNDEFINED;
}
throw MakeTypeError(kRegExpNonRegExp, "RegExp.prototype.sticky");
throw %make_type_error(kRegExpNonRegExp, "RegExp.prototype.sticky");
}
return TO_BOOLEAN(REGEXP_STICKY(this));
}
......@@ -1113,7 +1111,7 @@ function RegExpGetUnicode() {
%IncrementUseCounter(kRegExpPrototypeUnicodeGetter);
return UNDEFINED;
}
throw MakeTypeError(kRegExpNonRegExp, "RegExp.prototype.unicode");
throw %make_type_error(kRegExpNonRegExp, "RegExp.prototype.unicode");
}
return TO_BOOLEAN(REGEXP_UNICODE(this));
}
......
......@@ -19,13 +19,9 @@
var GlobalArray = global.Array;
var GlobalBoolean = global.Boolean;
var GlobalString = global.String;
var MakeRangeError;
var MakeTypeError;
var speciesSymbol;
utils.Import(function(from) {
MakeRangeError = from.MakeRangeError;
MakeTypeError = from.MakeTypeError;
speciesSymbol = from.species_symbol;
});
......@@ -40,7 +36,7 @@ utils.Import(function(from) {
function ToPositiveInteger(x, rangeErrorIndex) {
var i = TO_INTEGER(x) + 0;
if (i < 0) throw MakeRangeError(rangeErrorIndex);
if (i < 0) throw %make_range_error(rangeErrorIndex);
return i;
}
......@@ -66,7 +62,7 @@ function SpeciesConstructor(object, defaultConstructor) {
return defaultConstructor;
}
if (!IS_RECEIVER(constructor)) {
throw MakeTypeError(kConstructorNotReceiver);
throw %make_type_error(kConstructorNotReceiver);
}
var species = constructor[speciesSymbol];
if (IS_NULL_OR_UNDEFINED(species)) {
......@@ -75,7 +71,7 @@ function SpeciesConstructor(object, defaultConstructor) {
if (%IsConstructor(species)) {
return species;
}
throw MakeTypeError(kSpeciesNotConstructor);
throw %make_type_error(kSpeciesNotConstructor);
}
//----------------------------------------------------------------------------
......
......@@ -9,11 +9,6 @@
// -------------------------------------------------------------------
// Imports
var InternalArray = utils.InternalArray;
var MakeTypeError;
utils.Import(function(from) {
MakeTypeError = from.MakeTypeError;
});
// -------------------------------------------------------------------
......@@ -35,7 +30,7 @@ function SpreadArguments() {
function SpreadIterable(collection) {
if (IS_NULL_OR_UNDEFINED(collection)) {
throw MakeTypeError(kNotIterable, collection);
throw %make_type_error(kNotIterable, collection);
}
var args = new InternalArray();
......
......@@ -14,17 +14,12 @@
var GlobalString = global.String;
var IteratorPrototype = utils.ImportNow("IteratorPrototype");
var iteratorSymbol = utils.ImportNow("iterator_symbol");
var MakeTypeError;
var stringIteratorIteratedStringSymbol =
utils.ImportNow("string_iterator_iterated_string_symbol");
var stringIteratorNextIndexSymbol =
utils.ImportNow("string_iterator_next_index_symbol");
var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
utils.Import(function(from) {
MakeTypeError = from.MakeTypeError;
});
// -------------------------------------------------------------------
function StringIterator() {}
......@@ -49,7 +44,7 @@ function StringIteratorNext() {
if (!IS_RECEIVER(iterator) ||
!HAS_DEFINED_PRIVATE(iterator, stringIteratorNextIndexSymbol)) {
throw MakeTypeError(kIncompatibleMethodReceiver,
throw %make_type_error(kIncompatibleMethodReceiver,
'String Iterator.prototype.next');
}
......
......@@ -14,8 +14,6 @@ var ArrayJoin;
var GlobalRegExp = global.RegExp;
var GlobalString = global.String;
var IsRegExp;
var MakeRangeError;
var MakeTypeError;
var MaxSimple;
var MinSimple;
var RegExpInitialize;
......@@ -28,8 +26,6 @@ utils.Import(function(from) {
ArrayIndexOf = from.ArrayIndexOf;
ArrayJoin = from.ArrayJoin;
IsRegExp = from.IsRegExp;
MakeRangeError = from.MakeRangeError;
MakeTypeError = from.MakeTypeError;
MaxSimple = from.MaxSimple;
MinSimple = from.MinSimple;
RegExpInitialize = from.RegExpInitialize;
......@@ -138,7 +134,7 @@ function StringNormalize(formArg) { // length == 0
var NORMALIZATION_FORMS = ['NFC', 'NFD', 'NFKC', 'NFKD'];
var normalizationForm = %_Call(ArrayIndexOf, NORMALIZATION_FORMS, form);
if (normalizationForm === -1) {
throw MakeRangeError(kNormalizationForm,
throw %make_range_error(kNormalizationForm,
%_Call(ArrayJoin, NORMALIZATION_FORMS, ', '));
}
......@@ -583,14 +579,14 @@ function StringRepeat(count) {
var s = TO_STRING(this);
var n = TO_INTEGER(count);
if (n < 0 || n === INFINITY) throw MakeRangeError(kInvalidCountValue);
if (n < 0 || n === INFINITY) throw %make_range_error(kInvalidCountValue);
// Early return to allow an arbitrarily-large repeat of the empty string.
if (s.length === 0) return "";
// The maximum string length is stored in a smi, so a longer repeat
// must result in a range error.
if (n > %_MaxSmi()) throw MakeRangeError(kInvalidCountValue);
if (n > %_MaxSmi()) throw %make_range_error(kInvalidCountValue);
var r = "";
while (true) {
......@@ -609,7 +605,7 @@ function StringStartsWith(searchString, position) { // length == 1
var s = TO_STRING(this);
if (IsRegExp(searchString)) {
throw MakeTypeError(kFirstArgumentNotRegExp, "String.prototype.startsWith");
throw %make_type_error(kFirstArgumentNotRegExp, "String.prototype.startsWith");
}
var ss = TO_STRING(searchString);
......@@ -635,7 +631,7 @@ function StringEndsWith(searchString, position) { // length == 1
var s = TO_STRING(this);
if (IsRegExp(searchString)) {
throw MakeTypeError(kFirstArgumentNotRegExp, "String.prototype.endsWith");
throw %make_type_error(kFirstArgumentNotRegExp, "String.prototype.endsWith");
}
var ss = TO_STRING(searchString);
......@@ -662,7 +658,7 @@ function StringIncludes(searchString, position) { // length == 1
var string = TO_STRING(this);
if (IsRegExp(searchString)) {
throw MakeTypeError(kFirstArgumentNotRegExp, "String.prototype.includes");
throw %make_type_error(kFirstArgumentNotRegExp, "String.prototype.includes");
}
searchString = TO_STRING(searchString);
......
......@@ -16,7 +16,6 @@ var hasInstanceSymbol = utils.ImportNow("has_instance_symbol");
var isConcatSpreadableSymbol =
utils.ImportNow("is_concat_spreadable_symbol");
var iteratorSymbol = utils.ImportNow("iterator_symbol");
var MakeTypeError;
var matchSymbol = utils.ImportNow("match_symbol");
var replaceSymbol = utils.ImportNow("replace_symbol");
var searchSymbol = utils.ImportNow("search_symbol");
......@@ -26,10 +25,6 @@ var toPrimitiveSymbol = utils.ImportNow("to_primitive_symbol");
var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
var unscopablesSymbol = utils.ImportNow("unscopables_symbol");
utils.Import(function(from) {
MakeTypeError = from.MakeTypeError;
});
// -------------------------------------------------------------------
function SymbolFor(key) {
......@@ -45,7 +40,7 @@ function SymbolFor(key) {
function SymbolKeyFor(symbol) {
if (!IS_SYMBOL(symbol)) throw MakeTypeError(kSymbolKeyFor, symbol);
if (!IS_SYMBOL(symbol)) throw %make_type_error(kSymbolKeyFor, symbol);
return %SymbolRegistry().keyFor[symbol];
}
......
......@@ -38,8 +38,6 @@ var InnerArraySort;
var InnerArrayToLocaleString;
var InternalArray = utils.InternalArray;
var IsNaN;
var MakeRangeError;
var MakeTypeError;
var MaxSimple;
var MinSimple;
var PackedArrayReverse;
......@@ -90,8 +88,6 @@ utils.Import(function(from) {
InnerArraySort = from.InnerArraySort;
InnerArrayToLocaleString = from.InnerArrayToLocaleString;
IsNaN = from.IsNaN;
MakeRangeError = from.MakeRangeError;
MakeTypeError = from.MakeTypeError;
MaxSimple = from.MaxSimple;
MinSimple = from.MinSimple;
PackedArrayReverse = from.PackedArrayReverse;
......@@ -111,7 +107,7 @@ TYPED_ARRAYS(TYPED_ARRAY_CONSTRUCTOR_CASE)
}
// The TypeError should not be generated since all callers should
// have already called ValidateTypedArray.
throw MakeTypeError(kIncompatibleMethodReceiver,
throw %make_type_error(kIncompatibleMethodReceiver,
"TypedArrayDefaultConstructor", this);
}
......@@ -121,12 +117,12 @@ function TypedArrayCreate(constructor, arg0, arg1, arg2) {
} else {
var newTypedArray = new constructor(arg0, arg1, arg2);
}
if (!IS_TYPEDARRAY(newTypedArray)) throw MakeTypeError(kNotTypedArray);
if (!IS_TYPEDARRAY(newTypedArray)) throw %make_type_error(kNotTypedArray);
// TODO(littledan): Check for being detached, here and elsewhere
// All callers where the first argument is a Number have no additional
// arguments.
if (IS_NUMBER(arg0) && %_TypedArrayGetLength(newTypedArray) < arg0) {
throw MakeTypeError(kTypedArrayTooShort);
throw %make_type_error(kTypedArrayTooShort);
}
return newTypedArray;
}
......@@ -155,11 +151,11 @@ function NAMEConstructByArrayBuffer(obj, buffer, byteOffset, length) {
offset = byteOffset;
if (offset % ELEMENT_SIZE !== 0) {
throw MakeRangeError(kInvalidTypedArrayAlignment,
throw %make_range_error(kInvalidTypedArrayAlignment,
"start offset", "NAME", ELEMENT_SIZE);
}
if (offset > bufferByteLength) {
throw MakeRangeError(kInvalidTypedArrayOffset);
throw %make_range_error(kInvalidTypedArrayOffset);
}
}
......@@ -167,7 +163,7 @@ function NAMEConstructByArrayBuffer(obj, buffer, byteOffset, length) {
var newLength;
if (IS_UNDEFINED(length)) {
if (bufferByteLength % ELEMENT_SIZE !== 0) {
throw MakeRangeError(kInvalidTypedArrayAlignment,
throw %make_range_error(kInvalidTypedArrayAlignment,
"byte length", "NAME", ELEMENT_SIZE);
}
newByteLength = bufferByteLength - offset;
......@@ -178,7 +174,7 @@ function NAMEConstructByArrayBuffer(obj, buffer, byteOffset, length) {
}
if ((offset + newByteLength > bufferByteLength)
|| (newLength > %_MaxSmi())) {
throw MakeRangeError(kInvalidTypedArrayLength);
throw %make_range_error(kInvalidTypedArrayLength);
}
%_TypedArrayInitialize(obj, ARRAY_ID, buffer, offset, newByteLength, true);
}
......@@ -187,7 +183,7 @@ function NAMEConstructByLength(obj, length) {
var l = IS_UNDEFINED(length) ?
0 : ToPositiveInteger(length, kInvalidTypedArrayLength);
if (l > %_MaxSmi()) {
throw MakeRangeError(kInvalidTypedArrayLength);
throw %make_range_error(kInvalidTypedArrayLength);
}
var byteLength = l * ELEMENT_SIZE;
if (byteLength > %_TypedArrayMaxSizeInHeap()) {
......@@ -202,7 +198,7 @@ function NAMEConstructByArrayLike(obj, arrayLike, length) {
var l = ToPositiveInteger(length, kInvalidTypedArrayLength);
if (l > %_MaxSmi()) {
throw MakeRangeError(kInvalidTypedArrayLength);
throw %make_range_error(kInvalidTypedArrayLength);
}
var initialized = false;
var byteLength = l * ELEMENT_SIZE;
......@@ -275,7 +271,7 @@ function NAMEConstructor(arg1, arg2, arg3) {
}
}
} else {
throw MakeTypeError(kConstructorNotFunction, "NAME")
throw %make_type_error(kConstructorNotFunction, "NAME")
}
}
......@@ -325,7 +321,7 @@ macro TYPED_ARRAY_SUBARRAY_CASE(ARRAY_ID, NAME, ELEMENT_SIZE)
endmacro
TYPED_ARRAYS(TYPED_ARRAY_SUBARRAY_CASE)
}
throw MakeTypeError(kIncompatibleMethodReceiver,
throw %make_type_error(kIncompatibleMethodReceiver,
"get TypedArray.prototype.subarray", this);
}
%SetForceInlineFlag(TypedArraySubArray);
......@@ -399,10 +395,10 @@ function TypedArraySetFromOverlappingTypedArray(target, source, offset) {
function TypedArraySet(obj, offset) {
var intOffset = IS_UNDEFINED(offset) ? 0 : TO_INTEGER(offset);
if (intOffset < 0) throw MakeTypeError(kTypedArraySetNegativeOffset);
if (intOffset < 0) throw %make_type_error(kTypedArraySetNegativeOffset);
if (intOffset > %_MaxSmi()) {
throw MakeRangeError(kTypedArraySetSourceTooLarge);
throw %make_range_error(kTypedArraySetSourceTooLarge);
}
switch (%TypedArraySetFastCases(this, obj, intOffset)) {
// These numbers should be synchronized with runtime.cc.
......@@ -423,13 +419,13 @@ function TypedArraySet(obj, offset) {
// instead of silently ignoring the call, so that
// the user knows (s)he did something wrong.
// (Consistent with Firefox and Blink/WebKit)
throw MakeTypeError(kInvalidArgument);
throw %make_type_error(kInvalidArgument);
}
return;
}
l = TO_LENGTH(l);
if (intOffset + l > %_TypedArrayGetLength(this)) {
throw MakeRangeError(kTypedArraySetSourceTooLarge);
throw %make_range_error(kTypedArraySetSourceTooLarge);
}
TypedArraySetFromArrayLike(this, obj, l, intOffset);
return;
......@@ -446,7 +442,7 @@ function TypedArrayGetToStringTag() {
function TypedArrayCopyWithin(target, start, end) {
if (!IS_TYPEDARRAY(this)) throw MakeTypeError(kNotTypedArray);
if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray);
var length = %_TypedArrayGetLength(this);
......@@ -458,7 +454,7 @@ function TypedArrayCopyWithin(target, start, end) {
// ES6 draft 05-05-15, section 22.2.3.7
function TypedArrayEvery(f, receiver) {
if (!IS_TYPEDARRAY(this)) throw MakeTypeError(kNotTypedArray);
if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray);
var length = %_TypedArrayGetLength(this);
......@@ -469,7 +465,7 @@ function TypedArrayEvery(f, receiver) {
// ES6 draft 08-24-14, section 22.2.3.12
function TypedArrayForEach(f, receiver) {
if (!IS_TYPEDARRAY(this)) throw MakeTypeError(kNotTypedArray);
if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray);
var length = %_TypedArrayGetLength(this);
......@@ -480,7 +476,7 @@ function TypedArrayForEach(f, receiver) {
// ES6 draft 04-05-14 section 22.2.3.8
function TypedArrayFill(value, start, end) {
if (!IS_TYPEDARRAY(this)) throw MakeTypeError(kNotTypedArray);
if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray);
var length = %_TypedArrayGetLength(this);
......@@ -491,10 +487,10 @@ function TypedArrayFill(value, start, end) {
// ES6 draft 07-15-13, section 22.2.3.9
function TypedArrayFilter(f, thisArg) {
if (!IS_TYPEDARRAY(this)) throw MakeTypeError(kNotTypedArray);
if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray);
var length = %_TypedArrayGetLength(this);
if (!IS_CALLABLE(f)) throw MakeTypeError(kCalledNonCallable, f);
if (!IS_CALLABLE(f)) throw %make_type_error(kCalledNonCallable, f);
var result = new InternalArray();
InnerArrayFilter(f, thisArg, this, length, result);
var captured = result.length;
......@@ -509,7 +505,7 @@ function TypedArrayFilter(f, thisArg) {
// ES6 draft 07-15-13, section 22.2.3.10
function TypedArrayFind(predicate, thisArg) {
if (!IS_TYPEDARRAY(this)) throw MakeTypeError(kNotTypedArray);
if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray);
var length = %_TypedArrayGetLength(this);
......@@ -520,7 +516,7 @@ function TypedArrayFind(predicate, thisArg) {
// ES6 draft 07-15-13, section 22.2.3.11
function TypedArrayFindIndex(predicate, thisArg) {
if (!IS_TYPEDARRAY(this)) throw MakeTypeError(kNotTypedArray);
if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray);
var length = %_TypedArrayGetLength(this);
......@@ -531,7 +527,7 @@ function TypedArrayFindIndex(predicate, thisArg) {
// ES6 draft 05-18-15, section 22.2.3.21
function TypedArrayReverse() {
if (!IS_TYPEDARRAY(this)) throw MakeTypeError(kNotTypedArray);
if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray);
var length = %_TypedArrayGetLength(this);
......@@ -559,7 +555,7 @@ function TypedArrayComparefn(x, y) {
// ES6 draft 05-18-15, section 22.2.3.25
function TypedArraySort(comparefn) {
if (!IS_TYPEDARRAY(this)) throw MakeTypeError(kNotTypedArray);
if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray);
var length = %_TypedArrayGetLength(this);
......@@ -573,7 +569,7 @@ function TypedArraySort(comparefn) {
// ES6 section 22.2.3.13
function TypedArrayIndexOf(element, index) {
if (!IS_TYPEDARRAY(this)) throw MakeTypeError(kNotTypedArray);
if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray);
var length = %_TypedArrayGetLength(this);
return InnerArrayIndexOf(this, element, index, length);
......@@ -583,7 +579,7 @@ function TypedArrayIndexOf(element, index) {
// ES6 section 22.2.3.16
function TypedArrayLastIndexOf(element, index) {
if (!IS_TYPEDARRAY(this)) throw MakeTypeError(kNotTypedArray);
if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray);
var length = %_TypedArrayGetLength(this);
......@@ -595,11 +591,11 @@ function TypedArrayLastIndexOf(element, index) {
// ES6 draft 07-15-13, section 22.2.3.18
function TypedArrayMap(f, thisArg) {
if (!IS_TYPEDARRAY(this)) throw MakeTypeError(kNotTypedArray);
if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray);
var length = %_TypedArrayGetLength(this);
var result = TypedArraySpeciesCreate(this, length);
if (!IS_CALLABLE(f)) throw MakeTypeError(kCalledNonCallable, f);
if (!IS_CALLABLE(f)) throw %make_type_error(kCalledNonCallable, f);
for (var i = 0; i < length; i++) {
var element = this[i];
result[i] = %_Call(f, thisArg, element, i, this);
......@@ -611,7 +607,7 @@ function TypedArrayMap(f, thisArg) {
// ES6 draft 05-05-15, section 22.2.3.24
function TypedArraySome(f, receiver) {
if (!IS_TYPEDARRAY(this)) throw MakeTypeError(kNotTypedArray);
if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray);
var length = %_TypedArrayGetLength(this);
......@@ -622,7 +618,7 @@ function TypedArraySome(f, receiver) {
// ES6 section 22.2.3.27
function TypedArrayToLocaleString() {
if (!IS_TYPEDARRAY(this)) throw MakeTypeError(kNotTypedArray);
if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray);
var length = %_TypedArrayGetLength(this);
......@@ -632,7 +628,7 @@ function TypedArrayToLocaleString() {
// ES6 section 22.2.3.14
function TypedArrayJoin(separator) {
if (!IS_TYPEDARRAY(this)) throw MakeTypeError(kNotTypedArray);
if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray);
var length = %_TypedArrayGetLength(this);
......@@ -642,7 +638,7 @@ function TypedArrayJoin(separator) {
// ES6 draft 07-15-13, section 22.2.3.19
function TypedArrayReduce(callback, current) {
if (!IS_TYPEDARRAY(this)) throw MakeTypeError(kNotTypedArray);
if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray);
var length = %_TypedArrayGetLength(this);
return InnerArrayReduce(callback, current, this, length,
......@@ -653,7 +649,7 @@ function TypedArrayReduce(callback, current) {
// ES6 draft 07-15-13, section 22.2.3.19
function TypedArrayReduceRight(callback, current) {
if (!IS_TYPEDARRAY(this)) throw MakeTypeError(kNotTypedArray);
if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray);
var length = %_TypedArrayGetLength(this);
return InnerArrayReduceRight(callback, current, this, length,
......@@ -663,7 +659,7 @@ function TypedArrayReduceRight(callback, current) {
function TypedArraySlice(start, end) {
if (!IS_TYPEDARRAY(this)) throw MakeTypeError(kNotTypedArray);
if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray);
var len = %_TypedArrayGetLength(this);
var relativeStart = TO_INTEGER(start);
......@@ -707,7 +703,7 @@ function TypedArraySlice(start, end) {
// ES2016 draft, section 22.2.3.14
function TypedArrayIncludes(searchElement, fromIndex) {
if (!IS_TYPEDARRAY(this)) throw MakeTypeError(kNotTypedArray);
if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray);
var length = %_TypedArrayGetLength(this);
......@@ -771,10 +767,10 @@ function IterableToArrayLike(items) {
// ES#sec-%typedarray%.from
// %TypedArray%.from ( source [ , mapfn [ , thisArg ] ] )
function TypedArrayFrom(source, mapfn, thisArg) {
if (!%IsConstructor(this)) throw MakeTypeError(kNotConstructor, this);
if (!%IsConstructor(this)) throw %make_type_error(kNotConstructor, this);
var mapping;
if (!IS_UNDEFINED(mapfn)) {
if (!IS_CALLABLE(mapfn)) throw MakeTypeError(kCalledNonCallable, this);
if (!IS_CALLABLE(mapfn)) throw %make_type_error(kCalledNonCallable, this);
mapping = true;
} else {
mapping = false;
......@@ -799,10 +795,10 @@ function TypedArrayFrom(source, mapfn, thisArg) {
// TODO(bmeurer): Migrate this to a proper builtin.
function TypedArrayConstructor() {
if (IS_UNDEFINED(new.target)) {
throw MakeTypeError(kConstructorNonCallable, "TypedArray");
throw %make_type_error(kConstructorNonCallable, "TypedArray");
}
if (new.target === GlobalTypedArray) {
throw MakeTypeError(kConstructAbstractClass, "TypedArray");
throw %make_type_error(kConstructAbstractClass, "TypedArray");
}
}
......@@ -883,10 +879,10 @@ endmacro
macro DATA_VIEW_GETTER_SETTER(TYPENAME)
function DataViewGetTYPENAMEJS(offset, little_endian) {
if (!IS_DATAVIEW(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver,
throw %make_type_error(kIncompatibleMethodReceiver,
'DataView.getTYPENAME', this);
}
if (arguments.length < 1) throw MakeTypeError(kInvalidArgument);
if (arguments.length < 1) throw %make_type_error(kInvalidArgument);
offset = ToPositiveInteger(offset, kInvalidDataViewAccessorOffset);
return %DataViewGetTYPENAME(this, offset, !!little_endian);
}
......@@ -894,10 +890,10 @@ function DataViewGetTYPENAMEJS(offset, little_endian) {
function DataViewSetTYPENAMEJS(offset, value, little_endian) {
if (!IS_DATAVIEW(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver,
throw %make_type_error(kIncompatibleMethodReceiver,
'DataView.setTYPENAME', this);
}
if (arguments.length < 2) throw MakeTypeError(kInvalidArgument);
if (arguments.length < 2) throw %make_type_error(kInvalidArgument);
offset = ToPositiveInteger(offset, kInvalidDataViewAccessorOffset);
%DataViewSetTYPENAME(this, offset, TO_NUMBER(value), !!little_endian);
}
......
......@@ -12,18 +12,9 @@
var GlobalNumber = global.Number;
var GlobalObject = global.Object;
var iteratorSymbol = utils.ImportNow("iterator_symbol");
var MakeRangeError;
var MakeSyntaxError;
var MakeTypeError;
var NaN = %GetRootNaN();
var ObjectToString = utils.ImportNow("object_to_string");
utils.Import(function(from) {
MakeRangeError = from.MakeRangeError;
MakeSyntaxError = from.MakeSyntaxError;
MakeTypeError = from.MakeTypeError;
});
// ----------------------------------------------------------------------------
......@@ -136,7 +127,7 @@ function GetMethod(obj, p) {
var func = obj[p];
if (IS_NULL_OR_UNDEFINED(func)) return UNDEFINED;
if (IS_CALLABLE(func)) return func;
throw MakeTypeError(kCalledNonCallable, typeof func);
throw %make_type_error(kCalledNonCallable, typeof func);
}
// ES6 section 19.1.2.18.
......@@ -144,7 +135,7 @@ function ObjectSetPrototypeOf(obj, proto) {
CHECK_OBJECT_COERCIBLE(obj, "Object.setPrototypeOf");
if (proto !== null && !IS_RECEIVER(proto)) {
throw MakeTypeError(kProtoObjectOrNull, proto);
throw %make_type_error(kProtoObjectOrNull, proto);
}
if (IS_RECEIVER(obj)) {
......@@ -289,11 +280,11 @@ function GetIterator(obj, method) {
method = obj[iteratorSymbol];
}
if (!IS_CALLABLE(method)) {
throw MakeTypeError(kNotIterable, obj);
throw %make_type_error(kNotIterable, obj);
}
var iterator = %_Call(method, obj);
if (!IS_RECEIVER(iterator)) {
throw MakeTypeError(kNotAnIterator, iterator);
throw %make_type_error(kNotAnIterator, iterator);
}
return iterator;
}
......
......@@ -16,13 +16,11 @@ var GetHash;
var GlobalObject = global.Object;
var GlobalWeakMap = global.WeakMap;
var GlobalWeakSet = global.WeakSet;
var MakeTypeError;
var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
utils.Import(function(from) {
GetExistingHash = from.GetExistingHash;
GetHash = from.GetHash;
MakeTypeError = from.MakeTypeError;
});
// -------------------------------------------------------------------
......@@ -30,7 +28,7 @@ utils.Import(function(from) {
function WeakMapConstructor(iterable) {
if (IS_UNDEFINED(new.target)) {
throw MakeTypeError(kConstructorNotFunction, "WeakMap");
throw %make_type_error(kConstructorNotFunction, "WeakMap");
}
%WeakCollectionInitialize(this);
......@@ -38,11 +36,11 @@ function WeakMapConstructor(iterable) {
if (!IS_NULL_OR_UNDEFINED(iterable)) {
var adder = this.set;
if (!IS_CALLABLE(adder)) {
throw MakeTypeError(kPropertyNotFunction, adder, 'set', this);
throw %make_type_error(kPropertyNotFunction, adder, 'set', this);
}
for (var nextItem of iterable) {
if (!IS_RECEIVER(nextItem)) {
throw MakeTypeError(kIteratorValueNotAnObject, nextItem);
throw %make_type_error(kIteratorValueNotAnObject, nextItem);
}
%_Call(adder, this, nextItem[0], nextItem[1]);
}
......@@ -52,7 +50,7 @@ function WeakMapConstructor(iterable) {
function WeakMapGet(key) {
if (!IS_WEAKMAP(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver,
throw %make_type_error(kIncompatibleMethodReceiver,
'WeakMap.prototype.get', this);
}
if (!IS_RECEIVER(key)) return UNDEFINED;
......@@ -64,17 +62,17 @@ function WeakMapGet(key) {
function WeakMapSet(key, value) {
if (!IS_WEAKMAP(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver,
throw %make_type_error(kIncompatibleMethodReceiver,
'WeakMap.prototype.set', this);
}
if (!IS_RECEIVER(key)) throw MakeTypeError(kInvalidWeakMapKey);
if (!IS_RECEIVER(key)) throw %make_type_error(kInvalidWeakMapKey);
return %WeakCollectionSet(this, key, value, GetHash(key));
}
function WeakMapHas(key) {
if (!IS_WEAKMAP(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver,
throw %make_type_error(kIncompatibleMethodReceiver,
'WeakMap.prototype.has', this);
}
if (!IS_RECEIVER(key)) return false;
......@@ -86,7 +84,7 @@ function WeakMapHas(key) {
function WeakMapDelete(key) {
if (!IS_WEAKMAP(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver,
throw %make_type_error(kIncompatibleMethodReceiver,
'WeakMap.prototype.delete', this);
}
if (!IS_RECEIVER(key)) return false;
......@@ -119,7 +117,7 @@ utils.InstallFunctions(GlobalWeakMap.prototype, DONT_ENUM, [
function WeakSetConstructor(iterable) {
if (IS_UNDEFINED(new.target)) {
throw MakeTypeError(kConstructorNotFunction, "WeakSet");
throw %make_type_error(kConstructorNotFunction, "WeakSet");
}
%WeakCollectionInitialize(this);
......@@ -127,7 +125,7 @@ function WeakSetConstructor(iterable) {
if (!IS_NULL_OR_UNDEFINED(iterable)) {
var adder = this.add;
if (!IS_CALLABLE(adder)) {
throw MakeTypeError(kPropertyNotFunction, adder, 'add', this);
throw %make_type_error(kPropertyNotFunction, adder, 'add', this);
}
for (var value of iterable) {
%_Call(adder, this, value);
......@@ -138,17 +136,17 @@ function WeakSetConstructor(iterable) {
function WeakSetAdd(value) {
if (!IS_WEAKSET(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver,
throw %make_type_error(kIncompatibleMethodReceiver,
'WeakSet.prototype.add', this);
}
if (!IS_RECEIVER(value)) throw MakeTypeError(kInvalidWeakSetValue);
if (!IS_RECEIVER(value)) throw %make_type_error(kInvalidWeakSetValue);
return %WeakCollectionSet(this, value, true, GetHash(value));
}
function WeakSetHas(value) {
if (!IS_WEAKSET(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver,
throw %make_type_error(kIncompatibleMethodReceiver,
'WeakSet.prototype.has', this);
}
if (!IS_RECEIVER(value)) return false;
......@@ -160,7 +158,7 @@ function WeakSetHas(value) {
function WeakSetDelete(value) {
if (!IS_WEAKSET(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver,
throw %make_type_error(kIncompatibleMethodReceiver,
'WeakSet.prototype.delete', this);
}
if (!IS_RECEIVER(value)) return false;
......
......@@ -80,7 +80,7 @@ bytecodes: [
/* 15 S> */ B(LdrUndefined), R(0),
B(CreateArrayLiteral), U8(0), U8(0), U8(3),
B(Star), R(1),
B(CallJSRuntime), U8(131), R(0), U8(2),
B(CallJSRuntime), U8(134), R(0), U8(2),
/* 44 S> */ B(Return),
]
constant pool: [
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment