13 CallOptimization::CallOptimization(Handle<JSFunction>
function) {
18 Handle<JSObject> CallOptimization::LookupHolderOfExpectedType(
19 Handle<Map> object_map, HolderLookup* holder_lookup)
const {
20 DCHECK(is_simple_api_call());
21 if (!object_map->IsJSObjectMap()) {
22 *holder_lookup = kHolderNotFound;
25 if (expected_receiver_type_.is_null() ||
26 expected_receiver_type_->IsTemplateFor(*object_map)) {
27 *holder_lookup = kHolderIsReceiver;
31 if (!object_map->prototype()->IsJSObject())
break;
32 Handle<JSObject> prototype(JSObject::cast(object_map->prototype()));
33 if (!prototype->map()->is_hidden_prototype())
break;
34 object_map =
handle(prototype->map());
35 if (expected_receiver_type_->IsTemplateFor(*object_map)) {
36 *holder_lookup = kHolderFound;
40 *holder_lookup = kHolderNotFound;
45 bool CallOptimization::IsCompatibleReceiver(Handle<Object> receiver,
46 Handle<JSObject> holder)
const {
47 DCHECK(is_simple_api_call());
48 if (!receiver->IsJSObject())
return false;
49 Handle<Map>
map(JSObject::cast(*receiver)->map());
50 HolderLookup holder_lookup;
51 Handle<JSObject> api_holder = LookupHolderOfExpectedType(
map, &holder_lookup);
52 switch (holder_lookup) {
55 case kHolderIsReceiver:
58 if (api_holder.is_identical_to(holder))
return true;
61 JSObject*
object = *api_holder;
63 Object* prototype =
object->map()->prototype();
64 if (!prototype->IsJSObject())
return false;
65 if (prototype == *holder)
return true;
66 object = JSObject::cast(prototype);
76 void CallOptimization::Initialize(Handle<JSFunction>
function) {
78 is_simple_api_call_ =
false;
82 if (
function.is_null() || !function->is_compiled())
return;
84 constant_function_ =
function;
85 AnalyzePossibleApiFunction(
function);
89 void CallOptimization::AnalyzePossibleApiFunction(Handle<JSFunction>
function) {
90 if (!function->shared()->IsApiFunction())
return;
91 Handle<FunctionTemplateInfo> info(function->shared()->get_api_func_data());
94 if (info->call_code()->IsUndefined())
return;
96 Handle<CallHandlerInfo>(CallHandlerInfo::cast(info->call_code()));
100 if (!info->signature()->IsUndefined()) {
101 Handle<SignatureInfo> signature =
102 Handle<SignatureInfo>(SignatureInfo::cast(info->signature()));
103 if (!signature->args()->IsUndefined())
return;
104 if (!signature->receiver()->IsUndefined()) {
105 expected_receiver_type_ = Handle<FunctionTemplateInfo>(
106 FunctionTemplateInfo::cast(signature->receiver()));
110 is_simple_api_call_ =
true;
static Handle< T > null()
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf map
#define DCHECK(condition)
kSerializedDataOffset Object
Handle< T > handle(T *t, Isolate *isolate)
Debugger support for the V8 JavaScript engine.