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

Side by Side Diff: src/builtins.cc

Issue 573003: ia32: Fuse map and type checks in call ICs for API functions. (Closed)
Patch Set: Rewrote a comment. Created 10 years, 10 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
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 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 BUILTIN(HandleApiCall) { 467 BUILTIN(HandleApiCall) {
468 return HandleApiCallHelper<false>(args); 468 return HandleApiCallHelper<false>(args);
469 } 469 }
470 470
471 471
472 BUILTIN(HandleApiCallConstruct) { 472 BUILTIN(HandleApiCallConstruct) {
473 return HandleApiCallHelper<true>(args); 473 return HandleApiCallHelper<true>(args);
474 } 474 }
475 475
476 476
477 #ifdef DEBUG
478
479 static void VerifyTypeCheck(Handle<JSObject> object,
480 Handle<JSFunction> function) {
481 FunctionTemplateInfo* info =
482 FunctionTemplateInfo::cast(function->shared()->function_data());
483 if (info->signature()->IsUndefined()) return;
484 SignatureInfo* signature = SignatureInfo::cast(info->signature());
485 Object* receiver_type = signature->receiver();
486 if (receiver_type->IsUndefined()) return;
487 FunctionTemplateInfo* type = FunctionTemplateInfo::cast(receiver_type);
488 ASSERT(object->IsInstanceOf(type));
489 }
490
491 #endif
492
493
494 BUILTIN(FastHandleApiCall) {
495 ASSERT(!CalledAsConstructor());
496 const bool is_construct = false;
497
498 // We expect four more arguments: function, callback, call data, and holder.
499 const int args_length = args.length() - 4;
500 ASSERT(args_length >= 0);
501
502 Handle<JSFunction> function = args.at<JSFunction>(args_length);
503 Object* callback_obj = args[args_length + 1];
504 Handle<Object> data_handle = args.at<Object>(args_length + 2);
505 Handle<JSObject> checked_holder = args.at<JSObject>(args_length + 3);
506
507 #ifdef DEBUG
508 VerifyTypeCheck(checked_holder, function);
509 #endif
510
511 v8::Local<v8::Object> holder = v8::Utils::ToLocal(checked_holder);
512 v8::Local<v8::Function> callee = v8::Utils::ToLocal(function);
513 v8::InvocationCallback callback =
514 v8::ToCData<v8::InvocationCallback>(callback_obj);
515 v8::Local<v8::Value> data = v8::Utils::ToLocal(data_handle);
516
517 v8::Arguments new_args = v8::ImplementationUtilities::NewArguments(
518 data,
519 holder,
520 callee,
521 is_construct,
522 reinterpret_cast<void**>(&args[0] - 1),
523 args_length - 1);
524
525 HandleScope scope;
526 Object* result;
527 v8::Handle<v8::Value> value;
528 {
529 // Leaving JavaScript.
530 VMState state(EXTERNAL);
531 #ifdef ENABLE_LOGGING_AND_PROFILING
532 state.set_external_callback(v8::ToCData<Address>(callback_obj));
533 #endif
534 value = callback(new_args);
535 }
536 if (value.IsEmpty()) {
537 result = Heap::undefined_value();
538 } else {
539 result = *reinterpret_cast<Object**>(*value);
540 }
541
542 RETURN_IF_SCHEDULED_EXCEPTION();
543 return result;
544 }
545
546
477 // Helper function to handle calls to non-function objects created through the 547 // Helper function to handle calls to non-function objects created through the
478 // API. The object can be called as either a constructor (using new) or just as 548 // API. The object can be called as either a constructor (using new) or just as
479 // a function (without new). 549 // a function (without new).
480 static Object* HandleApiCallAsFunctionOrConstructor( 550 static Object* HandleApiCallAsFunctionOrConstructor(
481 bool is_construct_call, 551 bool is_construct_call,
482 BuiltinArguments<NO_EXTRA_ARGUMENTS> args) { 552 BuiltinArguments<NO_EXTRA_ARGUMENTS> args) {
483 // Non-functions are never called as constructors. Even if this is an object 553 // Non-functions are never called as constructors. Even if this is an object
484 // called as a constructor the delegate call is not a construct call. 554 // called as a constructor the delegate call is not a construct call.
485 ASSERT(!CalledAsConstructor()); 555 ASSERT(!CalledAsConstructor());
486 556
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
912 if (entry->contains(pc)) { 982 if (entry->contains(pc)) {
913 return names_[i]; 983 return names_[i];
914 } 984 }
915 } 985 }
916 } 986 }
917 return NULL; 987 return NULL;
918 } 988 }
919 989
920 990
921 } } // namespace v8::internal 991 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/builtins.h ('k') | src/ia32/macro-assembler-ia32.h » ('j') | src/ia32/stub-cache-ia32.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698