Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(313)

Unified Diff: src/js/v8natives.js

Issue 1540953004: [runtime] Rewrite Function.prototype.toString in C++. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix typos. Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/js/v8natives.js
diff --git a/src/js/v8natives.js b/src/js/v8natives.js
index a394629c1b48f7321af0271b1e07b06cc3681d82..8f17a838b0d9de173e67e2d70a7ef5871747f081 100644
--- a/src/js/v8natives.js
+++ b/src/js/v8natives.js
@@ -1252,56 +1252,6 @@ utils.InstallFunctions(GlobalNumber, DONT_ENUM, [
// ----------------------------------------------------------------------------
// Function
-function NativeCodeFunctionSourceString(func) {
- var name = %FunctionGetName(func);
- if (name) {
- // Mimic what KJS does.
- return 'function ' + name + '() { [native code] }';
- }
-
- return 'function () { [native code] }';
-}
-
-function FunctionSourceString(func) {
- if (!IS_FUNCTION(func)) {
- throw MakeTypeError(kNotGeneric, 'Function.prototype.toString');
- }
-
- if (%FunctionHidesSource(func)) {
- return NativeCodeFunctionSourceString(func);
- }
-
- var classSource = %ClassGetSourceCode(func);
- if (IS_STRING(classSource)) {
- return classSource;
- }
-
- var source = %FunctionGetSourceCode(func);
- if (!IS_STRING(source)) {
- return NativeCodeFunctionSourceString(func);
- }
-
- if (%FunctionIsArrow(func)) {
- return source;
- }
-
- var name = %FunctionNameShouldPrintAsAnonymous(func)
- ? 'anonymous'
- : %FunctionGetName(func);
-
- var isGenerator = %FunctionIsGenerator(func);
- var head = %FunctionIsConciseMethod(func)
- ? (isGenerator ? '*' : '')
- : (isGenerator ? 'function* ' : 'function ');
- return head + name + source;
-}
-
-
-function FunctionToString() {
- return FunctionSourceString(this);
-}
-
-
// ES6 9.2.3.2 Function.prototype.bind(thisArg , ...args)
function FunctionBind(this_arg) { // Length is 1.
if (!IS_CALLABLE(this)) throw MakeTypeError(kFunctionBind);
@@ -1413,7 +1363,6 @@ function FunctionConstructor(arg1) { // length == 1
utils.InstallFunctions(GlobalFunction.prototype, DONT_ENUM, [
"bind", FunctionBind,
- "toString", FunctionToString
]);
// ----------------------------------------------------------------------------
@@ -1438,7 +1387,6 @@ function GetIterator(obj, method) {
// Exports
utils.Export(function(to) {
- to.FunctionSourceString = FunctionSourceString;
to.GetIterator = GetIterator;
to.GetMethod = GetMethod;
to.IsFinite = GlobalIsFinite;
« src/debug/mirrors.js ('K') | « src/js/prologue.js ('k') | src/mips/builtins-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698