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

Side by Side Diff: src/full-codegen/mips/full-codegen-mips.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
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_MIPS 5 #if V8_TARGET_ARCH_MIPS
6 6
7 // Note on Mips implementation: 7 // Note on Mips implementation:
8 // 8 //
9 // The result_register() for mips is the 'v0' register, which is defined 9 // The result_register() for mips is the 'v0' register, which is defined
10 // by the ABI to contain function return values. However, the first 10 // by the ABI to contain function return values. However, the first
(...skipping 3658 matching lines...) Expand 10 before | Expand all | Expand 10 after
3669 // adaptor frame. 3669 // adaptor frame.
3670 __ lw(v0, MemOperand(a2, ArgumentsAdaptorFrameConstants::kLengthOffset)); 3670 __ lw(v0, MemOperand(a2, ArgumentsAdaptorFrameConstants::kLengthOffset));
3671 3671
3672 __ bind(&exit); 3672 __ bind(&exit);
3673 context()->Plug(v0); 3673 context()->Plug(v0);
3674 } 3674 }
3675 3675
3676 3676
3677 void FullCodeGenerator::EmitClassOf(CallRuntime* expr) { 3677 void FullCodeGenerator::EmitClassOf(CallRuntime* expr) {
3678 ZoneList<Expression*>* args = expr->arguments(); 3678 ZoneList<Expression*>* args = expr->arguments();
3679 DCHECK(args->length() == 1); 3679 DCHECK_EQ(1, args->length());
3680 Label done, null, function, non_function_constructor; 3680 Label done, null, function, non_function_constructor;
3681 3681
3682 VisitForAccumulatorValue(args->at(0)); 3682 VisitForAccumulatorValue(args->at(0));
3683 3683
3684 // If the object is a smi, we return null. 3684 // If the object is a smi, we return null.
3685 __ JumpIfSmi(v0, &null); 3685 __ JumpIfSmi(v0, &null);
3686 3686
3687 // Check that the object is a JS object but take special care of JS 3687 // If the object is not a receiver, we return null.
3688 // functions to make sure they have 'Function' as their class. 3688 STATIC_ASSERT(LAST_JS_RECEIVER_TYPE == LAST_TYPE);
3689 // Assume that there are only two callable types, and one of them is at
3690 // either end of the type range for JS object types. Saves extra comparisons.
3691 STATIC_ASSERT(NUM_OF_CALLABLE_SPEC_OBJECT_TYPES == 2);
3692 __ GetObjectType(v0, v0, a1); // Map is now in v0. 3689 __ GetObjectType(v0, v0, a1); // Map is now in v0.
3693 __ Branch(&null, lt, a1, Operand(FIRST_SPEC_OBJECT_TYPE)); 3690 __ Branch(&null, lt, a1, Operand(FIRST_JS_RECEIVER_TYPE));
3694 3691
3695 STATIC_ASSERT(FIRST_NONCALLABLE_SPEC_OBJECT_TYPE == 3692 // According to ES5 section 15 Standard Built-in ECMAScript Objects, the
3696 FIRST_SPEC_OBJECT_TYPE + 1); 3693 // [[Class]] of builtin objects is "Function" if a [[Call]] internal
3697 __ Branch(&function, eq, a1, Operand(FIRST_SPEC_OBJECT_TYPE)); 3694 // method is present.
3698 3695 __ lbu(a1, FieldMemOperand(v0, Map::kBitFieldOffset));
3699 STATIC_ASSERT(LAST_NONCALLABLE_SPEC_OBJECT_TYPE == 3696 __ And(a1, a1, Operand(1 << Map::kIsCallable));
3700 LAST_SPEC_OBJECT_TYPE - 1); 3697 __ Branch(&function, ne, a1, Operand(zero_reg));
3701 __ Branch(&function, eq, a1, Operand(LAST_SPEC_OBJECT_TYPE));
3702 // Assume that there is no larger type.
3703 STATIC_ASSERT(LAST_NONCALLABLE_SPEC_OBJECT_TYPE == LAST_TYPE - 1);
3704 3698
3705 // Check if the constructor in the map is a JS function. 3699 // Check if the constructor in the map is a JS function.
3706 Register instance_type = a2; 3700 Register instance_type = a2;
3707 __ GetMapConstructor(v0, v0, a1, instance_type); 3701 __ GetMapConstructor(v0, v0, a1, instance_type);
3708 __ Branch(&non_function_constructor, ne, instance_type, 3702 __ Branch(&non_function_constructor, ne, instance_type,
3709 Operand(JS_FUNCTION_TYPE)); 3703 Operand(JS_FUNCTION_TYPE));
3710 3704
3711 // v0 now contains the constructor function. Grab the 3705 // v0 now contains the constructor function. Grab the
3712 // instance class name from there. 3706 // instance class name from there.
3713 __ lw(v0, FieldMemOperand(v0, JSFunction::kSharedFunctionInfoOffset)); 3707 __ lw(v0, FieldMemOperand(v0, JSFunction::kSharedFunctionInfoOffset));
(...skipping 1607 matching lines...) Expand 10 before | Expand all | Expand 10 after
5321 reinterpret_cast<uint32_t>( 5315 reinterpret_cast<uint32_t>(
5322 isolate->builtins()->OsrAfterStackCheck()->entry())); 5316 isolate->builtins()->OsrAfterStackCheck()->entry()));
5323 return OSR_AFTER_STACK_CHECK; 5317 return OSR_AFTER_STACK_CHECK;
5324 } 5318 }
5325 5319
5326 5320
5327 } // namespace internal 5321 } // namespace internal
5328 } // namespace v8 5322 } // namespace v8
5329 5323
5330 #endif // V8_TARGET_ARCH_MIPS 5324 #endif // V8_TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « src/full-codegen/ia32/full-codegen-ia32.cc ('k') | src/full-codegen/mips64/full-codegen-mips64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698