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

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

Issue 6992072: Implement set trap for proxies, and revamp class hierarchy in preparation (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 1641 matching lines...) Expand 10 before | Expand all | Expand 10 after
1652 __ cmp(input, isolate()->factory()->null_value()); 1652 __ cmp(input, isolate()->factory()->null_value());
1653 __ j(equal, is_object); 1653 __ j(equal, is_object);
1654 1654
1655 __ mov(temp1, FieldOperand(input, HeapObject::kMapOffset)); 1655 __ mov(temp1, FieldOperand(input, HeapObject::kMapOffset));
1656 // Undetectable objects behave like undefined. 1656 // Undetectable objects behave like undefined.
1657 __ movzx_b(temp2, FieldOperand(temp1, Map::kBitFieldOffset)); 1657 __ movzx_b(temp2, FieldOperand(temp1, Map::kBitFieldOffset));
1658 __ test(temp2, Immediate(1 << Map::kIsUndetectable)); 1658 __ test(temp2, Immediate(1 << Map::kIsUndetectable));
1659 __ j(not_zero, is_not_object); 1659 __ j(not_zero, is_not_object);
1660 1660
1661 __ movzx_b(temp2, FieldOperand(temp1, Map::kInstanceTypeOffset)); 1661 __ movzx_b(temp2, FieldOperand(temp1, Map::kInstanceTypeOffset));
1662 __ cmp(temp2, FIRST_JS_OBJECT_TYPE); 1662 __ cmp(temp2, FIRST_OBJECT_CLASS_TYPE);
1663 __ j(below, is_not_object); 1663 __ j(below, is_not_object);
1664 __ cmp(temp2, LAST_JS_OBJECT_TYPE); 1664 __ cmp(temp2, LAST_OBJECT_CLASS_TYPE);
1665 return below_equal; 1665 return below_equal;
1666 } 1666 }
1667 1667
1668 1668
1669 void LCodeGen::DoIsObject(LIsObject* instr) { 1669 void LCodeGen::DoIsObject(LIsObject* instr) {
1670 Register reg = ToRegister(instr->InputAt(0)); 1670 Register reg = ToRegister(instr->InputAt(0));
1671 Register result = ToRegister(instr->result()); 1671 Register result = ToRegister(instr->result());
1672 Register temp = ToRegister(instr->TempAt(0)); 1672 Register temp = ToRegister(instr->TempAt(0));
1673 Label is_false, is_true, done; 1673 Label is_false, is_true, done;
1674 1674
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
1867 void LCodeGen::EmitClassOfTest(Label* is_true, 1867 void LCodeGen::EmitClassOfTest(Label* is_true,
1868 Label* is_false, 1868 Label* is_false,
1869 Handle<String>class_name, 1869 Handle<String>class_name,
1870 Register input, 1870 Register input,
1871 Register temp, 1871 Register temp,
1872 Register temp2) { 1872 Register temp2) {
1873 ASSERT(!input.is(temp)); 1873 ASSERT(!input.is(temp));
1874 ASSERT(!temp.is(temp2)); // But input and temp2 may be the same register. 1874 ASSERT(!temp.is(temp2)); // But input and temp2 may be the same register.
1875 __ test(input, Immediate(kSmiTagMask)); 1875 __ test(input, Immediate(kSmiTagMask));
1876 __ j(zero, is_false); 1876 __ j(zero, is_false);
1877 __ CmpObjectType(input, FIRST_JS_OBJECT_TYPE, temp); 1877 __ CmpObjectType(input, FIRST_OBJECT_OR_FUNCTION_CLASS_TYPE, temp);
1878 __ j(below, is_false); 1878 __ j(below, is_false);
1879 1879
1880 // Map is now in temp. 1880 // Map is now in temp.
1881 // Functions have class 'Function'. 1881 // Functions have class 'Function'.
1882 __ CmpInstanceType(temp, JS_FUNCTION_TYPE); 1882 __ CmpInstanceType(temp, FIRST_FUNCTION_CLASS_TYPE);
1883 if (class_name->IsEqualTo(CStrVector("Function"))) { 1883 if (class_name->IsEqualTo(CStrVector("Function"))) {
1884 __ j(equal, is_true); 1884 __ j(greater_equal, is_true);
1885 } else { 1885 } else {
1886 __ j(equal, is_false); 1886 __ j(greater_equal, is_false);
1887 } 1887 }
1888 1888
1889 // Check if the constructor in the map is a function. 1889 // Check if the constructor in the map is a function.
1890 __ mov(temp, FieldOperand(temp, Map::kConstructorOffset)); 1890 __ mov(temp, FieldOperand(temp, Map::kConstructorOffset));
1891 1891
1892 // As long as JS_FUNCTION_TYPE is the last instance type and it is 1892 // As long as LAST_FUNCTION_CLASS_TYPE is the last instance type,
1893 // right after LAST_JS_OBJECT_TYPE, we can avoid checking for 1893 // and FIRST_FUNCTION_CLASS_TYPE comes right after LAST_OBJECT_CLASS_TYPE,
1894 // LAST_JS_OBJECT_TYPE. 1894 // we can avoid checking for LAST_OBJECT_CLASS_TYPE.
1895 ASSERT(LAST_TYPE == JS_FUNCTION_TYPE); 1895 ASSERT(LAST_TYPE == LAST_FUNCTION_CLASS_TYPE);
1896 ASSERT(JS_FUNCTION_TYPE == LAST_JS_OBJECT_TYPE + 1); 1896 ASSERT(FIRST_FUNCTION_CLASS_TYPE == LAST_OBJECT_CLASS_TYPE + 1);
1897 1897
1898 // Objects with a non-function constructor have class 'Object'. 1898 // Objects with a non-function constructor have class 'Object'.
1899 __ CmpObjectType(temp, JS_FUNCTION_TYPE, temp2); 1899 __ CmpObjectType(temp, JS_FUNCTION_TYPE, temp2);
1900 if (class_name->IsEqualTo(CStrVector("Object"))) { 1900 if (class_name->IsEqualTo(CStrVector("Object"))) {
1901 __ j(not_equal, is_true); 1901 __ j(not_equal, is_true);
1902 } else { 1902 } else {
1903 __ j(not_equal, is_false); 1903 __ j(not_equal, is_false);
1904 } 1904 }
1905 1905
1906 // temp now contains the constructor function. Grab the 1906 // temp now contains the constructor function. Grab the
(...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after
2591 // as a receiver. 2591 // as a receiver.
2592 Label global_object, receiver_ok; 2592 Label global_object, receiver_ok;
2593 __ cmp(receiver, factory()->null_value()); 2593 __ cmp(receiver, factory()->null_value());
2594 __ j(equal, &global_object, Label::kNear); 2594 __ j(equal, &global_object, Label::kNear);
2595 __ cmp(receiver, factory()->undefined_value()); 2595 __ cmp(receiver, factory()->undefined_value());
2596 __ j(equal, &global_object, Label::kNear); 2596 __ j(equal, &global_object, Label::kNear);
2597 2597
2598 // The receiver should be a JS object. 2598 // The receiver should be a JS object.
2599 __ test(receiver, Immediate(kSmiTagMask)); 2599 __ test(receiver, Immediate(kSmiTagMask));
2600 DeoptimizeIf(equal, instr->environment()); 2600 DeoptimizeIf(equal, instr->environment());
2601 __ CmpObjectType(receiver, FIRST_JS_OBJECT_TYPE, scratch); 2601 __ CmpObjectType(receiver, FIRST_OBJECT_OR_FUNCTION_CLASS_TYPE, scratch);
2602 DeoptimizeIf(below, instr->environment()); 2602 DeoptimizeIf(below, instr->environment());
2603 __ jmp(&receiver_ok, Label::kNear); 2603 __ jmp(&receiver_ok, Label::kNear);
2604 2604
2605 __ bind(&global_object); 2605 __ bind(&global_object);
2606 // TODO(kmillikin): We have a hydrogen value for the global object. See 2606 // TODO(kmillikin): We have a hydrogen value for the global object. See
2607 // if it's better to use it than to explicitly fetch it from the context 2607 // if it's better to use it than to explicitly fetch it from the context
2608 // here. 2608 // here.
2609 __ mov(receiver, Operand(ebp, StandardFrameConstants::kContextOffset)); 2609 __ mov(receiver, Operand(ebp, StandardFrameConstants::kContextOffset));
2610 __ mov(receiver, ContextOperand(receiver, Context::GLOBAL_INDEX)); 2610 __ mov(receiver, ContextOperand(receiver, Context::GLOBAL_INDEX));
2611 __ bind(&receiver_ok); 2611 __ bind(&receiver_ok);
(...skipping 1639 matching lines...) Expand 10 before | Expand all | Expand 10 after
4251 __ cmp(input, factory()->undefined_value()); 4251 __ cmp(input, factory()->undefined_value());
4252 __ j(equal, true_label); 4252 __ j(equal, true_label);
4253 __ JumpIfSmi(input, false_label); 4253 __ JumpIfSmi(input, false_label);
4254 // Check for undetectable objects => true. 4254 // Check for undetectable objects => true.
4255 __ mov(input, FieldOperand(input, HeapObject::kMapOffset)); 4255 __ mov(input, FieldOperand(input, HeapObject::kMapOffset));
4256 __ test_b(FieldOperand(input, Map::kBitFieldOffset), 4256 __ test_b(FieldOperand(input, Map::kBitFieldOffset),
4257 1 << Map::kIsUndetectable); 4257 1 << Map::kIsUndetectable);
4258 final_branch_condition = not_zero; 4258 final_branch_condition = not_zero;
4259 4259
4260 } else if (type_name->Equals(heap()->function_symbol())) { 4260 } else if (type_name->Equals(heap()->function_symbol())) {
4261 ASSERT(LAST_TYPE == LAST_FUNCTION_CLASS_TYPE);
4261 __ JumpIfSmi(input, false_label); 4262 __ JumpIfSmi(input, false_label);
4262 __ CmpObjectType(input, JS_FUNCTION_TYPE, input); 4263 __ CmpObjectType(input, FIRST_FUNCTION_CLASS_TYPE, input);
4263 __ j(equal, true_label); 4264 final_branch_condition = above_equal;
4264 // Regular expressions => 'function' (they are callable).
4265 __ CmpInstanceType(input, JS_REGEXP_TYPE);
4266 final_branch_condition = equal;
4267 4265
4268 } else if (type_name->Equals(heap()->object_symbol())) { 4266 } else if (type_name->Equals(heap()->object_symbol())) {
4269 __ JumpIfSmi(input, false_label); 4267 __ JumpIfSmi(input, false_label);
4270 __ cmp(input, factory()->null_value()); 4268 __ cmp(input, factory()->null_value());
4271 __ j(equal, true_label); 4269 __ j(equal, true_label);
4272 // Regular expressions => 'function', not 'object'. 4270 // Regular expressions => 'function', not 'object'.
4273 __ CmpObjectType(input, FIRST_JS_OBJECT_TYPE, input); 4271 __ CmpObjectType(input, FIRST_OBJECT_CLASS_TYPE, input);
4274 __ j(below, false_label); 4272 __ j(below, false_label);
4275 __ CmpInstanceType(input, FIRST_FUNCTION_CLASS_TYPE); 4273 __ CmpInstanceType(input, LAST_OBJECT_CLASS_TYPE);
4276 __ j(above_equal, false_label); 4274 __ j(above, false_label);
4277 // Check for undetectable objects => false. 4275 // Check for undetectable objects => false.
4278 __ test_b(FieldOperand(input, Map::kBitFieldOffset), 4276 __ test_b(FieldOperand(input, Map::kBitFieldOffset),
4279 1 << Map::kIsUndetectable); 4277 1 << Map::kIsUndetectable);
4280 final_branch_condition = zero; 4278 final_branch_condition = zero;
4281 4279
4282 } else { 4280 } else {
4283 final_branch_condition = not_equal; 4281 final_branch_condition = not_equal;
4284 __ jmp(false_label); 4282 __ jmp(false_label);
4285 // A dead branch instruction will be generated after this point. 4283 // A dead branch instruction will be generated after this point.
4286 } 4284 }
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
4430 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); 4428 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset));
4431 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION, safepoint_generator); 4429 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION, safepoint_generator);
4432 } 4430 }
4433 4431
4434 4432
4435 #undef __ 4433 #undef __
4436 4434
4437 } } // namespace v8::internal 4435 } } // namespace v8::internal
4438 4436
4439 #endif // V8_TARGET_ARCH_IA32 4437 #endif // V8_TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698