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

Side by Side Diff: src/builtins.cc

Issue 114036: Push bleeding_edge revision 2020 (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
Patch Set: Created 11 years, 7 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 | « src/builtins.h ('k') | src/contexts.h » ('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 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 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 387
388 RETURN_IF_SCHEDULED_EXCEPTION(); 388 RETURN_IF_SCHEDULED_EXCEPTION();
389 if (!is_construct || result->IsJSObject()) return result; 389 if (!is_construct || result->IsJSObject()) return result;
390 } 390 }
391 391
392 return *receiver; 392 return *receiver;
393 } 393 }
394 BUILTIN_END 394 BUILTIN_END
395 395
396 396
397 // Handle calls to non-function objects created through the API that 397 // Helper function to handle calls to non-function objects created through the
398 // support calls. 398 // API. The object can be called as either a constructor (using new) or just as
399 BUILTIN(HandleApiCallAsFunction) { 399 // a function (without new).
400 // Non-functions are never called as constructors. 400 static Object* HandleApiCallAsFunctionOrConstructor(bool is_construct_call,
401 int __argc__,
402 Object** __argv__) {
403 // Non-functions are never called as constructors. Even if this is an object
404 // called as a constructor the delegate call is not a construct call.
401 ASSERT(!CalledAsConstructor()); 405 ASSERT(!CalledAsConstructor());
402 406
407 Handle<Object> receiver(&__argv__[0]);
408
403 // Get the object called. 409 // Get the object called.
404 JSObject* obj = JSObject::cast(*receiver); 410 JSObject* obj = JSObject::cast(*receiver);
405 411
406 // Get the invocation callback from the function descriptor that was 412 // Get the invocation callback from the function descriptor that was
407 // used to create the called object. 413 // used to create the called object.
408 ASSERT(obj->map()->has_instance_call_handler()); 414 ASSERT(obj->map()->has_instance_call_handler());
409 JSFunction* constructor = JSFunction::cast(obj->map()->constructor()); 415 JSFunction* constructor = JSFunction::cast(obj->map()->constructor());
410 Object* template_info = constructor->shared()->function_data(); 416 Object* template_info = constructor->shared()->function_data();
411 Object* handler = 417 Object* handler =
412 FunctionTemplateInfo::cast(template_info)->instance_call_handler(); 418 FunctionTemplateInfo::cast(template_info)->instance_call_handler();
(...skipping 11 matching lines...) Expand all
424 v8::Utils::ToLocal(Handle<JSObject>::cast(receiver)); 430 v8::Utils::ToLocal(Handle<JSObject>::cast(receiver));
425 Handle<Object> data_handle(data_obj); 431 Handle<Object> data_handle(data_obj);
426 v8::Local<v8::Value> data = v8::Utils::ToLocal(data_handle); 432 v8::Local<v8::Value> data = v8::Utils::ToLocal(data_handle);
427 Handle<JSFunction> callee_handle(constructor); 433 Handle<JSFunction> callee_handle(constructor);
428 v8::Local<v8::Function> callee = v8::Utils::ToLocal(callee_handle); 434 v8::Local<v8::Function> callee = v8::Utils::ToLocal(callee_handle);
429 LOG(ApiObjectAccess("call non-function", JSObject::cast(*receiver))); 435 LOG(ApiObjectAccess("call non-function", JSObject::cast(*receiver)));
430 v8::Arguments args = v8::ImplementationUtilities::NewArguments( 436 v8::Arguments args = v8::ImplementationUtilities::NewArguments(
431 data, 437 data,
432 self, 438 self,
433 callee, 439 callee,
434 false, 440 is_construct_call,
435 reinterpret_cast<void**>(__argv__ - 1), 441 reinterpret_cast<void**>(__argv__ - 1),
436 __argc__ - 1); 442 __argc__ - 1);
437 v8::Handle<v8::Value> value; 443 v8::Handle<v8::Value> value;
438 { 444 {
439 // Leaving JavaScript. 445 // Leaving JavaScript.
440 VMState state(EXTERNAL); 446 VMState state(EXTERNAL);
441 value = callback(args); 447 value = callback(args);
442 } 448 }
443 if (value.IsEmpty()) { 449 if (value.IsEmpty()) {
444 result = Heap::undefined_value(); 450 result = Heap::undefined_value();
445 } else { 451 } else {
446 result = *reinterpret_cast<Object**>(*value); 452 result = *reinterpret_cast<Object**>(*value);
447 } 453 }
448 } 454 }
449 // Check for exceptions and return result. 455 // Check for exceptions and return result.
450 RETURN_IF_SCHEDULED_EXCEPTION(); 456 RETURN_IF_SCHEDULED_EXCEPTION();
451 return result; 457 return result;
452 } 458 }
459
460
461 // Handle calls to non-function objects created through the API. This delegate
462 // function is used when the call is a normal function call.
463 BUILTIN(HandleApiCallAsFunction) {
464 return HandleApiCallAsFunctionOrConstructor(false, __argc__, __argv__);
465 }
466 BUILTIN_END
467
468
469 // Handle calls to non-function objects created through the API. This delegate
470 // function is used when the call is a construct call.
471 BUILTIN(HandleApiCallAsConstructor) {
472 return HandleApiCallAsFunctionOrConstructor(true, __argc__, __argv__);
473 }
453 BUILTIN_END 474 BUILTIN_END
454 475
455 476
456 // TODO(1238487): This is a nasty hack. We need to improve the way we 477 // TODO(1238487): This is a nasty hack. We need to improve the way we
457 // call builtins considerable to get rid of this and the hairy macros 478 // call builtins considerable to get rid of this and the hairy macros
458 // in builtins.cc. 479 // in builtins.cc.
459 Object* Builtins::builtin_passed_function; 480 Object* Builtins::builtin_passed_function;
460 481
461 482
462 483
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 if (entry->contains(pc)) { 757 if (entry->contains(pc)) {
737 return names_[i]; 758 return names_[i];
738 } 759 }
739 } 760 }
740 } 761 }
741 return NULL; 762 return NULL;
742 } 763 }
743 764
744 765
745 } } // namespace v8::internal 766 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/builtins.h ('k') | src/contexts.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698