Commit 2fc2bbdd authored by jgruber's avatar jgruber Committed by Commit bot

Move ErrorToString to runtime

BUG=

Review-Url: https://codereview.chromium.org/2206183002
Cr-Commit-Position: refs/heads/master@{#38295}
parent 03924dbf
......@@ -1531,6 +1531,7 @@ v8_source_set("v8_base") {
"src/runtime/runtime-compiler.cc",
"src/runtime/runtime-date.cc",
"src/runtime/runtime-debug.cc",
"src/runtime/runtime-error.cc",
"src/runtime/runtime-forin.cc",
"src/runtime/runtime-function.cc",
"src/runtime/runtime-futex.cc",
......
......@@ -8,7 +8,6 @@
// ----------------------------------------------------------------------------
// Imports
var ErrorToString;
var GlobalArray = global.Array;
var IsNaN = global.isNaN;
var JSONStringify = global.JSON.stringify;
......@@ -21,7 +20,6 @@ var SetIteratorNext;
var SetValues;
utils.Import(function(from) {
ErrorToString = from.ErrorToString;
MakeError = from.MakeError;
MapEntries = from.MapEntries;
MapIteratorNext = from.MapIteratorNext;
......@@ -1255,7 +1253,7 @@ ErrorMirror.prototype.toText = function() {
// Use the same text representation as in messages.js.
var text;
try {
text = %_Call(ErrorToString, this.value_);
text = %ErrorToString(this.value_);
} catch (e) {
text = '#<Error>';
}
......
......@@ -115,22 +115,6 @@ utils.SetUpLockedPrototype(Script, [
// ----------------------------------------------------------------------------
// Error implementation
function ErrorToString() {
if (!IS_RECEIVER(this)) {
throw MakeTypeError(kCalledOnNonObject, "Error.prototype.toString");
}
var name = this.name;
name = IS_UNDEFINED(name) ? "Error" : TO_STRING(name);
var message = this.message;
message = IS_UNDEFINED(message) ? "" : TO_STRING(message);
if (name == "") return message;
if (message == "") return name;
return `${name}: ${message}`
}
function MakeError(type, arg0, arg1, arg2) {
return MakeGenericError(GlobalError, type, arg0, arg1, arg2);
}
......@@ -160,7 +144,6 @@ function MakeURIError() {
]);
utils.Export(function(to) {
to.ErrorToString = ErrorToString;
to.MakeError = MakeError;
to.MakeRangeError = MakeRangeError;
to.MakeSyntaxError = MakeSyntaxError;
......
......@@ -185,7 +185,6 @@ function PostNatives(utils) {
"ArrayToString",
"AsyncFunctionNext",
"AsyncFunctionThrow",
"ErrorToString",
"GetIterator",
"GetMethod",
"IntlParseDate",
......
// Copyright 2016 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.
#include "src/runtime/runtime-utils.h"
#include "src/arguments.h"
#include "src/base/platform/time.h"
#include "src/conversions-inl.h"
#include "src/futex-emulation.h"
#include "src/globals.h"
namespace v8 {
namespace internal {
RUNTIME_FUNCTION(Runtime_ErrorToString) {
HandleScope scope(isolate);
DCHECK(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(Object, recv, 0);
RETURN_RESULT_OR_FAILURE(isolate, ErrorUtils::ToString(isolate, recv));
}
} // namespace internal
} // namespace v8
......@@ -198,6 +198,8 @@ namespace internal {
F(GetWasmFunctionOffsetTable, 1, 1) \
F(DisassembleWasmFunction, 1, 1)
#define FOR_EACH_INTRINSIC_ERROR(F) F(ErrorToString, 1, 1)
#define FOR_EACH_INTRINSIC_FORIN(F) \
F(ForInDone, 2, 1) \
F(ForInEnumerate, 1, 1) \
......@@ -958,6 +960,7 @@ namespace internal {
FOR_EACH_INTRINSIC_COMPILER(F) \
FOR_EACH_INTRINSIC_DATE(F) \
FOR_EACH_INTRINSIC_DEBUG(F) \
FOR_EACH_INTRINSIC_ERROR(F) \
FOR_EACH_INTRINSIC_FORIN(F) \
FOR_EACH_INTRINSIC_INTERPRETER(F) \
FOR_EACH_INTRINSIC_FUNCTION(F) \
......
......@@ -1134,6 +1134,7 @@
'runtime/runtime-debug.cc',
'runtime/runtime-forin.cc',
'runtime/runtime-function.cc',
'runtime/runtime-error.cc',
'runtime/runtime-futex.cc',
'runtime/runtime-generator.cc',
'runtime/runtime-i18n.cc',
......
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