Commit d881baac authored by machenbach's avatar machenbach Committed by Commit bot

Revert of Migrate error messages, part 2. (patchset #1 id:1 of...

Revert of Migrate error messages, part 2. (patchset #1 id:1 of https://codereview.chromium.org/1086313003/)

Reason for revert:
[Sheriff]: This changes layout test expectations e.g.
http://build.chromium.org/p/client.v8/builders/V8-Blink%20Win/builds/2964

Original issue's description:
> Migrate error messages, part 2.
>
> Motivation for this is reducing the size of the native context.
>
> Committed: https://crrev.com/d3b788df0a4ccfedbe6e1df5e214cb6ba2792a65
> Cr-Commit-Position: refs/heads/master@{#27878}

TBR=mvstanton@chromium.org,yangguo@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true

Review URL: https://codereview.chromium.org/1095573002

Cr-Commit-Position: refs/heads/master@{#27889}
parent 2dc0f2ec
...@@ -73,8 +73,8 @@ function ArrayIteratorNext() { ...@@ -73,8 +73,8 @@ function ArrayIteratorNext() {
var iterator = ToObject(this); var iterator = ToObject(this);
if (!HAS_DEFINED_PRIVATE(iterator, arrayIteratorNextIndexSymbol)) { if (!HAS_DEFINED_PRIVATE(iterator, arrayIteratorNextIndexSymbol)) {
throw MakeTypeError(kIncompatibleMethodReceiver, throw MakeTypeError('incompatible_method_receiver',
'Array Iterator.prototype.next', this); ['Array Iterator.prototype.next']);
} }
var array = GET_PRIVATE(iterator, arrayIteratorObjectSymbol); var array = GET_PRIVATE(iterator, arrayIteratorObjectSymbol);
......
...@@ -1142,7 +1142,9 @@ function ArrayFilter(f, receiver) { ...@@ -1142,7 +1142,9 @@ function ArrayFilter(f, receiver) {
var array = ToObject(this); var array = ToObject(this);
var length = ToUint32(array.length); var length = ToUint32(array.length);
if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f); if (!IS_SPEC_FUNCTION(f)) {
throw MakeTypeError('called_non_callable', [ f ]);
}
var needs_wrapper = false; var needs_wrapper = false;
if (IS_NULL_OR_UNDEFINED(receiver)) { if (IS_NULL_OR_UNDEFINED(receiver)) {
receiver = %GetDefaultReceiver(f) || receiver; receiver = %GetDefaultReceiver(f) || receiver;
...@@ -1179,7 +1181,9 @@ function ArrayForEach(f, receiver) { ...@@ -1179,7 +1181,9 @@ function ArrayForEach(f, receiver) {
var array = ToObject(this); var array = ToObject(this);
var length = TO_UINT32(array.length); var length = TO_UINT32(array.length);
if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f); if (!IS_SPEC_FUNCTION(f)) {
throw MakeTypeError('called_non_callable', [ f ]);
}
var needs_wrapper = false; var needs_wrapper = false;
if (IS_NULL_OR_UNDEFINED(receiver)) { if (IS_NULL_OR_UNDEFINED(receiver)) {
receiver = %GetDefaultReceiver(f) || receiver; receiver = %GetDefaultReceiver(f) || receiver;
...@@ -1211,7 +1215,9 @@ function ArraySome(f, receiver) { ...@@ -1211,7 +1215,9 @@ function ArraySome(f, receiver) {
var array = ToObject(this); var array = ToObject(this);
var length = TO_UINT32(array.length); var length = TO_UINT32(array.length);
if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f); if (!IS_SPEC_FUNCTION(f)) {
throw MakeTypeError('called_non_callable', [ f ]);
}
var needs_wrapper = false; var needs_wrapper = false;
if (IS_NULL_OR_UNDEFINED(receiver)) { if (IS_NULL_OR_UNDEFINED(receiver)) {
receiver = %GetDefaultReceiver(f) || receiver; receiver = %GetDefaultReceiver(f) || receiver;
...@@ -1242,7 +1248,9 @@ function ArrayEvery(f, receiver) { ...@@ -1242,7 +1248,9 @@ function ArrayEvery(f, receiver) {
var array = ToObject(this); var array = ToObject(this);
var length = TO_UINT32(array.length); var length = TO_UINT32(array.length);
if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f); if (!IS_SPEC_FUNCTION(f)) {
throw MakeTypeError('called_non_callable', [ f ]);
}
var needs_wrapper = false; var needs_wrapper = false;
if (IS_NULL_OR_UNDEFINED(receiver)) { if (IS_NULL_OR_UNDEFINED(receiver)) {
receiver = %GetDefaultReceiver(f) || receiver; receiver = %GetDefaultReceiver(f) || receiver;
...@@ -1272,7 +1280,9 @@ function ArrayMap(f, receiver) { ...@@ -1272,7 +1280,9 @@ function ArrayMap(f, receiver) {
var array = ToObject(this); var array = ToObject(this);
var length = TO_UINT32(array.length); var length = TO_UINT32(array.length);
if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f); if (!IS_SPEC_FUNCTION(f)) {
throw MakeTypeError('called_non_callable', [ f ]);
}
var needs_wrapper = false; var needs_wrapper = false;
if (IS_NULL_OR_UNDEFINED(receiver)) { if (IS_NULL_OR_UNDEFINED(receiver)) {
receiver = %GetDefaultReceiver(f) || receiver; receiver = %GetDefaultReceiver(f) || receiver;
...@@ -1417,7 +1427,7 @@ function ArrayReduce(callback, current) { ...@@ -1417,7 +1427,7 @@ function ArrayReduce(callback, current) {
var length = ToUint32(array.length); var length = ToUint32(array.length);
if (!IS_SPEC_FUNCTION(callback)) { if (!IS_SPEC_FUNCTION(callback)) {
throw MakeTypeError(kCalledNonCallable, callback); throw MakeTypeError('called_non_callable', [callback]);
} }
var is_array = IS_ARRAY(array); var is_array = IS_ARRAY(array);
...@@ -1454,7 +1464,7 @@ function ArrayReduceRight(callback, current) { ...@@ -1454,7 +1464,7 @@ function ArrayReduceRight(callback, current) {
var length = ToUint32(array.length); var length = ToUint32(array.length);
if (!IS_SPEC_FUNCTION(callback)) { if (!IS_SPEC_FUNCTION(callback)) {
throw MakeTypeError(kCalledNonCallable, callback); throw MakeTypeError('called_non_callable', [callback]);
} }
var is_array = IS_ARRAY(array); var is_array = IS_ARRAY(array);
......
...@@ -24,8 +24,8 @@ function ArrayBufferConstructor(length) { // length = 1 ...@@ -24,8 +24,8 @@ function ArrayBufferConstructor(length) { // length = 1
function ArrayBufferGetByteLen() { function ArrayBufferGetByteLen() {
if (!IS_ARRAYBUFFER(this)) { if (!IS_ARRAYBUFFER(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver, throw MakeTypeError('incompatible_method_receiver',
'ArrayBuffer.prototype.byteLength', this); ['ArrayBuffer.prototype.byteLength', this]);
} }
return %_ArrayBufferGetByteLength(this); return %_ArrayBufferGetByteLength(this);
} }
...@@ -33,8 +33,8 @@ function ArrayBufferGetByteLen() { ...@@ -33,8 +33,8 @@ function ArrayBufferGetByteLen() {
// ES6 Draft 15.13.5.5.3 // ES6 Draft 15.13.5.5.3
function ArrayBufferSlice(start, end) { function ArrayBufferSlice(start, end) {
if (!IS_ARRAYBUFFER(this)) { if (!IS_ARRAYBUFFER(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver, throw MakeTypeError('incompatible_method_receiver',
'ArrayBuffer.prototype.slice', this); ['ArrayBuffer.prototype.slice', this]);
} }
var relativeStart = TO_INTEGER(start); var relativeStart = TO_INTEGER(start);
......
...@@ -26,8 +26,8 @@ function SetIteratorConstructor(set, kind) { ...@@ -26,8 +26,8 @@ function SetIteratorConstructor(set, kind) {
function SetIteratorNextJS() { function SetIteratorNextJS() {
if (!IS_SET_ITERATOR(this)) { if (!IS_SET_ITERATOR(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver, throw MakeTypeError('incompatible_method_receiver',
'Set Iterator.prototype.next', this); ['Set Iterator.prototype.next', this]);
} }
var value_array = [UNDEFINED, UNDEFINED]; var value_array = [UNDEFINED, UNDEFINED];
...@@ -56,8 +56,8 @@ function SetIteratorSymbolIterator() { ...@@ -56,8 +56,8 @@ function SetIteratorSymbolIterator() {
function SetEntries() { function SetEntries() {
if (!IS_SET(this)) { if (!IS_SET(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver, throw MakeTypeError('incompatible_method_receiver',
'Set.prototype.entries', this); ['Set.prototype.entries', this]);
} }
return new SetIterator(this, ITERATOR_KIND_ENTRIES); return new SetIterator(this, ITERATOR_KIND_ENTRIES);
} }
...@@ -65,8 +65,8 @@ function SetEntries() { ...@@ -65,8 +65,8 @@ function SetEntries() {
function SetValues() { function SetValues() {
if (!IS_SET(this)) { if (!IS_SET(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver, throw MakeTypeError('incompatible_method_receiver',
'Set.prototype.values', this); ['Set.prototype.values', this]);
} }
return new SetIterator(this, ITERATOR_KIND_VALUES); return new SetIterator(this, ITERATOR_KIND_VALUES);
} }
...@@ -111,8 +111,8 @@ function MapIteratorSymbolIterator() { ...@@ -111,8 +111,8 @@ function MapIteratorSymbolIterator() {
function MapIteratorNextJS() { function MapIteratorNextJS() {
if (!IS_MAP_ITERATOR(this)) { if (!IS_MAP_ITERATOR(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver, throw MakeTypeError('incompatible_method_receiver',
'Map Iterator.prototype.next', this); ['Map Iterator.prototype.next', this]);
} }
var value_array = [UNDEFINED, UNDEFINED]; var value_array = [UNDEFINED, UNDEFINED];
...@@ -137,8 +137,8 @@ function MapIteratorNextJS() { ...@@ -137,8 +137,8 @@ function MapIteratorNextJS() {
function MapEntries() { function MapEntries() {
if (!IS_MAP(this)) { if (!IS_MAP(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver, throw MakeTypeError('incompatible_method_receiver',
'Map.prototype.entries', this); ['Map.prototype.entries', this]);
} }
return new MapIterator(this, ITERATOR_KIND_ENTRIES); return new MapIterator(this, ITERATOR_KIND_ENTRIES);
} }
...@@ -146,8 +146,8 @@ function MapEntries() { ...@@ -146,8 +146,8 @@ function MapEntries() {
function MapKeys() { function MapKeys() {
if (!IS_MAP(this)) { if (!IS_MAP(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver, throw MakeTypeError('incompatible_method_receiver',
'Map.prototype.keys', this); ['Map.prototype.keys', this]);
} }
return new MapIterator(this, ITERATOR_KIND_KEYS); return new MapIterator(this, ITERATOR_KIND_KEYS);
} }
...@@ -155,8 +155,8 @@ function MapKeys() { ...@@ -155,8 +155,8 @@ function MapKeys() {
function MapValues() { function MapValues() {
if (!IS_MAP(this)) { if (!IS_MAP(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver, throw MakeTypeError('incompatible_method_receiver',
'Map.prototype.values', this); ['Map.prototype.values', this]);
} }
return new MapIterator(this, ITERATOR_KIND_VALUES); return new MapIterator(this, ITERATOR_KIND_VALUES);
} }
......
...@@ -99,7 +99,7 @@ function SetConstructor(iterable) { ...@@ -99,7 +99,7 @@ function SetConstructor(iterable) {
if (!IS_NULL_OR_UNDEFINED(iterable)) { if (!IS_NULL_OR_UNDEFINED(iterable)) {
var adder = this.add; var adder = this.add;
if (!IS_SPEC_FUNCTION(adder)) { if (!IS_SPEC_FUNCTION(adder)) {
throw MakeTypeError(kPropertyNotFunction, 'add', this); throw MakeTypeError(kPropertyNotFunction, ['add', this]);
} }
for (var value of iterable) { for (var value of iterable) {
...@@ -111,7 +111,8 @@ function SetConstructor(iterable) { ...@@ -111,7 +111,8 @@ function SetConstructor(iterable) {
function SetAdd(key) { function SetAdd(key) {
if (!IS_SET(this)) { if (!IS_SET(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver, 'Set.prototype.add', this); throw MakeTypeError('incompatible_method_receiver',
['Set.prototype.add', this]);
} }
// Normalize -0 to +0 as required by the spec. // Normalize -0 to +0 as required by the spec.
// Even though we use SameValueZero as the comparison for the keys we don't // Even though we use SameValueZero as the comparison for the keys we don't
...@@ -151,7 +152,8 @@ function SetAdd(key) { ...@@ -151,7 +152,8 @@ function SetAdd(key) {
function SetHas(key) { function SetHas(key) {
if (!IS_SET(this)) { if (!IS_SET(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver, 'Set.prototype.has', this); throw MakeTypeError('incompatible_method_receiver',
['Set.prototype.has', this]);
} }
var table = %_JSCollectionGetTable(this); var table = %_JSCollectionGetTable(this);
var numBuckets = ORDERED_HASH_TABLE_BUCKET_COUNT(table); var numBuckets = ORDERED_HASH_TABLE_BUCKET_COUNT(table);
...@@ -162,8 +164,8 @@ function SetHas(key) { ...@@ -162,8 +164,8 @@ function SetHas(key) {
function SetDelete(key) { function SetDelete(key) {
if (!IS_SET(this)) { if (!IS_SET(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver, throw MakeTypeError('incompatible_method_receiver',
'Set.prototype.delete', this); ['Set.prototype.delete', this]);
} }
var table = %_JSCollectionGetTable(this); var table = %_JSCollectionGetTable(this);
var numBuckets = ORDERED_HASH_TABLE_BUCKET_COUNT(table); var numBuckets = ORDERED_HASH_TABLE_BUCKET_COUNT(table);
...@@ -184,8 +186,8 @@ function SetDelete(key) { ...@@ -184,8 +186,8 @@ function SetDelete(key) {
function SetGetSize() { function SetGetSize() {
if (!IS_SET(this)) { if (!IS_SET(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver, throw MakeTypeError('incompatible_method_receiver',
'Set.prototype.size', this); ['Set.prototype.size', this]);
} }
var table = %_JSCollectionGetTable(this); var table = %_JSCollectionGetTable(this);
return ORDERED_HASH_TABLE_ELEMENT_COUNT(table); return ORDERED_HASH_TABLE_ELEMENT_COUNT(table);
...@@ -194,8 +196,8 @@ function SetGetSize() { ...@@ -194,8 +196,8 @@ function SetGetSize() {
function SetClearJS() { function SetClearJS() {
if (!IS_SET(this)) { if (!IS_SET(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver, throw MakeTypeError('incompatible_method_receiver',
'Set.prototype.clear', this); ['Set.prototype.clear', this]);
} }
%_SetClear(this); %_SetClear(this);
} }
...@@ -203,11 +205,13 @@ function SetClearJS() { ...@@ -203,11 +205,13 @@ function SetClearJS() {
function SetForEach(f, receiver) { function SetForEach(f, receiver) {
if (!IS_SET(this)) { if (!IS_SET(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver, throw MakeTypeError('incompatible_method_receiver',
'Set.prototype.forEach', this); ['Set.prototype.forEach', this]);
} }
if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f); if (!IS_SPEC_FUNCTION(f)) {
throw MakeTypeError('called_non_callable', [f]);
}
var needs_wrapper = false; var needs_wrapper = false;
if (IS_NULL_OR_UNDEFINED(receiver)) { if (IS_NULL_OR_UNDEFINED(receiver)) {
receiver = %GetDefaultReceiver(f) || receiver; receiver = %GetDefaultReceiver(f) || receiver;
...@@ -262,7 +266,7 @@ function MapConstructor(iterable) { ...@@ -262,7 +266,7 @@ function MapConstructor(iterable) {
if (!IS_NULL_OR_UNDEFINED(iterable)) { if (!IS_NULL_OR_UNDEFINED(iterable)) {
var adder = this.set; var adder = this.set;
if (!IS_SPEC_FUNCTION(adder)) { if (!IS_SPEC_FUNCTION(adder)) {
throw MakeTypeError(kPropertyNotFunction, 'set', this); throw MakeTypeError(kPropertyNotFunction, ['set', this]);
} }
for (var nextItem of iterable) { for (var nextItem of iterable) {
...@@ -277,8 +281,8 @@ function MapConstructor(iterable) { ...@@ -277,8 +281,8 @@ function MapConstructor(iterable) {
function MapGet(key) { function MapGet(key) {
if (!IS_MAP(this)) { if (!IS_MAP(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver, throw MakeTypeError('incompatible_method_receiver',
'Map.prototype.get', this); ['Map.prototype.get', this]);
} }
var table = %_JSCollectionGetTable(this); var table = %_JSCollectionGetTable(this);
var numBuckets = ORDERED_HASH_TABLE_BUCKET_COUNT(table); var numBuckets = ORDERED_HASH_TABLE_BUCKET_COUNT(table);
...@@ -291,8 +295,8 @@ function MapGet(key) { ...@@ -291,8 +295,8 @@ function MapGet(key) {
function MapSet(key, value) { function MapSet(key, value) {
if (!IS_MAP(this)) { if (!IS_MAP(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver, throw MakeTypeError('incompatible_method_receiver',
'Map.prototype.set', this); ['Map.prototype.set', this]);
} }
// Normalize -0 to +0 as required by the spec. // Normalize -0 to +0 as required by the spec.
// Even though we use SameValueZero as the comparison for the keys we don't // Even though we use SameValueZero as the comparison for the keys we don't
...@@ -339,8 +343,8 @@ function MapSet(key, value) { ...@@ -339,8 +343,8 @@ function MapSet(key, value) {
function MapHas(key) { function MapHas(key) {
if (!IS_MAP(this)) { if (!IS_MAP(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver, throw MakeTypeError('incompatible_method_receiver',
'Map.prototype.has', this); ['Map.prototype.has', this]);
} }
var table = %_JSCollectionGetTable(this); var table = %_JSCollectionGetTable(this);
var numBuckets = ORDERED_HASH_TABLE_BUCKET_COUNT(table); var numBuckets = ORDERED_HASH_TABLE_BUCKET_COUNT(table);
...@@ -351,8 +355,8 @@ function MapHas(key) { ...@@ -351,8 +355,8 @@ function MapHas(key) {
function MapDelete(key) { function MapDelete(key) {
if (!IS_MAP(this)) { if (!IS_MAP(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver, throw MakeTypeError('incompatible_method_receiver',
'Map.prototype.delete', this); ['Map.prototype.delete', this]);
} }
var table = %_JSCollectionGetTable(this); var table = %_JSCollectionGetTable(this);
var numBuckets = ORDERED_HASH_TABLE_BUCKET_COUNT(table); var numBuckets = ORDERED_HASH_TABLE_BUCKET_COUNT(table);
...@@ -374,8 +378,8 @@ function MapDelete(key) { ...@@ -374,8 +378,8 @@ function MapDelete(key) {
function MapGetSize() { function MapGetSize() {
if (!IS_MAP(this)) { if (!IS_MAP(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver, throw MakeTypeError('incompatible_method_receiver',
'Map.prototype.size', this); ['Map.prototype.size', this]);
} }
var table = %_JSCollectionGetTable(this); var table = %_JSCollectionGetTable(this);
return ORDERED_HASH_TABLE_ELEMENT_COUNT(table); return ORDERED_HASH_TABLE_ELEMENT_COUNT(table);
...@@ -384,8 +388,8 @@ function MapGetSize() { ...@@ -384,8 +388,8 @@ function MapGetSize() {
function MapClearJS() { function MapClearJS() {
if (!IS_MAP(this)) { if (!IS_MAP(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver, throw MakeTypeError('incompatible_method_receiver',
'Map.prototype.clear', this); ['Map.prototype.clear', this]);
} }
%_MapClear(this); %_MapClear(this);
} }
...@@ -393,11 +397,13 @@ function MapClearJS() { ...@@ -393,11 +397,13 @@ function MapClearJS() {
function MapForEach(f, receiver) { function MapForEach(f, receiver) {
if (!IS_MAP(this)) { if (!IS_MAP(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver, throw MakeTypeError('incompatible_method_receiver',
'Map.prototype.forEach', this); ['Map.prototype.forEach', this]);
} }
if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f); if (!IS_SPEC_FUNCTION(f)) {
throw MakeTypeError('called_non_callable', [f]);
}
var needs_wrapper = false; var needs_wrapper = false;
if (IS_NULL_OR_UNDEFINED(receiver)) { if (IS_NULL_OR_UNDEFINED(receiver)) {
receiver = %GetDefaultReceiver(f) || receiver; receiver = %GetDefaultReceiver(f) || receiver;
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#include "src/codegen.h" #include "src/codegen.h"
#include "src/deoptimizer.h" #include "src/deoptimizer.h"
#include "src/isolate-inl.h" #include "src/isolate-inl.h"
#include "src/messages.h"
#include "src/vm-state-inl.h" #include "src/vm-state-inl.h"
namespace v8 { namespace v8 {
...@@ -280,8 +279,8 @@ MaybeHandle<Object> Execution::TryGetFunctionDelegate(Isolate* isolate, ...@@ -280,8 +279,8 @@ MaybeHandle<Object> Execution::TryGetFunctionDelegate(Isolate* isolate,
// If the Object doesn't have an instance-call handler we should // If the Object doesn't have an instance-call handler we should
// throw a non-callable exception. // throw a non-callable exception.
THROW_NEW_ERROR(isolate, THROW_NEW_ERROR(isolate, NewTypeError("called_non_callable",
NewTypeError(MessageTemplate::kCalledNonCallable, object), i::HandleVector<i::Object>(&object, 1)),
Object); Object);
} }
...@@ -336,8 +335,8 @@ MaybeHandle<Object> Execution::TryGetConstructorDelegate( ...@@ -336,8 +335,8 @@ MaybeHandle<Object> Execution::TryGetConstructorDelegate(
// If the Object doesn't have an instance-call handler we should // If the Object doesn't have an instance-call handler we should
// throw a non-callable exception. // throw a non-callable exception.
THROW_NEW_ERROR(isolate, THROW_NEW_ERROR(isolate, NewTypeError("called_non_callable",
NewTypeError(MessageTemplate::kCalledNonCallable, object), i::HandleVector<i::Object>(&object, 1)),
Object); Object);
} }
......
...@@ -1080,6 +1080,13 @@ Handle<Object> Factory::NewTypeError(const char* message, ...@@ -1080,6 +1080,13 @@ Handle<Object> Factory::NewTypeError(const char* message,
} }
Handle<Object> Factory::NewTypeError(MessageTemplate::Template template_index,
Handle<Object> arg0, Handle<Object> arg1,
Handle<Object> arg2) {
return NewError("MakeTypeError2", template_index, arg0, arg1, arg2);
}
Handle<Object> Factory::NewTypeError(Handle<String> message) { Handle<Object> Factory::NewTypeError(Handle<String> message) {
return NewError("$TypeError", message); return NewError("$TypeError", message);
} }
...@@ -1177,24 +1184,9 @@ Handle<Object> Factory::NewEvalError(const char* message, ...@@ -1177,24 +1184,9 @@ Handle<Object> Factory::NewEvalError(const char* message,
} }
Handle<Object> Factory::NewError(MessageTemplate::Template template_index, Handle<Object> Factory::NewError(const char* message,
Handle<Object> arg0, Handle<Object> arg1, Vector<Handle<Object> > args) {
Handle<Object> arg2) { return NewError("MakeError", message, args);
return NewError("MakeError", template_index, arg0, arg1, arg2);
}
Handle<Object> Factory::NewTypeError(MessageTemplate::Template template_index,
Handle<Object> arg0, Handle<Object> arg1,
Handle<Object> arg2) {
return NewError("MakeTypeError", template_index, arg0, arg1, arg2);
}
Handle<Object> Factory::NewEvalError(MessageTemplate::Template template_index,
Handle<Object> arg0, Handle<Object> arg1,
Handle<Object> arg2) {
return NewError("MakeEvalError", template_index, arg0, arg1, arg2);
} }
......
...@@ -537,12 +537,20 @@ class Factory FINAL { ...@@ -537,12 +537,20 @@ class Factory FINAL {
Handle<Object> NewError(const char* maker, const char* message, Handle<Object> NewError(const char* maker, const char* message,
Vector<Handle<Object> > args); Vector<Handle<Object> > args);
Handle<Object> NewError(const char* message, Vector<Handle<Object> > args); Handle<Object> NewError(const char* message, Vector<Handle<Object> > args);
Handle<Object> NewError(const char* maker,
MessageTemplate::Template template_index,
Handle<Object> arg0, Handle<Object> arg1,
Handle<Object> arg2);
Handle<Object> NewError(Handle<String> message); Handle<Object> NewError(Handle<String> message);
Handle<Object> NewError(const char* constructor, Handle<String> message); Handle<Object> NewError(const char* constructor, Handle<String> message);
Handle<Object> NewTypeError(const char* message, Handle<Object> NewTypeError(const char* message,
Vector<Handle<Object> > args); Vector<Handle<Object> > args);
Handle<Object> NewTypeError(MessageTemplate::Template template_index,
Handle<Object> arg0 = Handle<Object>(),
Handle<Object> arg1 = Handle<Object>(),
Handle<Object> arg2 = Handle<Object>());
Handle<Object> NewTypeError(Handle<String> message); Handle<Object> NewTypeError(Handle<String> message);
Handle<Object> NewRangeError(const char* message, Handle<Object> NewRangeError(const char* message,
...@@ -565,26 +573,6 @@ class Factory FINAL { ...@@ -565,26 +573,6 @@ class Factory FINAL {
Handle<Object> NewEvalError(const char* message, Handle<Object> NewEvalError(const char* message,
Vector<Handle<Object> > args); Vector<Handle<Object> > args);
Handle<Object> NewError(const char* maker,
MessageTemplate::Template template_index,
Handle<Object> arg0, Handle<Object> arg1,
Handle<Object> arg2);
Handle<Object> NewError(MessageTemplate::Template template_index,
Handle<Object> arg0 = Handle<Object>(),
Handle<Object> arg1 = Handle<Object>(),
Handle<Object> arg2 = Handle<Object>());
Handle<Object> NewTypeError(MessageTemplate::Template template_index,
Handle<Object> arg0 = Handle<Object>(),
Handle<Object> arg1 = Handle<Object>(),
Handle<Object> arg2 = Handle<Object>());
Handle<Object> NewEvalError(MessageTemplate::Template template_index,
Handle<Object> arg0 = Handle<Object>(),
Handle<Object> arg1 = Handle<Object>(),
Handle<Object> arg2 = Handle<Object>());
Handle<String> NumberToString(Handle<Object> number, Handle<String> NumberToString(Handle<Object> number,
bool check_number_string_cache = true); bool check_number_string_cache = true);
......
...@@ -16,8 +16,8 @@ ...@@ -16,8 +16,8 @@
function GeneratorObjectNext(value) { function GeneratorObjectNext(value) {
if (!IS_GENERATOR(this)) { if (!IS_GENERATOR(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver, throw MakeTypeError('incompatible_method_receiver',
'[Generator].prototype.next', this); ['[Generator].prototype.next', this]);
} }
var continuation = %GeneratorGetContinuation(this); var continuation = %GeneratorGetContinuation(this);
...@@ -35,14 +35,14 @@ function GeneratorObjectNext(value) { ...@@ -35,14 +35,14 @@ function GeneratorObjectNext(value) {
return { value: void 0, done: true }; return { value: void 0, done: true };
} else { } else {
// Generator is running. // Generator is running.
throw MakeTypeError(kGeneratorRunning); throw MakeTypeError('generator_running', []);
} }
} }
function GeneratorObjectThrow(exn) { function GeneratorObjectThrow(exn) {
if (!IS_GENERATOR(this)) { if (!IS_GENERATOR(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver, throw MakeTypeError('incompatible_method_receiver',
'[Generator].prototype.throw', this); ['[Generator].prototype.throw', this]);
} }
var continuation = %GeneratorGetContinuation(this); var continuation = %GeneratorGetContinuation(this);
...@@ -59,7 +59,7 @@ function GeneratorObjectThrow(exn) { ...@@ -59,7 +59,7 @@ function GeneratorObjectThrow(exn) {
throw exn; throw exn;
} else { } else {
// Generator is running. // Generator is running.
throw MakeTypeError(kGeneratorRunning); throw MakeTypeError('generator_running', []);
} }
} }
......
...@@ -18,7 +18,7 @@ function ArrayFind(predicate /* thisArg */) { // length == 1 ...@@ -18,7 +18,7 @@ function ArrayFind(predicate /* thisArg */) { // length == 1
var length = ToInteger(array.length); var length = ToInteger(array.length);
if (!IS_SPEC_FUNCTION(predicate)) { if (!IS_SPEC_FUNCTION(predicate)) {
throw MakeTypeError(kCalledNonCallable, predicate); throw MakeTypeError('called_non_callable', [predicate]);
} }
var thisArg; var thisArg;
...@@ -55,7 +55,7 @@ function ArrayFindIndex(predicate /* thisArg */) { // length == 1 ...@@ -55,7 +55,7 @@ function ArrayFindIndex(predicate /* thisArg */) { // length == 1
var length = ToInteger(array.length); var length = ToInteger(array.length);
if (!IS_SPEC_FUNCTION(predicate)) { if (!IS_SPEC_FUNCTION(predicate)) {
throw MakeTypeError(kCalledNonCallable, predicate); throw MakeTypeError('called_non_callable', [predicate]);
} }
var thisArg; var thisArg;
...@@ -134,7 +134,7 @@ function ArrayFrom(arrayLike, mapfn, receiver) { ...@@ -134,7 +134,7 @@ function ArrayFrom(arrayLike, mapfn, receiver) {
if (mapping) { if (mapping) {
if (!IS_SPEC_FUNCTION(mapfn)) { if (!IS_SPEC_FUNCTION(mapfn)) {
throw MakeTypeError(kCalledNonCallable, mapfn); throw MakeTypeError('called_non_callable', [ mapfn ]);
} else if (IS_NULL_OR_UNDEFINED(receiver)) { } else if (IS_NULL_OR_UNDEFINED(receiver)) {
receiver = %GetDefaultReceiver(mapfn) || receiver; receiver = %GetDefaultReceiver(mapfn) || receiver;
} else if (!IS_SPEC_OBJECT(receiver) && %IsSloppyModeFunction(mapfn)) { } else if (!IS_SPEC_OBJECT(receiver) && %IsSloppyModeFunction(mapfn)) {
......
...@@ -31,7 +31,9 @@ function NAMEForEach(f /* thisArg */) { // length == 1 ...@@ -31,7 +31,9 @@ function NAMEForEach(f /* thisArg */) { // length == 1
if (!%IsTypedArray(this)) { if (!%IsTypedArray(this)) {
throw MakeTypeError('not_typed_array', []); throw MakeTypeError('not_typed_array', []);
} }
if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f); if (!IS_SPEC_FUNCTION(f)) {
throw MakeTypeError('called_non_callable', [ f ]);
}
var length = %_TypedArrayGetLength(this); var length = %_TypedArrayGetLength(this);
var receiver; var receiver;
......
...@@ -88,17 +88,9 @@ class MessageHandler { ...@@ -88,17 +88,9 @@ class MessageHandler {
}; };
#define MESSAGE_TEMPLATES(T) \ #define MESSAGE_TEMPLATES(T) \
/* Error */ \ T(PropertyNotFunction, "Property '%' of object % is not a function") \
T(CyclicProto, "Cyclic __proto__ value") \ T(WithExpression, "% has no properties")
/* TypeError */ \
T(CalledNonCallable, "% is not a function") \
T(GeneratorRunning, "Generator is already running") \
T(IncompatibleMethodReceiver, "Method % called on incompatible receiver %") \
T(PropertyNotFunction, "Property '%' of object % is not a function") \
T(WithExpression, "% has no properties") \
/* EvalError */ \
T(CodeGenFromStrings, "%")
class MessageTemplate { class MessageTemplate {
public: public:
......
...@@ -6,9 +6,12 @@ ...@@ -6,9 +6,12 @@
var kMessages = { var kMessages = {
// Error // Error
cyclic_proto: ["Cyclic __proto__ value"],
code_gen_from_strings: ["%0"],
constructor_is_generator: ["Class constructor may not be a generator"], constructor_is_generator: ["Class constructor may not be a generator"],
constructor_is_accessor: ["Class constructor may not be an accessor"], constructor_is_accessor: ["Class constructor may not be an accessor"],
// TypeError // TypeError
generator_running: ["Generator is already running"],
unexpected_token: ["Unexpected token ", "%0"], unexpected_token: ["Unexpected token ", "%0"],
unexpected_token_number: ["Unexpected number"], unexpected_token_number: ["Unexpected number"],
unexpected_token_string: ["Unexpected string"], unexpected_token_string: ["Unexpected string"],
...@@ -24,6 +27,7 @@ var kMessages = { ...@@ -24,6 +27,7 @@ var kMessages = {
unterminated_template_expr: ["Missing } in template expression"], unterminated_template_expr: ["Missing } in template expression"],
unterminated_arg_list: ["missing ) after argument list"], unterminated_arg_list: ["missing ) after argument list"],
regexp_flags: ["Cannot supply flags when constructing one RegExp from another"], regexp_flags: ["Cannot supply flags when constructing one RegExp from another"],
incompatible_method_receiver: ["Method ", "%0", " called on incompatible receiver ", "%1"],
multiple_defaults_in_switch: ["More than one default clause in switch statement"], multiple_defaults_in_switch: ["More than one default clause in switch statement"],
newline_after_throw: ["Illegal newline after throw"], newline_after_throw: ["Illegal newline after throw"],
label_redeclaration: ["Label '", "%0", "' has already been declared"], label_redeclaration: ["Label '", "%0", "' has already been declared"],
...@@ -32,6 +36,8 @@ var kMessages = { ...@@ -32,6 +36,8 @@ var kMessages = {
no_catch_or_finally: ["Missing catch or finally after try"], no_catch_or_finally: ["Missing catch or finally after try"],
unknown_label: ["Undefined label '", "%0", "'"], unknown_label: ["Undefined label '", "%0", "'"],
uncaught_exception: ["Uncaught ", "%0"], uncaught_exception: ["Uncaught ", "%0"],
stack_trace: ["Stack Trace:\n", "%0"],
called_non_callable: ["%0", " is not a function"],
undefined_method: ["Object ", "%1", " has no method '", "%0", "'"], undefined_method: ["Object ", "%1", " has no method '", "%0", "'"],
cannot_convert_to_primitive: ["Cannot convert object to primitive value"], cannot_convert_to_primitive: ["Cannot convert object to primitive value"],
not_constructor: ["%0", " is not a constructor"], not_constructor: ["%0", " is not a constructor"],
...@@ -312,8 +318,13 @@ function ToDetailString(obj) { ...@@ -312,8 +318,13 @@ function ToDetailString(obj) {
} }
function MakeGenericError(constructor, type, arg0, arg1, arg2) { function MakeGenericError(constructor, type, args) {
if (IS_UNDEFINED(arg0) && IS_STRING(type)) arg0 = []; if (IS_UNDEFINED(args)) args = [];
return new constructor(FormatMessage(type, args));
}
function MakeGenericError2(constructor, type, arg0, arg1, arg2) {
return new constructor(FormatMessage(type, arg0, arg1, arg2)); return new constructor(FormatMessage(type, arg0, arg1, arg2));
} }
...@@ -370,35 +381,42 @@ function GetSourceLine(message) { ...@@ -370,35 +381,42 @@ function GetSourceLine(message) {
} }
function MakeError(type, arg0, arg1, arg2) { function MakeTypeError(type, args) {
return MakeGenericError($Error, type, arg0, arg1, arg2); return MakeGenericError($TypeError, type, args);
} }
function MakeTypeError(type, arg0, arg1, arg2) { // TODO(yangguo): rename this once we migrated all messages.
return MakeGenericError($TypeError, type, arg0, arg1, arg2); function MakeTypeError2(type, arg0, arg1, arg2) {
return MakeGenericError2($TypeError, type, arg0, arg1, arg2);
} }
function MakeRangeError(type, arg0, arg1, arg2) { function MakeRangeError(type, args) {
return MakeGenericError($RangeError, type, arg0, arg1, arg2); return MakeGenericError($RangeError, type, args);
} }
function MakeSyntaxError(type, arg0, arg1, arg2) { function MakeSyntaxError(type, args) {
return MakeGenericError($SyntaxError, type, arg0, arg1, arg2); return MakeGenericError($SyntaxError, type, args);
} }
function MakeReferenceError(type, arg0, arg1, arg2) { function MakeReferenceError(type, args) {
return MakeGenericError($ReferenceError, type, arg0, arg1, arg2); return MakeGenericError($ReferenceError, type, args);
} }
function MakeEvalError(type, arg0, arg1, arg2) { function MakeEvalError(type, args) {
return MakeGenericError($EvalError, type, arg0, arg1, arg2); return MakeGenericError($EvalError, type, args);
} }
function MakeError(type, args) {
return MakeGenericError($Error, type, args);
}
// The embedded versions are called from unoptimized code, with embedded // The embedded versions are called from unoptimized code, with embedded
// arguments. Those arguments cannot be arrays, which are context-dependent. // arguments. Those arguments cannot be arrays, which are context-dependent.
function MakeTypeErrorEmbedded(type, arg) { function MakeTypeErrorEmbedded(type, arg) {
......
...@@ -33,7 +33,6 @@ ...@@ -33,7 +33,6 @@
#include "src/log.h" #include "src/log.h"
#include "src/lookup.h" #include "src/lookup.h"
#include "src/macro-assembler.h" #include "src/macro-assembler.h"
#include "src/messages.h"
#include "src/objects-inl.h" #include "src/objects-inl.h"
#include "src/prototype.h" #include "src/prototype.h"
#include "src/safepoint-table.h" #include "src/safepoint-table.h"
...@@ -298,9 +297,10 @@ MaybeHandle<Object> Object::GetPropertyWithAccessor(Handle<Object> receiver, ...@@ -298,9 +297,10 @@ MaybeHandle<Object> Object::GetPropertyWithAccessor(Handle<Object> receiver,
if (structure->IsAccessorInfo()) { if (structure->IsAccessorInfo()) {
Handle<AccessorInfo> info = Handle<AccessorInfo>::cast(structure); Handle<AccessorInfo> info = Handle<AccessorInfo>::cast(structure);
if (!info->IsCompatibleReceiver(*receiver)) { if (!info->IsCompatibleReceiver(*receiver)) {
Handle<Object> args[] = {name, receiver};
THROW_NEW_ERROR(isolate, THROW_NEW_ERROR(isolate,
NewTypeError(MessageTemplate::kIncompatibleMethodReceiver, NewTypeError("incompatible_method_receiver",
name, receiver), HandleVector(args, arraysize(args))),
Object); Object);
} }
...@@ -362,9 +362,10 @@ MaybeHandle<Object> Object::SetPropertyWithAccessor( ...@@ -362,9 +362,10 @@ MaybeHandle<Object> Object::SetPropertyWithAccessor(
// api style callbacks // api style callbacks
ExecutableAccessorInfo* info = ExecutableAccessorInfo::cast(*structure); ExecutableAccessorInfo* info = ExecutableAccessorInfo::cast(*structure);
if (!info->IsCompatibleReceiver(*receiver)) { if (!info->IsCompatibleReceiver(*receiver)) {
Handle<Object> args[] = {name, receiver};
THROW_NEW_ERROR(isolate, THROW_NEW_ERROR(isolate,
NewTypeError(MessageTemplate::kIncompatibleMethodReceiver, NewTypeError("incompatible_method_receiver",
name, receiver), HandleVector(args, arraysize(args))),
Object); Object);
} }
Object* call_obj = info->setter(); Object* call_obj = info->setter();
...@@ -12488,7 +12489,9 @@ MaybeHandle<Object> JSObject::SetPrototype(Handle<JSObject> object, ...@@ -12488,7 +12489,9 @@ MaybeHandle<Object> JSObject::SetPrototype(Handle<JSObject> object,
!iter.IsAtEnd(); iter.Advance()) { !iter.IsAtEnd(); iter.Advance()) {
if (JSReceiver::cast(iter.GetCurrent()) == *object) { if (JSReceiver::cast(iter.GetCurrent()) == *object) {
// Cycle detected. // Cycle detected.
THROW_NEW_ERROR(isolate, NewError(MessageTemplate::kCyclicProto), Object); THROW_NEW_ERROR(isolate,
NewError("cyclic_proto", HandleVector<Object>(NULL, 0)),
Object);
} }
} }
......
...@@ -88,8 +88,8 @@ function RegExpCompileJS(pattern, flags) { ...@@ -88,8 +88,8 @@ function RegExpCompileJS(pattern, flags) {
// behavior. // behavior.
if (this == GlobalRegExp.prototype) { if (this == GlobalRegExp.prototype) {
// We don't allow recompiling RegExp.prototype. // We don't allow recompiling RegExp.prototype.
throw MakeTypeError(kIncompatibleMethodReceiver, throw MakeTypeError('incompatible_method_receiver',
'RegExp.prototype.compile', this); ['RegExp.prototype.compile', this]);
} }
if (IS_UNDEFINED(pattern) && %_ArgumentsLength() != 0) { if (IS_UNDEFINED(pattern) && %_ArgumentsLength() != 0) {
DoConstructRegExp(this, 'undefined', flags); DoConstructRegExp(this, 'undefined', flags);
...@@ -146,8 +146,8 @@ function RegExpExecNoTests(regexp, string, start) { ...@@ -146,8 +146,8 @@ function RegExpExecNoTests(regexp, string, start) {
function RegExpExecJS(string) { function RegExpExecJS(string) {
if (!IS_REGEXP(this)) { if (!IS_REGEXP(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver, throw MakeTypeError('incompatible_method_receiver',
'RegExp.prototype.exec', this); ['RegExp.prototype.exec', this]);
} }
string = TO_STRING_INLINE(string); string = TO_STRING_INLINE(string);
...@@ -194,8 +194,8 @@ var regexp_val; ...@@ -194,8 +194,8 @@ var regexp_val;
// else implements. // else implements.
function RegExpTest(string) { function RegExpTest(string) {
if (!IS_REGEXP(this)) { if (!IS_REGEXP(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver, throw MakeTypeError('incompatible_method_receiver',
'RegExp.prototype.test', this); ['RegExp.prototype.test', this]);
} }
string = TO_STRING_INLINE(string); string = TO_STRING_INLINE(string);
...@@ -256,8 +256,8 @@ function TrimRegExp(regexp) { ...@@ -256,8 +256,8 @@ function TrimRegExp(regexp) {
function RegExpToString() { function RegExpToString() {
if (!IS_REGEXP(this)) { if (!IS_REGEXP(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver, throw MakeTypeError('incompatible_method_receiver',
'RegExp.prototype.toString', this); ['RegExp.prototype.toString', this]);
} }
var result = '/' + this.source + '/'; var result = '/' + this.source + '/';
if (this.global) result += 'g'; if (this.global) result += 'g';
......
...@@ -379,7 +379,7 @@ function CALL_NON_FUNCTION() { ...@@ -379,7 +379,7 @@ function CALL_NON_FUNCTION() {
if (!IS_FUNCTION(delegate)) { if (!IS_FUNCTION(delegate)) {
var callsite = %RenderCallSite(); var callsite = %RenderCallSite();
if (callsite == "") callsite = typeof this; if (callsite == "") callsite = typeof this;
throw %MakeTypeError(kCalledNonCallable, callsite); throw %MakeTypeError('called_non_callable', [callsite]);
} }
return %Apply(delegate, this, arguments, 0, %_ArgumentsLength()); return %Apply(delegate, this, arguments, 0, %_ArgumentsLength());
} }
...@@ -390,7 +390,7 @@ function CALL_NON_FUNCTION_AS_CONSTRUCTOR() { ...@@ -390,7 +390,7 @@ function CALL_NON_FUNCTION_AS_CONSTRUCTOR() {
if (!IS_FUNCTION(delegate)) { if (!IS_FUNCTION(delegate)) {
var callsite = %RenderCallSite(); var callsite = %RenderCallSite();
if (callsite == "") callsite = typeof this; if (callsite == "") callsite = typeof this;
throw %MakeTypeError(kCalledNonCallable, callsite); throw %MakeTypeError('called_non_callable', [callsite]);
} }
return %Apply(delegate, this, arguments, 0, %_ArgumentsLength()); return %Apply(delegate, this, arguments, 0, %_ArgumentsLength());
} }
...@@ -463,7 +463,7 @@ function REFLECT_APPLY_PREPARE(args) { ...@@ -463,7 +463,7 @@ function REFLECT_APPLY_PREPARE(args) {
} }
if (!IS_SPEC_FUNCTION(this)) { if (!IS_SPEC_FUNCTION(this)) {
throw %MakeTypeError(kCalledNonCallable, %ToString(this)); throw %MakeTypeError('called_non_callable', [ %ToString(this) ]);
} }
if (!IS_SPEC_OBJECT(args)) { if (!IS_SPEC_OBJECT(args)) {
...@@ -503,7 +503,7 @@ function REFLECT_CONSTRUCT_PREPARE(args, newTarget) { ...@@ -503,7 +503,7 @@ function REFLECT_CONSTRUCT_PREPARE(args, newTarget) {
if (!ctorOk) { if (!ctorOk) {
if (!IS_SPEC_FUNCTION(this)) { if (!IS_SPEC_FUNCTION(this)) {
throw %MakeTypeError(kCalledNonCallable, %ToString(this)); throw %MakeTypeError('called_non_callable', [ %ToString(this) ]);
} else { } else {
throw %MakeTypeError('not_constructor', [ %ToString(this) ]); throw %MakeTypeError('not_constructor', [ %ToString(this) ]);
} }
...@@ -511,7 +511,7 @@ function REFLECT_CONSTRUCT_PREPARE(args, newTarget) { ...@@ -511,7 +511,7 @@ function REFLECT_CONSTRUCT_PREPARE(args, newTarget) {
if (!newTargetOk) { if (!newTargetOk) {
if (!IS_SPEC_FUNCTION(newTarget)) { if (!IS_SPEC_FUNCTION(newTarget)) {
throw %MakeTypeError(kCalledNonCallable, %ToString(newTarget)); throw %MakeTypeError('called_non_callable', [ %ToString(newTarget) ]);
} else { } else {
throw %MakeTypeError('not_constructor', [ %ToString(newTarget) ]); throw %MakeTypeError('not_constructor', [ %ToString(newTarget) ]);
} }
......
...@@ -398,7 +398,7 @@ static ObjectPair CompileGlobalEval(Isolate* isolate, Handle<String> source, ...@@ -398,7 +398,7 @@ static ObjectPair CompileGlobalEval(Isolate* isolate, Handle<String> source,
native_context->ErrorMessageForCodeGenerationFromStrings(); native_context->ErrorMessageForCodeGenerationFromStrings();
Handle<Object> error; Handle<Object> error;
MaybeHandle<Object> maybe_error = isolate->factory()->NewEvalError( MaybeHandle<Object> maybe_error = isolate->factory()->NewEvalError(
MessageTemplate::kCodeGenFromStrings, error_message); "code_gen_from_strings", HandleVector<Object>(&error_message, 1));
if (maybe_error.ToHandle(&error)) isolate->Throw(*error); if (maybe_error.ToHandle(&error)) isolate->Throw(*error);
return MakePair(isolate->heap()->exception(), NULL); return MakePair(isolate->heap()->exception(), NULL);
} }
......
...@@ -42,8 +42,8 @@ function StringIteratorNext() { ...@@ -42,8 +42,8 @@ function StringIteratorNext() {
var iterator = ToObject(this); var iterator = ToObject(this);
if (!HAS_DEFINED_PRIVATE(iterator, stringIteratorNextIndexSymbol)) { if (!HAS_DEFINED_PRIVATE(iterator, stringIteratorNextIndexSymbol)) {
throw MakeTypeError(kIncompatibleMethodReceiver, throw MakeTypeError('incompatible_method_receiver',
'String Iterator.prototype.next'); ['String Iterator.prototype.next']);
} }
var s = GET_PRIVATE(iterator, stringIteratorIteratedStringSymbol); var s = GET_PRIVATE(iterator, stringIteratorIteratedStringSymbol);
......
...@@ -34,8 +34,8 @@ function SymbolConstructor(x) { ...@@ -34,8 +34,8 @@ function SymbolConstructor(x) {
function SymbolToString() { function SymbolToString() {
if (!(IS_SYMBOL(this) || IS_SYMBOL_WRAPPER(this))) { if (!(IS_SYMBOL(this) || IS_SYMBOL_WRAPPER(this))) {
throw MakeTypeError(kIncompatibleMethodReceiver, throw MakeTypeError(
"Symbol.prototype.toString", this); 'incompatible_method_receiver', ["Symbol.prototype.toString", this]);
} }
var description = %SymbolDescription(%_ValueOf(this)); var description = %SymbolDescription(%_ValueOf(this));
return "Symbol(" + (IS_UNDEFINED(description) ? "" : description) + ")"; return "Symbol(" + (IS_UNDEFINED(description) ? "" : description) + ")";
...@@ -44,8 +44,8 @@ function SymbolToString() { ...@@ -44,8 +44,8 @@ function SymbolToString() {
function SymbolValueOf() { function SymbolValueOf() {
if (!(IS_SYMBOL(this) || IS_SYMBOL_WRAPPER(this))) { if (!(IS_SYMBOL(this) || IS_SYMBOL_WRAPPER(this))) {
throw MakeTypeError(kIncompatibleMethodReceiver, throw MakeTypeError(
"Symbol.prototype.valueOf", this); 'incompatible_method_receiver', ["Symbol.prototype.valueOf", this]);
} }
return %_ValueOf(this); return %_ValueOf(this);
} }
......
...@@ -119,28 +119,32 @@ function NAMEConstructor(arg1, arg2, arg3) { ...@@ -119,28 +119,32 @@ function NAMEConstructor(arg1, arg2, arg3) {
function NAME_GetBuffer() { function NAME_GetBuffer() {
if (!(%_ClassOf(this) === 'NAME')) { if (!(%_ClassOf(this) === 'NAME')) {
throw MakeTypeError(kIncompatibleMethodReceiver, "NAME.buffer", this); throw MakeTypeError('incompatible_method_receiver',
["NAME.buffer", this]);
} }
return %TypedArrayGetBuffer(this); return %TypedArrayGetBuffer(this);
} }
function NAME_GetByteLength() { function NAME_GetByteLength() {
if (!(%_ClassOf(this) === 'NAME')) { if (!(%_ClassOf(this) === 'NAME')) {
throw MakeTypeError(kIncompatibleMethodReceiver, "NAME.byteLength", this); throw MakeTypeError('incompatible_method_receiver',
["NAME.byteLength", this]);
} }
return %_ArrayBufferViewGetByteLength(this); return %_ArrayBufferViewGetByteLength(this);
} }
function NAME_GetByteOffset() { function NAME_GetByteOffset() {
if (!(%_ClassOf(this) === 'NAME')) { if (!(%_ClassOf(this) === 'NAME')) {
throw MakeTypeError(kIncompatibleMethodReceiver, "NAME.byteOffset", this); throw MakeTypeError('incompatible_method_receiver',
["NAME.byteOffset", this]);
} }
return %_ArrayBufferViewGetByteOffset(this); return %_ArrayBufferViewGetByteOffset(this);
} }
function NAME_GetLength() { function NAME_GetLength() {
if (!(%_ClassOf(this) === 'NAME')) { if (!(%_ClassOf(this) === 'NAME')) {
throw MakeTypeError(kIncompatibleMethodReceiver, "NAME.length", this); throw MakeTypeError('incompatible_method_receiver',
["NAME.length", this]);
} }
return %_TypedArrayGetLength(this); return %_TypedArrayGetLength(this);
} }
...@@ -149,7 +153,8 @@ var $NAME = global.NAME; ...@@ -149,7 +153,8 @@ var $NAME = global.NAME;
function NAMESubArray(begin, end) { function NAMESubArray(begin, end) {
if (!(%_ClassOf(this) === 'NAME')) { if (!(%_ClassOf(this) === 'NAME')) {
throw MakeTypeError(kIncompatibleMethodReceiver, "NAME.subarray", this); throw MakeTypeError('incompatible_method_receiver',
["NAME.subarray", this]);
} }
var beginInt = TO_INTEGER(begin); var beginInt = TO_INTEGER(begin);
if (!IS_UNDEFINED(end)) { if (!IS_UNDEFINED(end)) {
...@@ -361,23 +366,24 @@ function DataViewConstructor(buffer, byteOffset, byteLength) { // length = 3 ...@@ -361,23 +366,24 @@ function DataViewConstructor(buffer, byteOffset, byteLength) { // length = 3
function DataViewGetBufferJS() { function DataViewGetBufferJS() {
if (!IS_DATAVIEW(this)) { if (!IS_DATAVIEW(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver, 'DataView.buffer', this); throw MakeTypeError('incompatible_method_receiver',
['DataView.buffer', this]);
} }
return %DataViewGetBuffer(this); return %DataViewGetBuffer(this);
} }
function DataViewGetByteOffset() { function DataViewGetByteOffset() {
if (!IS_DATAVIEW(this)) { if (!IS_DATAVIEW(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver, throw MakeTypeError('incompatible_method_receiver',
'DataView.byteOffset', this); ['DataView.byteOffset', this]);
} }
return %_ArrayBufferViewGetByteOffset(this); return %_ArrayBufferViewGetByteOffset(this);
} }
function DataViewGetByteLength() { function DataViewGetByteLength() {
if (!IS_DATAVIEW(this)) { if (!IS_DATAVIEW(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver, throw MakeTypeError('incompatible_method_receiver',
'DataView.byteLength', this); ['DataView.byteLength', this]);
} }
return %_ArrayBufferViewGetByteLength(this); return %_ArrayBufferViewGetByteLength(this);
} }
...@@ -401,8 +407,8 @@ function ToPositiveDataViewOffset(offset) { ...@@ -401,8 +407,8 @@ function ToPositiveDataViewOffset(offset) {
macro DATA_VIEW_GETTER_SETTER(TYPENAME) macro DATA_VIEW_GETTER_SETTER(TYPENAME)
function DataViewGetTYPENAMEJS(offset, little_endian) { function DataViewGetTYPENAMEJS(offset, little_endian) {
if (!IS_DATAVIEW(this)) { if (!IS_DATAVIEW(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver, throw MakeTypeError('incompatible_method_receiver',
'DataView.getTYPENAME', this); ['DataView.getTYPENAME', this]);
} }
if (%_ArgumentsLength() < 1) { if (%_ArgumentsLength() < 1) {
throw MakeTypeError('invalid_argument'); throw MakeTypeError('invalid_argument');
...@@ -414,8 +420,8 @@ function DataViewGetTYPENAMEJS(offset, little_endian) { ...@@ -414,8 +420,8 @@ function DataViewGetTYPENAMEJS(offset, little_endian) {
function DataViewSetTYPENAMEJS(offset, value, little_endian) { function DataViewSetTYPENAMEJS(offset, value, little_endian) {
if (!IS_DATAVIEW(this)) { if (!IS_DATAVIEW(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver, throw MakeTypeError('incompatible_method_receiver',
'DataView.setTYPENAME', this); ['DataView.setTYPENAME', this]);
} }
if (%_ArgumentsLength() < 2) { if (%_ArgumentsLength() < 2) {
throw MakeTypeError('invalid_argument'); throw MakeTypeError('invalid_argument');
......
...@@ -691,7 +691,7 @@ function GetMethod(obj, p) { ...@@ -691,7 +691,7 @@ function GetMethod(obj, p) {
var func = obj[p]; var func = obj[p];
if (IS_NULL_OR_UNDEFINED(func)) return UNDEFINED; if (IS_NULL_OR_UNDEFINED(func)) return UNDEFINED;
if (IS_SPEC_FUNCTION(func)) return func; if (IS_SPEC_FUNCTION(func)) return func;
throw MakeTypeError(kCalledNonCallable, typeof func); throw MakeTypeError('called_non_callable', [typeof func]);
} }
...@@ -1587,8 +1587,8 @@ function NumberToFixedJS(fractionDigits) { ...@@ -1587,8 +1587,8 @@ function NumberToFixedJS(fractionDigits) {
var x = this; var x = this;
if (!IS_NUMBER(this)) { if (!IS_NUMBER(this)) {
if (!IS_NUMBER_WRAPPER(this)) { if (!IS_NUMBER_WRAPPER(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver, throw MakeTypeError("incompatible_method_receiver",
"Number.prototype.toFixed", this); ["Number.prototype.toFixed", this]);
} }
// Get the value of this number in case it's an object. // Get the value of this number in case it's an object.
x = %_ValueOf(this); x = %_ValueOf(this);
...@@ -1612,8 +1612,8 @@ function NumberToExponentialJS(fractionDigits) { ...@@ -1612,8 +1612,8 @@ function NumberToExponentialJS(fractionDigits) {
var x = this; var x = this;
if (!IS_NUMBER(this)) { if (!IS_NUMBER(this)) {
if (!IS_NUMBER_WRAPPER(this)) { if (!IS_NUMBER_WRAPPER(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver, throw MakeTypeError("incompatible_method_receiver",
"Number.prototype.toExponential", this); ["Number.prototype.toExponential", this]);
} }
// Get the value of this number in case it's an object. // Get the value of this number in case it's an object.
x = %_ValueOf(this); x = %_ValueOf(this);
...@@ -1638,8 +1638,8 @@ function NumberToPrecisionJS(precision) { ...@@ -1638,8 +1638,8 @@ function NumberToPrecisionJS(precision) {
var x = this; var x = this;
if (!IS_NUMBER(this)) { if (!IS_NUMBER(this)) {
if (!IS_NUMBER_WRAPPER(this)) { if (!IS_NUMBER_WRAPPER(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver, throw MakeTypeError("incompatible_method_receiver",
"Number.prototype.toPrecision", this); ["Number.prototype.toPrecision", this]);
} }
// Get the value of this number in case it's an object. // Get the value of this number in case it's an object.
x = %_ValueOf(this); x = %_ValueOf(this);
......
...@@ -25,7 +25,7 @@ function WeakMapConstructor(iterable) { ...@@ -25,7 +25,7 @@ function WeakMapConstructor(iterable) {
if (!IS_NULL_OR_UNDEFINED(iterable)) { if (!IS_NULL_OR_UNDEFINED(iterable)) {
var adder = this.set; var adder = this.set;
if (!IS_SPEC_FUNCTION(adder)) { if (!IS_SPEC_FUNCTION(adder)) {
throw MakeTypeError(kPropertyNotFunction, 'set', this); throw MakeTypeError(kPropertyNotFunction, ['set', this]);
} }
for (var nextItem of iterable) { for (var nextItem of iterable) {
if (!IS_SPEC_OBJECT(nextItem)) { if (!IS_SPEC_OBJECT(nextItem)) {
...@@ -39,8 +39,8 @@ function WeakMapConstructor(iterable) { ...@@ -39,8 +39,8 @@ function WeakMapConstructor(iterable) {
function WeakMapGet(key) { function WeakMapGet(key) {
if (!IS_WEAKMAP(this)) { if (!IS_WEAKMAP(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver, throw MakeTypeError('incompatible_method_receiver',
'WeakMap.prototype.get', this); ['WeakMap.prototype.get', this]);
} }
if (!IS_SPEC_OBJECT(key)) return UNDEFINED; if (!IS_SPEC_OBJECT(key)) return UNDEFINED;
return %WeakCollectionGet(this, key); return %WeakCollectionGet(this, key);
...@@ -49,8 +49,8 @@ function WeakMapGet(key) { ...@@ -49,8 +49,8 @@ function WeakMapGet(key) {
function WeakMapSet(key, value) { function WeakMapSet(key, value) {
if (!IS_WEAKMAP(this)) { if (!IS_WEAKMAP(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver, throw MakeTypeError('incompatible_method_receiver',
'WeakMap.prototype.set', this); ['WeakMap.prototype.set', this]);
} }
if (!IS_SPEC_OBJECT(key)) { if (!IS_SPEC_OBJECT(key)) {
throw %MakeTypeError('invalid_weakmap_key', [this, key]); throw %MakeTypeError('invalid_weakmap_key', [this, key]);
...@@ -61,8 +61,8 @@ function WeakMapSet(key, value) { ...@@ -61,8 +61,8 @@ function WeakMapSet(key, value) {
function WeakMapHas(key) { function WeakMapHas(key) {
if (!IS_WEAKMAP(this)) { if (!IS_WEAKMAP(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver, throw MakeTypeError('incompatible_method_receiver',
'WeakMap.prototype.has', this); ['WeakMap.prototype.has', this]);
} }
if (!IS_SPEC_OBJECT(key)) return false; if (!IS_SPEC_OBJECT(key)) return false;
return %WeakCollectionHas(this, key); return %WeakCollectionHas(this, key);
...@@ -71,8 +71,8 @@ function WeakMapHas(key) { ...@@ -71,8 +71,8 @@ function WeakMapHas(key) {
function WeakMapDelete(key) { function WeakMapDelete(key) {
if (!IS_WEAKMAP(this)) { if (!IS_WEAKMAP(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver, throw MakeTypeError('incompatible_method_receiver',
'WeakMap.prototype.delete', this); ['WeakMap.prototype.delete', this]);
} }
if (!IS_SPEC_OBJECT(key)) return false; if (!IS_SPEC_OBJECT(key)) return false;
return %WeakCollectionDelete(this, key); return %WeakCollectionDelete(this, key);
...@@ -110,7 +110,7 @@ function WeakSetConstructor(iterable) { ...@@ -110,7 +110,7 @@ function WeakSetConstructor(iterable) {
if (!IS_NULL_OR_UNDEFINED(iterable)) { if (!IS_NULL_OR_UNDEFINED(iterable)) {
var adder = this.add; var adder = this.add;
if (!IS_SPEC_FUNCTION(adder)) { if (!IS_SPEC_FUNCTION(adder)) {
throw MakeTypeError(kPropertyNotFunction, 'add', this); throw MakeTypeError(kPropertyNotFunction, ['add', this]);
} }
for (var value of iterable) { for (var value of iterable) {
%_CallFunction(this, value, adder); %_CallFunction(this, value, adder);
...@@ -121,8 +121,8 @@ function WeakSetConstructor(iterable) { ...@@ -121,8 +121,8 @@ function WeakSetConstructor(iterable) {
function WeakSetAdd(value) { function WeakSetAdd(value) {
if (!IS_WEAKSET(this)) { if (!IS_WEAKSET(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver, throw MakeTypeError('incompatible_method_receiver',
'WeakSet.prototype.add', this); ['WeakSet.prototype.add', this]);
} }
if (!IS_SPEC_OBJECT(value)) { if (!IS_SPEC_OBJECT(value)) {
throw %MakeTypeError('invalid_weakset_value', [this, value]); throw %MakeTypeError('invalid_weakset_value', [this, value]);
...@@ -133,8 +133,8 @@ function WeakSetAdd(value) { ...@@ -133,8 +133,8 @@ function WeakSetAdd(value) {
function WeakSetHas(value) { function WeakSetHas(value) {
if (!IS_WEAKSET(this)) { if (!IS_WEAKSET(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver, throw MakeTypeError('incompatible_method_receiver',
'WeakSet.prototype.has', this); ['WeakSet.prototype.has', this]);
} }
if (!IS_SPEC_OBJECT(value)) return false; if (!IS_SPEC_OBJECT(value)) return false;
return %WeakCollectionHas(this, value); return %WeakCollectionHas(this, value);
...@@ -143,8 +143,8 @@ function WeakSetHas(value) { ...@@ -143,8 +143,8 @@ function WeakSetHas(value) {
function WeakSetDelete(value) { function WeakSetDelete(value) {
if (!IS_WEAKSET(this)) { if (!IS_WEAKSET(this)) {
throw MakeTypeError(kIncompatibleMethodReceiver, throw MakeTypeError('incompatible_method_receiver',
'WeakSet.prototype.delete', this); ['WeakSet.prototype.delete', this]);
} }
if (!IS_SPEC_OBJECT(value)) return false; if (!IS_SPEC_OBJECT(value)) return false;
return %WeakCollectionDelete(this, value); return %WeakCollectionDelete(this, value);
......
// Copyright 2015 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
function test(f, expected, type) {
try {
f();
assertUnreachable();
} catch (e) {
assertInstanceof(e, type);
assertEquals(expected, e.message);
}
}
// === Error ===
// kCyclicProto
test(function() {
var o = {};
o.__proto__ = o;
}, "Cyclic __proto__ value", Error);
// === TypeError ===
// kGeneratorRunning
test(function() {
var iter;
function* generator() { yield iter.next(); }
var iter = generator();
iter.next();
}, "Generator is already running", TypeError);
// kCalledNonCallable
test(function() {
[].forEach(1);
}, "1 is not a function", TypeError);
// kIncompatibleMethodReceiver
test(function() {
RegExp.prototype.compile.call(RegExp.prototype);
}, "Method RegExp.prototype.compile called on incompatible receiver " +
"[object RegExp]", TypeError);
// kPropertyNotFunction
test(function() {
Set.prototype.add = 0;
new Set(1);
}, "Property 'add' of object #<Set> is not a function", TypeError);
// kWithExpression
test(function() {
with (null) {}
}, "null has no properties", TypeError);
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