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

Side by Side Diff: src/execution.cc

Issue 7887031: Make built-in functions not call .apply on functions. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/runtime.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 219
220 220
221 Handle<Object> Execution::GetFunctionDelegate(Handle<Object> object) { 221 Handle<Object> Execution::GetFunctionDelegate(Handle<Object> object) {
222 ASSERT(!object->IsJSFunction()); 222 ASSERT(!object->IsJSFunction());
223 Isolate* isolate = Isolate::Current(); 223 Isolate* isolate = Isolate::Current();
224 Factory* factory = isolate->factory(); 224 Factory* factory = isolate->factory();
225 225
226 // If you return a function from here, it will be called when an 226 // If you return a function from here, it will be called when an
227 // attempt is made to call the given object as a function. 227 // attempt is made to call the given object as a function.
228 228
229 // If object is a function proxies, get its handler. Iterate if necessary. 229 // If object is a function proxy, get its handler. Iterate if necessary.
230 Object* fun = *object; 230 Object* fun = *object;
231 while (fun->IsJSFunctionProxy()) { 231 while (fun->IsJSFunctionProxy()) {
232 fun = JSFunctionProxy::cast(fun)->call_trap(); 232 fun = JSFunctionProxy::cast(fun)->call_trap();
233 } 233 }
234 if (fun->IsJSFunction()) return Handle<Object>(fun); 234 if (fun->IsJSFunction()) return Handle<Object>(fun);
235 235
236 // Objects created through the API can have an instance-call handler 236 // Objects created through the API can have an instance-call handler
237 // that should be used when calling the object as a function. 237 // that should be used when calling the object as a function.
238 if (fun->IsHeapObject() && 238 if (fun->IsHeapObject() &&
239 HeapObject::cast(fun)->map()->has_instance_call_handler()) { 239 HeapObject::cast(fun)->map()->has_instance_call_handler()) {
240 return Handle<JSFunction>( 240 return Handle<JSFunction>(
241 isolate->global_context()->call_as_function_delegate()); 241 isolate->global_context()->call_as_function_delegate());
242 } 242 }
243 243
244 return factory->undefined_value(); 244 return factory->undefined_value();
245 } 245 }
246 246
247 247
248 Handle<Object> Execution::TryGetFunctionDelegate(Handle<Object> object, 248 Handle<Object> Execution::TryGetFunctionDelegate(Handle<Object> object,
249 bool* has_pending_exception) { 249 bool* has_pending_exception) {
250 ASSERT(!object->IsJSFunction()); 250 ASSERT(!object->IsJSFunction());
251 Isolate* isolate = Isolate::Current(); 251 Isolate* isolate = Isolate::Current();
252 252
253 // If object is a function proxies, get its handler. Iterate if necessary. 253 // If object is a function proxy, get its handler. Iterate if necessary.
254 Object* fun = *object; 254 Object* fun = *object;
255 while (fun->IsJSFunctionProxy()) { 255 while (fun->IsJSFunctionProxy()) {
256 fun = JSFunctionProxy::cast(fun)->call_trap(); 256 fun = JSFunctionProxy::cast(fun)->call_trap();
257 } 257 }
258 if (fun->IsJSFunction()) return Handle<Object>(fun); 258 if (fun->IsJSFunction()) return Handle<Object>(fun);
259 259
260 // Objects created through the API can have an instance-call handler 260 // Objects created through the API can have an instance-call handler
261 // that should be used when calling the object as a function. 261 // that should be used when calling the object as a function.
262 if (fun->IsHeapObject() && 262 if (fun->IsHeapObject() &&
263 HeapObject::cast(fun)->map()->has_instance_call_handler()) { 263 HeapObject::cast(fun)->map()->has_instance_call_handler()) {
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after
868 return isolate->TerminateExecution(); 868 return isolate->TerminateExecution();
869 } 869 }
870 if (stack_guard->IsInterrupted()) { 870 if (stack_guard->IsInterrupted()) {
871 stack_guard->Continue(INTERRUPT); 871 stack_guard->Continue(INTERRUPT);
872 return isolate->StackOverflow(); 872 return isolate->StackOverflow();
873 } 873 }
874 return isolate->heap()->undefined_value(); 874 return isolate->heap()->undefined_value();
875 } 875 }
876 876
877 } } // namespace v8::internal 877 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/runtime.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698