OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 return result; | 157 return result; |
158 } | 158 } |
159 | 159 |
160 | 160 |
161 Handle<Object> Execution::GetFunctionDelegate(Handle<Object> object) { | 161 Handle<Object> Execution::GetFunctionDelegate(Handle<Object> object) { |
162 ASSERT(!object->IsJSFunction()); | 162 ASSERT(!object->IsJSFunction()); |
163 | 163 |
164 // If you return a function from here, it will be called when an | 164 // If you return a function from here, it will be called when an |
165 // attempt is made to call the given object as a function. | 165 // attempt is made to call the given object as a function. |
166 | 166 |
167 // The regular expression code here is really meant more as an | 167 // Regular expressions can be called as functions in both Firefox |
168 // example than anything else. KJS does not support calling regular | 168 // and Safari so we allow it too. |
169 // expressions as functions, but SpiderMonkey does. | 169 bool is_regexp = |
170 if (FLAG_call_regexp) { | 170 object->IsHeapObject() && |
171 bool is_regexp = | 171 (HeapObject::cast(*object)->map()->constructor() == |
172 object->IsHeapObject() && | 172 *Top::regexp_function()); |
173 (HeapObject::cast(*object)->map()->constructor() == | |
174 *Top::regexp_function()); | |
175 | 173 |
176 if (is_regexp) { | 174 if (is_regexp) { |
177 Handle<String> exec = Factory::exec_symbol(); | 175 Handle<String> exec = Factory::exec_symbol(); |
178 return Handle<Object>(object->GetProperty(*exec)); | 176 return Handle<Object>(object->GetProperty(*exec)); |
179 } | |
180 } | 177 } |
181 | 178 |
182 // Objects created through the API can have an instance-call handler | 179 // Objects created through the API can have an instance-call handler |
183 // that should be used when calling the object as a function. | 180 // that should be used when calling the object as a function. |
184 if (object->IsHeapObject() && | 181 if (object->IsHeapObject() && |
185 HeapObject::cast(*object)->map()->has_instance_call_handler()) { | 182 HeapObject::cast(*object)->map()->has_instance_call_handler()) { |
186 return Handle<JSFunction>( | 183 return Handle<JSFunction>( |
187 Top::global_context()->call_as_function_delegate()); | 184 Top::global_context()->call_as_function_delegate()); |
188 } | 185 } |
189 | 186 |
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
644 // All allocation spaces other than NEW_SPACE have the same effect. | 641 // All allocation spaces other than NEW_SPACE have the same effect. |
645 Heap::CollectAllGarbage(); | 642 Heap::CollectAllGarbage(); |
646 return v8::Undefined(); | 643 return v8::Undefined(); |
647 } | 644 } |
648 | 645 |
649 | 646 |
650 static GCExtension kGCExtension; | 647 static GCExtension kGCExtension; |
651 v8::DeclareExtension kGCExtensionDeclaration(&kGCExtension); | 648 v8::DeclareExtension kGCExtensionDeclaration(&kGCExtension); |
652 | 649 |
653 } } // namespace v8::internal | 650 } } // namespace v8::internal |
OLD | NEW |