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

Side by Side Diff: src/x64/lithium-codegen-x64.cc

Issue 1307943013: [es5] Class of object is "Function" if object has [[Call]]. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Address Jakobs comments. Created 5 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
« no previous file with comments | « src/objects.cc ('k') | src/x64/macro-assembler-x64.cc » ('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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #if V8_TARGET_ARCH_X64 5 #if V8_TARGET_ARCH_X64
6 6
7 #include "src/base/bits.h" 7 #include "src/base/bits.h"
8 #include "src/code-factory.h" 8 #include "src/code-factory.h"
9 #include "src/code-stubs.h" 9 #include "src/code-stubs.h"
10 #include "src/cpu-profiler.h" 10 #include "src/cpu-profiler.h"
(...skipping 2554 matching lines...) Expand 10 before | Expand all | Expand 10 after
2565 Handle<String> class_name, 2565 Handle<String> class_name,
2566 Register input, 2566 Register input,
2567 Register temp, 2567 Register temp,
2568 Register temp2) { 2568 Register temp2) {
2569 DCHECK(!input.is(temp)); 2569 DCHECK(!input.is(temp));
2570 DCHECK(!input.is(temp2)); 2570 DCHECK(!input.is(temp2));
2571 DCHECK(!temp.is(temp2)); 2571 DCHECK(!temp.is(temp2));
2572 2572
2573 __ JumpIfSmi(input, is_false); 2573 __ JumpIfSmi(input, is_false);
2574 2574
2575 STATIC_ASSERT(LAST_JS_RECEIVER_TYPE == LAST_TYPE);
2576 __ CmpObjectType(input, FIRST_JS_RECEIVER_TYPE, temp);
2577 __ j(below, is_false);
2578
2579 // Objects with [[Call]] have class 'Function'.
2580 __ testb(FieldOperand(temp, Map::kBitFieldOffset),
2581 Immediate(1 << Map::kIsCallable));
2575 if (String::Equals(isolate()->factory()->Function_string(), class_name)) { 2582 if (String::Equals(isolate()->factory()->Function_string(), class_name)) {
2576 // Assuming the following assertions, we can use the same compares to test 2583 __ j(not_zero, is_true);
2577 // for both being a function type and being in the object type range.
2578 STATIC_ASSERT(NUM_OF_CALLABLE_SPEC_OBJECT_TYPES == 2);
2579 STATIC_ASSERT(FIRST_NONCALLABLE_SPEC_OBJECT_TYPE ==
2580 FIRST_SPEC_OBJECT_TYPE + 1);
2581 STATIC_ASSERT(LAST_NONCALLABLE_SPEC_OBJECT_TYPE ==
2582 LAST_SPEC_OBJECT_TYPE - 1);
2583 STATIC_ASSERT(LAST_SPEC_OBJECT_TYPE == LAST_TYPE);
2584 __ CmpObjectType(input, FIRST_SPEC_OBJECT_TYPE, temp);
2585 __ j(below, is_false);
2586 __ j(equal, is_true);
2587 __ CmpInstanceType(temp, LAST_SPEC_OBJECT_TYPE);
2588 __ j(equal, is_true);
2589 } else { 2584 } else {
2590 // Faster code path to avoid two compares: subtract lower bound from the 2585 __ j(not_zero, is_false);
2591 // actual type and do a signed compare with the width of the type range.
2592 __ movp(temp, FieldOperand(input, HeapObject::kMapOffset));
2593 __ movzxbl(temp2, FieldOperand(temp, Map::kInstanceTypeOffset));
2594 __ subp(temp2, Immediate(FIRST_NONCALLABLE_SPEC_OBJECT_TYPE));
2595 __ cmpp(temp2, Immediate(LAST_NONCALLABLE_SPEC_OBJECT_TYPE -
2596 FIRST_NONCALLABLE_SPEC_OBJECT_TYPE));
2597 __ j(above, is_false);
2598 } 2586 }
2599 2587
2600 // Now we are in the FIRST-LAST_NONCALLABLE_SPEC_OBJECT_TYPE range. 2588 // Now we are in the FIRST-LAST_JS_RECEIVER_TYPE range.
2601 // Check if the constructor in the map is a function. 2589 // Check if the constructor in the map is a function.
2602 __ GetMapConstructor(temp, temp, kScratchRegister); 2590 __ GetMapConstructor(temp, temp, kScratchRegister);
2603 2591
2604 // Objects with a non-function constructor have class 'Object'. 2592 // Objects with a non-function constructor have class 'Object'.
2605 __ CmpInstanceType(kScratchRegister, JS_FUNCTION_TYPE); 2593 __ CmpInstanceType(kScratchRegister, JS_FUNCTION_TYPE);
2606 if (String::Equals(class_name, isolate()->factory()->Object_string())) { 2594 if (String::Equals(class_name, isolate()->factory()->Object_string())) {
2607 __ j(not_equal, is_true); 2595 __ j(not_equal, is_true);
2608 } else { 2596 } else {
2609 __ j(not_equal, is_false); 2597 __ j(not_equal, is_false);
2610 } 2598 }
(...skipping 3335 matching lines...) Expand 10 before | Expand all | Expand 10 after
5946 RecordSafepoint(Safepoint::kNoLazyDeopt); 5934 RecordSafepoint(Safepoint::kNoLazyDeopt);
5947 } 5935 }
5948 5936
5949 5937
5950 #undef __ 5938 #undef __
5951 5939
5952 } // namespace internal 5940 } // namespace internal
5953 } // namespace v8 5941 } // namespace v8
5954 5942
5955 #endif // V8_TARGET_ARCH_X64 5943 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/objects.cc ('k') | src/x64/macro-assembler-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698