| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 577 Register scratch2, | 577 Register scratch2, |
| 578 Register scratch3, | 578 Register scratch3, |
| 579 Handle<JSObject> interceptor_holder, | 579 Handle<JSObject> interceptor_holder, |
| 580 LookupResult* lookup, | 580 LookupResult* lookup, |
| 581 Handle<String> name, | 581 Handle<String> name, |
| 582 const CallOptimization& optimization, | 582 const CallOptimization& optimization, |
| 583 Label* miss_label) { | 583 Label* miss_label) { |
| 584 ASSERT(optimization.is_constant_call()); | 584 ASSERT(optimization.is_constant_call()); |
| 585 ASSERT(!lookup->holder()->IsGlobalObject()); | 585 ASSERT(!lookup->holder()->IsGlobalObject()); |
| 586 | 586 |
| 587 int depth1 = kInvalidProtoDepth; | 587 bool can_do_fast_api_call = !lookup->holder()->IsGlobalObject() && |
| 588 int depth2 = kInvalidProtoDepth; | 588 optimization.is_simple_api_call() && |
| 589 bool can_do_fast_api_call = false; | 589 optimization.IsCompatibleReceiver(object); |
| 590 if (optimization.is_simple_api_call() && | |
| 591 !lookup->holder()->IsGlobalObject()) { | |
| 592 depth1 = optimization.GetPrototypeDepthOfExpectedType( | |
| 593 object, interceptor_holder); | |
| 594 if (depth1 == kInvalidProtoDepth) { | |
| 595 depth2 = optimization.GetPrototypeDepthOfExpectedType( | |
| 596 interceptor_holder, Handle<JSObject>(lookup->holder())); | |
| 597 } | |
| 598 can_do_fast_api_call = | |
| 599 depth1 != kInvalidProtoDepth || depth2 != kInvalidProtoDepth; | |
| 600 } | |
| 601 | 590 |
| 602 Counters* counters = masm->isolate()->counters(); | 591 Counters* counters = masm->isolate()->counters(); |
| 603 __ IncrementCounter(counters->call_const_interceptor(), 1); | 592 __ IncrementCounter(counters->call_const_interceptor(), 1); |
| 604 | 593 |
| 605 if (can_do_fast_api_call) { | 594 if (can_do_fast_api_call) { |
| 606 __ IncrementCounter(counters->call_const_interceptor_fast_api(), 1); | 595 __ IncrementCounter(counters->call_const_interceptor_fast_api(), 1); |
| 607 ReserveSpaceForFastApiCall(masm, scratch1); | 596 ReserveSpaceForFastApiCall(masm, scratch1); |
| 608 } | 597 } |
| 609 | 598 |
| 610 // Check that the maps from receiver to interceptor's holder | 599 // Check that the maps from receiver to interceptor's holder |
| 611 // haven't changed and thus we can invoke interceptor. | 600 // haven't changed and thus we can invoke interceptor. |
| 612 Label miss_cleanup; | 601 Label miss_cleanup; |
| 613 Label* miss = can_do_fast_api_call ? &miss_cleanup : miss_label; | 602 Label* miss = can_do_fast_api_call ? &miss_cleanup : miss_label; |
| 603 int depth = can_do_fast_api_call ? 0 : kInvalidProtoDepth; |
| 614 Register holder = | 604 Register holder = |
| 615 stub_compiler_->CheckPrototypes(object, receiver, interceptor_holder, | 605 stub_compiler_->CheckPrototypes(object, receiver, interceptor_holder, |
| 616 scratch1, scratch2, scratch3, | 606 scratch1, scratch2, scratch3, |
| 617 name, depth1, miss); | 607 name, depth, miss); |
| 618 | 608 |
| 619 // Invoke an interceptor and if it provides a value, | 609 // Invoke an interceptor and if it provides a value, |
| 620 // branch to |regular_invoke|. | 610 // branch to |regular_invoke|. |
| 621 Label regular_invoke; | 611 Label regular_invoke; |
| 622 LoadWithInterceptor(masm, receiver, holder, interceptor_holder, | 612 LoadWithInterceptor(masm, receiver, holder, interceptor_holder, |
| 623 ®ular_invoke); | 613 ®ular_invoke); |
| 624 | 614 |
| 625 // Interceptor returned nothing for this property. Try to use cached | 615 // Interceptor returned nothing for this property. Try to use cached |
| 626 // constant function. | 616 // constant function. |
| 627 | 617 |
| 628 // Check that the maps from interceptor's holder to constant function's | 618 // Check that the maps from interceptor's holder to constant function's |
| 629 // holder haven't changed and thus we can use cached constant function. | 619 // holder haven't changed and thus we can use cached constant function. |
| 620 // TODO(2268): Switch to return holder once embedders have adapted. |
| 630 if (*interceptor_holder != lookup->holder()) { | 621 if (*interceptor_holder != lookup->holder()) { |
| 631 stub_compiler_->CheckPrototypes(interceptor_holder, receiver, | 622 stub_compiler_->CheckPrototypes(interceptor_holder, receiver, |
| 632 Handle<JSObject>(lookup->holder()), | 623 Handle<JSObject>(lookup->holder()), |
| 633 scratch1, scratch2, scratch3, | 624 scratch1, scratch2, scratch3, |
| 634 name, depth2, miss); | 625 name, kInvalidProtoDepth, miss); |
| 635 } else { | |
| 636 // CheckPrototypes has a side effect of fetching a 'holder' | |
| 637 // for API (object which is instanceof for the signature). It's | |
| 638 // safe to omit it here, as if present, it should be fetched | |
| 639 // by the previous CheckPrototypes. | |
| 640 ASSERT(depth2 == kInvalidProtoDepth); | |
| 641 } | 626 } |
| 642 | 627 |
| 643 // Invoke function. | 628 // Invoke function. |
| 644 if (can_do_fast_api_call) { | 629 if (can_do_fast_api_call) { |
| 645 GenerateFastApiCall(masm, optimization, arguments_.immediate()); | 630 GenerateFastApiCall(masm, optimization, arguments_.immediate()); |
| 646 } else { | 631 } else { |
| 647 CallKind call_kind = CallICBase::Contextual::decode(extra_state_) | 632 CallKind call_kind = CallICBase::Contextual::decode(extra_state_) |
| 648 ? CALL_AS_FUNCTION | 633 ? CALL_AS_FUNCTION |
| 649 : CALL_AS_METHOD; | 634 : CALL_AS_METHOD; |
| 650 __ InvokeFunction(optimization.constant_function(), arguments_, | 635 __ InvokeFunction(optimization.constant_function(), arguments_, |
| (...skipping 1651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2302 Handle<JSObject> holder, | 2287 Handle<JSObject> holder, |
| 2303 Handle<JSGlobalPropertyCell> cell, | 2288 Handle<JSGlobalPropertyCell> cell, |
| 2304 Handle<JSFunction> function, | 2289 Handle<JSFunction> function, |
| 2305 Handle<String> name) { | 2290 Handle<String> name) { |
| 2306 ASSERT(optimization.is_simple_api_call()); | 2291 ASSERT(optimization.is_simple_api_call()); |
| 2307 // Bail out if object is a global object as we don't want to | 2292 // Bail out if object is a global object as we don't want to |
| 2308 // repatch it to global receiver. | 2293 // repatch it to global receiver. |
| 2309 if (object->IsGlobalObject()) return Handle<Code>::null(); | 2294 if (object->IsGlobalObject()) return Handle<Code>::null(); |
| 2310 if (!cell.is_null()) return Handle<Code>::null(); | 2295 if (!cell.is_null()) return Handle<Code>::null(); |
| 2311 if (!object->IsJSObject()) return Handle<Code>::null(); | 2296 if (!object->IsJSObject()) return Handle<Code>::null(); |
| 2312 int depth = optimization.GetPrototypeDepthOfExpectedType( | 2297 if (!optimization.IsCompatibleReceiver(object)) return Handle<Code>::null(); |
| 2313 Handle<JSObject>::cast(object), holder); | |
| 2314 if (depth == kInvalidProtoDepth) return Handle<Code>::null(); | |
| 2315 | 2298 |
| 2316 Label miss, miss_before_stack_reserved; | 2299 Label miss, miss_before_stack_reserved; |
| 2317 | 2300 |
| 2318 GenerateNameCheck(name, &miss_before_stack_reserved); | 2301 GenerateNameCheck(name, &miss_before_stack_reserved); |
| 2319 | 2302 |
| 2320 // Get the receiver from the stack. | 2303 // Get the receiver from the stack. |
| 2321 const int argc = arguments().immediate(); | 2304 const int argc = arguments().immediate(); |
| 2322 __ mov(edx, Operand(esp, (argc + 1) * kPointerSize)); | 2305 __ mov(edx, Operand(esp, (argc + 1) * kPointerSize)); |
| 2323 | 2306 |
| 2324 // Check that the receiver isn't a smi. | 2307 // Check that the receiver isn't a smi. |
| 2325 __ JumpIfSmi(edx, &miss_before_stack_reserved); | 2308 __ JumpIfSmi(edx, &miss_before_stack_reserved); |
| 2326 | 2309 |
| 2327 Counters* counters = isolate()->counters(); | 2310 Counters* counters = isolate()->counters(); |
| 2328 __ IncrementCounter(counters->call_const(), 1); | 2311 __ IncrementCounter(counters->call_const(), 1); |
| 2329 __ IncrementCounter(counters->call_const_fast_api(), 1); | 2312 __ IncrementCounter(counters->call_const_fast_api(), 1); |
| 2330 | 2313 |
| 2331 // Allocate space for v8::Arguments implicit values. Must be initialized | 2314 // Allocate space for v8::Arguments implicit values. Must be initialized |
| 2332 // before calling any runtime function. | 2315 // before calling any runtime function. |
| 2333 __ sub(esp, Immediate(kFastApiCallArguments * kPointerSize)); | 2316 __ sub(esp, Immediate(kFastApiCallArguments * kPointerSize)); |
| 2334 | 2317 |
| 2335 // Check that the maps haven't changed and find a Holder as a side effect. | 2318 // Check that the maps haven't changed and find holder as a side effect. |
| 2319 // TODO(2268): Switch to return holder once embedders have adapted. |
| 2336 CheckPrototypes(Handle<JSObject>::cast(object), edx, holder, ebx, eax, edi, | 2320 CheckPrototypes(Handle<JSObject>::cast(object), edx, holder, ebx, eax, edi, |
| 2337 name, depth, &miss); | 2321 name, 0, &miss); |
| 2338 | 2322 |
| 2339 // Move the return address on top of the stack. | 2323 // Move the return address on top of the stack. |
| 2340 __ mov(eax, Operand(esp, 4 * kPointerSize)); | 2324 __ mov(eax, Operand(esp, 4 * kPointerSize)); |
| 2341 __ mov(Operand(esp, 0 * kPointerSize), eax); | 2325 __ mov(Operand(esp, 0 * kPointerSize), eax); |
| 2342 | 2326 |
| 2343 // esp[2 * kPointerSize] is uninitialized, esp[3 * kPointerSize] contains | 2327 // esp[2 * kPointerSize] is uninitialized, esp[3 * kPointerSize] contains |
| 2344 // duplicate of return address and will be overwritten. | 2328 // duplicate of return address and will be overwritten. |
| 2345 GenerateFastApiCall(masm(), optimization, argc); | 2329 GenerateFastApiCall(masm(), optimization, argc); |
| 2346 | 2330 |
| 2347 __ bind(&miss); | 2331 __ bind(&miss); |
| (...skipping 2046 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4394 __ jmp(ic_slow, RelocInfo::CODE_TARGET); | 4378 __ jmp(ic_slow, RelocInfo::CODE_TARGET); |
| 4395 } | 4379 } |
| 4396 } | 4380 } |
| 4397 | 4381 |
| 4398 | 4382 |
| 4399 #undef __ | 4383 #undef __ |
| 4400 | 4384 |
| 4401 } } // namespace v8::internal | 4385 } } // namespace v8::internal |
| 4402 | 4386 |
| 4403 #endif // V8_TARGET_ARCH_IA32 | 4387 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |