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

Unified Diff: src/v8natives.js

Issue 1112113002: Show function <name>() { [native code] } for built-in classes (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 8 months 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/v8natives.js
diff --git a/src/v8natives.js b/src/v8natives.js
index 1e42ac5d1eb2e100444303cc78e19bfe9e243525..d163f5e23218b1f8946d602b7a0e19ce0e72d12f 100644
--- a/src/v8natives.js
+++ b/src/v8natives.js
@@ -1738,6 +1738,16 @@ SetUpNumber();
// ----------------------------------------------------------------------------
// 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) {
while (%IsJSFunctionProxy(func)) {
func = %GetCallTrap(func);
@@ -1747,20 +1757,18 @@ function FunctionSourceString(func) {
throw MakeTypeError(kNotGeneric, 'Function.prototype.toString');
}
+ if (%FunctionIsBuiltin(func)) {
+ return NativeCodeFunctionSourceString(func);
+ }
+
var classSource = %ClassGetSourceCode(func);
if (IS_STRING(classSource)) {
return classSource;
}
var source = %FunctionGetSourceCode(func);
- if (!IS_STRING(source) || %FunctionIsBuiltin(func)) {
- var name = %FunctionGetName(func);
- if (name) {
- // Mimic what KJS does.
- return 'function ' + name + '() { [native code] }';
- } else {
- return 'function () { [native code] }';
- }
+ if (!IS_STRING(source)) {
+ return NativeCodeFunctionSourceString(func);
}
if (%FunctionIsArrow(func)) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698