Revision: 2913 Author: [email protected] Date: Thu Sep 17 04:11:01 2009 Log: Land change by Jan de Mooij to change the toString behavior of |function|.toString() for builtin functions.
Review URL: http://codereview.chromium.org/209014 http://code.google.com/p/v8/source/detail?r=2913 Modified: /branches/bleeding_edge/AUTHORS /branches/bleeding_edge/src/runtime.cc /branches/bleeding_edge/src/runtime.h /branches/bleeding_edge/src/v8natives.js ======================================= --- /branches/bleeding_edge/AUTHORS Mon Sep 7 00:54:51 2009 +++ /branches/bleeding_edge/AUTHORS Thu Sep 17 04:11:01 2009 @@ -10,6 +10,7 @@ Craig Schlenter <[email protected]> Daniel Andersson <[email protected]> Daniel James <[email protected]> +Jan de Mooij <[email protected]> Jay Freeman <[email protected]> Joel Stanley <[email protected]> Matt Hanselman <[email protected]> ======================================= --- /branches/bleeding_edge/src/runtime.cc Wed Sep 16 06:09:26 2009 +++ /branches/bleeding_edge/src/runtime.cc Thu Sep 17 04:11:01 2009 @@ -1207,6 +1207,14 @@ return !f->shared()->function_data()->IsUndefined() ? Heap::true_value() : Heap::false_value(); } + +static Object* Runtime_FunctionIsBuiltin(Arguments args) { + NoHandleAllocation ha; + ASSERT(args.length() == 1); + + CONVERT_CHECKED(JSFunction, f, args[0]); + return f->IsBuiltin() ? Heap::true_value() : Heap::false_value(); +} static Object* Runtime_SetCode(Arguments args) { ======================================= --- /branches/bleeding_edge/src/runtime.h Tue Sep 15 04:51:40 2009 +++ /branches/bleeding_edge/src/runtime.h Thu Sep 17 04:11:01 2009 @@ -171,6 +171,7 @@ F(FunctionGetScriptSourcePosition, 1, 1) \ F(FunctionGetPositionForOffset, 2, 1) \ F(FunctionIsAPIFunction, 1, 1) \ + F(FunctionIsBuiltin, 1, 1) \ F(GetScript, 1, 1) \ F(CollectStackTrace, 2, 1) \ \ ======================================= --- /branches/bleeding_edge/src/v8natives.js Tue Sep 15 06:30:46 2009 +++ /branches/bleeding_edge/src/v8natives.js Thu Sep 17 04:11:01 2009 @@ -524,7 +524,7 @@ } var source = %FunctionGetSourceCode(func); - if (!IS_STRING(source)) { + if (!IS_STRING(source) || %FunctionIsBuiltin(func)) { var name = %FunctionGetName(func); if (name) { // Mimic what KJS does. @@ -534,12 +534,6 @@ } } - // Censor occurrences of internal calls. We do that for all - // functions and don't cache under the assumption that people rarly - // convert functions to strings. Note that we (apparently) can't - // use regular expression literals in natives files. - var regexp = ORIGINAL_REGEXP("%(\\w+\\()", "gm"); - if (source.match(regexp)) source = source.replace(regexp, "$1"); var name = %FunctionGetName(func); return 'function ' + name + source; } --~--~---------~--~----~------------~-------~--~----~ v8-dev mailing list [email protected] http://groups.google.com/group/v8-dev -~----------~----~----~----~------~----~------~--~---
