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

Side by Side Diff: src/ia32/lithium-codegen-ia32.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/full-codegen/x64/full-codegen-x64.cc ('k') | src/ia32/macro-assembler-ia32.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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_IA32 5 #if V8_TARGET_ARCH_IA32
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/codegen.h" 10 #include "src/codegen.h"
(...skipping 2503 matching lines...) Expand 10 before | Expand all | Expand 10 after
2514 Label* is_false, 2514 Label* is_false,
2515 Handle<String>class_name, 2515 Handle<String>class_name,
2516 Register input, 2516 Register input,
2517 Register temp, 2517 Register temp,
2518 Register temp2) { 2518 Register temp2) {
2519 DCHECK(!input.is(temp)); 2519 DCHECK(!input.is(temp));
2520 DCHECK(!input.is(temp2)); 2520 DCHECK(!input.is(temp2));
2521 DCHECK(!temp.is(temp2)); 2521 DCHECK(!temp.is(temp2));
2522 __ JumpIfSmi(input, is_false); 2522 __ JumpIfSmi(input, is_false);
2523 2523
2524 STATIC_ASSERT(LAST_JS_RECEIVER_TYPE == LAST_TYPE);
2525 __ CmpObjectType(input, FIRST_JS_RECEIVER_TYPE, temp);
2526 __ j(below, is_false);
2527
2528 // Objects with [[Call]] have class 'Function'.
2529 __ test_b(FieldOperand(temp, Map::kBitFieldOffset), 1 << Map::kIsCallable);
2524 if (String::Equals(isolate()->factory()->Function_string(), class_name)) { 2530 if (String::Equals(isolate()->factory()->Function_string(), class_name)) {
2525 // Assuming the following assertions, we can use the same compares to test 2531 __ j(not_zero, is_true);
2526 // for both being a function type and being in the object type range.
2527 STATIC_ASSERT(NUM_OF_CALLABLE_SPEC_OBJECT_TYPES == 2);
2528 STATIC_ASSERT(FIRST_NONCALLABLE_SPEC_OBJECT_TYPE ==
2529 FIRST_SPEC_OBJECT_TYPE + 1);
2530 STATIC_ASSERT(LAST_NONCALLABLE_SPEC_OBJECT_TYPE ==
2531 LAST_SPEC_OBJECT_TYPE - 1);
2532 STATIC_ASSERT(LAST_SPEC_OBJECT_TYPE == LAST_TYPE);
2533 __ CmpObjectType(input, FIRST_SPEC_OBJECT_TYPE, temp);
2534 __ j(below, is_false);
2535 __ j(equal, is_true);
2536 __ CmpInstanceType(temp, LAST_SPEC_OBJECT_TYPE);
2537 __ j(equal, is_true);
2538 } else { 2532 } else {
2539 // Faster code path to avoid two compares: subtract lower bound from the 2533 __ j(not_zero, is_false);
2540 // actual type and do a signed compare with the width of the type range.
2541 __ mov(temp, FieldOperand(input, HeapObject::kMapOffset));
2542 __ movzx_b(temp2, FieldOperand(temp, Map::kInstanceTypeOffset));
2543 __ sub(Operand(temp2), Immediate(FIRST_NONCALLABLE_SPEC_OBJECT_TYPE));
2544 __ cmp(Operand(temp2), Immediate(LAST_NONCALLABLE_SPEC_OBJECT_TYPE -
2545 FIRST_NONCALLABLE_SPEC_OBJECT_TYPE));
2546 __ j(above, is_false);
2547 } 2534 }
2548 2535
2549 // Now we are in the FIRST-LAST_NONCALLABLE_SPEC_OBJECT_TYPE range. 2536 // Now we are in the FIRST-LAST_JS_RECEIVER_TYPE range.
2550 // Check if the constructor in the map is a function. 2537 // Check if the constructor in the map is a function.
2551 __ GetMapConstructor(temp, temp, temp2); 2538 __ GetMapConstructor(temp, temp, temp2);
2552 // Objects with a non-function constructor have class 'Object'. 2539 // Objects with a non-function constructor have class 'Object'.
2553 __ CmpInstanceType(temp2, JS_FUNCTION_TYPE); 2540 __ CmpInstanceType(temp2, JS_FUNCTION_TYPE);
2554 if (String::Equals(class_name, isolate()->factory()->Object_string())) { 2541 if (String::Equals(class_name, isolate()->factory()->Object_string())) {
2555 __ j(not_equal, is_true); 2542 __ j(not_equal, is_true);
2556 } else { 2543 } else {
2557 __ j(not_equal, is_false); 2544 __ j(not_equal, is_false);
2558 } 2545 }
2559 2546
(...skipping 3194 matching lines...) Expand 10 before | Expand all | Expand 10 after
5754 RecordSafepoint(Safepoint::kNoLazyDeopt); 5741 RecordSafepoint(Safepoint::kNoLazyDeopt);
5755 } 5742 }
5756 5743
5757 5744
5758 #undef __ 5745 #undef __
5759 5746
5760 } // namespace internal 5747 } // namespace internal
5761 } // namespace v8 5748 } // namespace v8
5762 5749
5763 #endif // V8_TARGET_ARCH_IA32 5750 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/full-codegen/x64/full-codegen-x64.cc ('k') | src/ia32/macro-assembler-ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698