Reviewers: iposva, Kasper Lund, Description: Firefox and Safari both allow calling regular expression objects as functions. For compatibility make call_regexp the default and remove the flag.
Please review this at http://codereview.chromium.org/155453 SVN Base: http://v8.googlecode.com/svn/branches/bleeding_edge/ Affected files: M src/arm/stub-cache-arm.cc M src/execution.cc M src/flag-definitions.h Index: src/flag-definitions.h =================================================================== --- src/flag-definitions.h (revision 2427) +++ src/flag-definitions.h (working copy) @@ -144,9 +144,6 @@ "automatically set the debug break flag when debugger commands are " "in the queue (experimental)") -// execution.cc -DEFINE_bool(call_regexp, false, "allow calls to RegExp objects") - // frames.cc DEFINE_int(max_stack_trace_source_length, 300, "maximum length of function source code printed in a stack trace.") Index: src/arm/stub-cache-arm.cc =================================================================== --- src/arm/stub-cache-arm.cc (revision 2430) +++ src/arm/stub-cache-arm.cc (working copy) @@ -1121,8 +1121,6 @@ } -// TODO(1224671): IC stubs for keyed loads have not been implemented -// for ARM. Object* KeyedLoadStubCompiler::CompileLoadField(String* name, JSObject* receiver, JSObject* holder, Index: src/execution.cc =================================================================== --- src/execution.cc (revision 2427) +++ src/execution.cc (working copy) @@ -164,19 +164,16 @@ // If you return a function from here, it will be called when an // attempt is made to call the given object as a function. - // The regular expression code here is really meant more as an - // example than anything else. KJS does not support calling regular - // expressions as functions, but SpiderMonkey does. - if (FLAG_call_regexp) { - bool is_regexp = - object->IsHeapObject() && - (HeapObject::cast(*object)->map()->constructor() == - *Top::regexp_function()); + // Regular expressions can be called as functions in both Firefox + // and Safari so we allow it too. + bool is_regexp = + object->IsHeapObject() && + (HeapObject::cast(*object)->map()->constructor() == + *Top::regexp_function()); - if (is_regexp) { - Handle<String> exec = Factory::exec_symbol(); - return Handle<Object>(object->GetProperty(*exec)); - } + if (is_regexp) { + Handle<String> exec = Factory::exec_symbol(); + return Handle<Object>(object->GetProperty(*exec)); } // Objects created through the API can have an instance-call handler --~--~---------~--~----~------------~-------~--~----~ v8-dev mailing list [email protected] http://groups.google.com/group/v8-dev -~----------~----~----~----~------~----~------~--~---
