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

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

Issue 39337: Reduced the code sequence for testing for object type.... Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 9 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
« no previous file with comments | « src/builtins-ia32.cc ('k') | src/ic-ia32.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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 1916 matching lines...) Expand 10 before | Expand all | Expand 10 after
1927 ASSERT(kSmiTagSize == 1 && kSmiTag == 0); 1927 ASSERT(kSmiTagSize == 1 && kSmiTag == 0);
1928 Result switch_value = frame_->Pop(); 1928 Result switch_value = frame_->Pop();
1929 switch_value.ToRegister(); 1929 switch_value.ToRegister();
1930 __ test(switch_value.reg(), Immediate(kSmiTagMask)); 1930 __ test(switch_value.reg(), Immediate(kSmiTagMask));
1931 is_smi.Branch(equal, &switch_value, taken); 1931 is_smi.Branch(equal, &switch_value, taken);
1932 1932
1933 // It's a heap object, not a smi or a failure. Check if it is a 1933 // It's a heap object, not a smi or a failure. Check if it is a
1934 // heap number. 1934 // heap number.
1935 Result temp = allocator()->Allocate(); 1935 Result temp = allocator()->Allocate();
1936 ASSERT(temp.is_valid()); 1936 ASSERT(temp.is_valid());
1937 __ mov(temp.reg(), FieldOperand(switch_value.reg(), HeapObject::kMapOffset)); 1937 __ CmpObjectType(switch_value.reg(), HEAP_NUMBER_TYPE, temp.reg());
1938 __ movzx_b(temp.reg(), FieldOperand(temp.reg(), Map::kInstanceTypeOffset));
1939 __ cmp(temp.reg(), HEAP_NUMBER_TYPE);
1940 temp.Unuse(); 1938 temp.Unuse();
1941 default_target->Branch(not_equal); 1939 default_target->Branch(not_equal);
1942 1940
1943 // The switch value is a heap number. Convert it to a smi. 1941 // The switch value is a heap number. Convert it to a smi.
1944 frame_->Push(&switch_value); 1942 frame_->Push(&switch_value);
1945 Result smi_value = frame_->CallRuntime(Runtime::kNumberToSmi, 1); 1943 Result smi_value = frame_->CallRuntime(Runtime::kNumberToSmi, 1);
1946 1944
1947 is_smi.Bind(&smi_value); 1945 is_smi.Bind(&smi_value);
1948 smi_value.ToRegister(); 1946 smi_value.ToRegister();
1949 // Convert the switch value to a 0-based table index. 1947 // Convert the switch value to a 0-based table index.
(...skipping 2172 matching lines...) Expand 10 before | Expand all | Expand 10 after
4122 ASSERT(args->length() == 1); 4120 ASSERT(args->length() == 1);
4123 Load(args->at(0)); 4121 Load(args->at(0));
4124 Result value = frame_->Pop(); 4122 Result value = frame_->Pop();
4125 value.ToRegister(); 4123 value.ToRegister();
4126 ASSERT(value.is_valid()); 4124 ASSERT(value.is_valid());
4127 __ test(value.reg(), Immediate(kSmiTagMask)); 4125 __ test(value.reg(), Immediate(kSmiTagMask));
4128 destination()->false_target()->Branch(equal); 4126 destination()->false_target()->Branch(equal);
4129 // It is a heap object - get map. 4127 // It is a heap object - get map.
4130 Result temp = allocator()->Allocate(); 4128 Result temp = allocator()->Allocate();
4131 ASSERT(temp.is_valid()); 4129 ASSERT(temp.is_valid());
4132 __ mov(temp.reg(), FieldOperand(value.reg(), HeapObject::kMapOffset));
4133 __ movzx_b(temp.reg(), FieldOperand(temp.reg(), Map::kInstanceTypeOffset));
4134 // Check if the object is a JS array or not. 4130 // Check if the object is a JS array or not.
4135 __ cmp(temp.reg(), JS_ARRAY_TYPE); 4131 __ CmpObjectType(value.reg(), JS_ARRAY_TYPE, temp.reg());
4136 value.Unuse(); 4132 value.Unuse();
4137 temp.Unuse(); 4133 temp.Unuse();
4138 destination()->Split(equal); 4134 destination()->Split(equal);
4139 } 4135 }
4140 4136
4141 4137
4142 void CodeGenerator::GenerateArgumentsLength(ZoneList<Expression*>* args) { 4138 void CodeGenerator::GenerateArgumentsLength(ZoneList<Expression*>* args) {
4143 ASSERT(args->length() == 0); 4139 ASSERT(args->length() == 0);
4144 Result initial_value = allocator()->Allocate(eax); 4140 Result initial_value = allocator()->Allocate(eax);
4145 ASSERT(initial_value.is_valid()); 4141 ASSERT(initial_value.is_valid());
(...skipping 15 matching lines...) Expand all
4161 frame_->Dup(); 4157 frame_->Dup();
4162 Result object = frame_->Pop(); 4158 Result object = frame_->Pop();
4163 object.ToRegister(); 4159 object.ToRegister();
4164 ASSERT(object.is_valid()); 4160 ASSERT(object.is_valid());
4165 // if (object->IsSmi()) return object. 4161 // if (object->IsSmi()) return object.
4166 __ test(object.reg(), Immediate(kSmiTagMask)); 4162 __ test(object.reg(), Immediate(kSmiTagMask));
4167 leave.Branch(zero, taken); 4163 leave.Branch(zero, taken);
4168 // It is a heap object - get map. 4164 // It is a heap object - get map.
4169 Result temp = allocator()->Allocate(); 4165 Result temp = allocator()->Allocate();
4170 ASSERT(temp.is_valid()); 4166 ASSERT(temp.is_valid());
4171 __ mov(temp.reg(), FieldOperand(object.reg(), HeapObject::kMapOffset));
4172 __ movzx_b(temp.reg(), FieldOperand(temp.reg(), Map::kInstanceTypeOffset));
4173 // if (!object->IsJSValue()) return object. 4167 // if (!object->IsJSValue()) return object.
4174 __ cmp(temp.reg(), JS_VALUE_TYPE); 4168 __ CmpObjectType(object.reg(), JS_VALUE_TYPE, temp.reg());
4175 leave.Branch(not_equal, not_taken); 4169 leave.Branch(not_equal, not_taken);
4176 __ mov(temp.reg(), FieldOperand(object.reg(), JSValue::kValueOffset)); 4170 __ mov(temp.reg(), FieldOperand(object.reg(), JSValue::kValueOffset));
4177 object.Unuse(); 4171 object.Unuse();
4178 frame_->SetElementAt(0, &temp); 4172 frame_->SetElementAt(0, &temp);
4179 leave.Bind(); 4173 leave.Bind();
4180 } 4174 }
4181 4175
4182 4176
4183 void CodeGenerator::GenerateSetValueOf(ZoneList<Expression*>* args) { 4177 void CodeGenerator::GenerateSetValueOf(ZoneList<Expression*>* args) {
4184 ASSERT(args->length() == 2); 4178 ASSERT(args->length() == 2);
4185 JumpTarget leave(this); 4179 JumpTarget leave(this);
4186 Load(args->at(0)); // Load the object. 4180 Load(args->at(0)); // Load the object.
4187 Load(args->at(1)); // Load the value. 4181 Load(args->at(1)); // Load the value.
4188 Result value = frame_->Pop(); 4182 Result value = frame_->Pop();
4189 Result object = frame_->Pop(); 4183 Result object = frame_->Pop();
4190 value.ToRegister(); 4184 value.ToRegister();
4191 object.ToRegister(); 4185 object.ToRegister();
4192 4186
4193 // if (object->IsSmi()) return value. 4187 // if (object->IsSmi()) return value.
4194 __ test(object.reg(), Immediate(kSmiTagMask)); 4188 __ test(object.reg(), Immediate(kSmiTagMask));
4195 leave.Branch(zero, &value, taken); 4189 leave.Branch(zero, &value, taken);
4196 4190
4197 // It is a heap object - get its map. 4191 // It is a heap object - get its map.
4198 Result scratch = allocator_->Allocate(); 4192 Result scratch = allocator_->Allocate();
4199 ASSERT(scratch.is_valid()); 4193 ASSERT(scratch.is_valid());
4200 __ mov(scratch.reg(), FieldOperand(object.reg(), HeapObject::kMapOffset));
4201 __ movzx_b(scratch.reg(),
4202 FieldOperand(scratch.reg(), Map::kInstanceTypeOffset));
4203 // if (!object->IsJSValue()) return value. 4194 // if (!object->IsJSValue()) return value.
4204 __ cmp(scratch.reg(), JS_VALUE_TYPE); 4195 __ CmpObjectType(object.reg(), JS_VALUE_TYPE, scratch.reg());
4205 leave.Branch(not_equal, &value, not_taken); 4196 leave.Branch(not_equal, &value, not_taken);
4206 4197
4207 // Store the value. 4198 // Store the value.
4208 __ mov(FieldOperand(object.reg(), JSValue::kValueOffset), value.reg()); 4199 __ mov(FieldOperand(object.reg(), JSValue::kValueOffset), value.reg());
4209 // Update the write barrier. Save the value as it will be 4200 // Update the write barrier. Save the value as it will be
4210 // overwritten by the write barrier code and is needed afterward. 4201 // overwritten by the write barrier code and is needed afterward.
4211 Result duplicate_value = allocator_->Allocate(); 4202 Result duplicate_value = allocator_->Allocate();
4212 ASSERT(duplicate_value.is_valid()); 4203 ASSERT(duplicate_value.is_valid());
4213 __ mov(duplicate_value.reg(), value.reg()); 4204 __ mov(duplicate_value.reg(), value.reg());
4214 // The object register is also overwritten by the write barrier and 4205 // The object register is also overwritten by the write barrier and
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after
4908 __ movzx_b(answer.reg(), 4899 __ movzx_b(answer.reg(),
4909 FieldOperand(answer.reg(), Map::kBitFieldOffset)); 4900 FieldOperand(answer.reg(), Map::kBitFieldOffset));
4910 __ test(answer.reg(), Immediate(1 << Map::kIsUndetectable)); 4901 __ test(answer.reg(), Immediate(1 << Map::kIsUndetectable));
4911 answer.Unuse(); 4902 answer.Unuse();
4912 destination()->Split(not_zero); 4903 destination()->Split(not_zero);
4913 4904
4914 } else if (check->Equals(Heap::function_symbol())) { 4905 } else if (check->Equals(Heap::function_symbol())) {
4915 __ test(answer.reg(), Immediate(kSmiTagMask)); 4906 __ test(answer.reg(), Immediate(kSmiTagMask));
4916 destination()->false_target()->Branch(zero); 4907 destination()->false_target()->Branch(zero);
4917 frame_->Spill(answer.reg()); 4908 frame_->Spill(answer.reg());
4918 __ mov(answer.reg(), FieldOperand(answer.reg(), HeapObject::kMapOffset)); 4909 __ CmpObjectType(answer.reg(), JS_FUNCTION_TYPE, answer.reg());
4919 __ movzx_b(answer.reg(),
4920 FieldOperand(answer.reg(), Map::kInstanceTypeOffset));
4921 __ cmp(answer.reg(), JS_FUNCTION_TYPE);
4922 answer.Unuse(); 4910 answer.Unuse();
4923 destination()->Split(equal); 4911 destination()->Split(equal);
4924 4912
4925 } else if (check->Equals(Heap::object_symbol())) { 4913 } else if (check->Equals(Heap::object_symbol())) {
4926 __ test(answer.reg(), Immediate(kSmiTagMask)); 4914 __ test(answer.reg(), Immediate(kSmiTagMask));
4927 destination()->false_target()->Branch(zero); 4915 destination()->false_target()->Branch(zero);
4928 __ cmp(answer.reg(), Factory::null_value()); 4916 __ cmp(answer.reg(), Factory::null_value());
4929 destination()->true_target()->Branch(equal); 4917 destination()->true_target()->Branch(equal);
4930 4918
4931 // It can be an undetectable object. 4919 // It can be an undetectable object.
(...skipping 1476 matching lines...) Expand 10 before | Expand all | Expand 10 after
6408 void CallFunctionStub::Generate(MacroAssembler* masm) { 6396 void CallFunctionStub::Generate(MacroAssembler* masm) {
6409 Label slow; 6397 Label slow;
6410 6398
6411 // Get the function to call from the stack. 6399 // Get the function to call from the stack.
6412 // +2 ~ receiver, return address 6400 // +2 ~ receiver, return address
6413 __ mov(edi, Operand(esp, (argc_ + 2) * kPointerSize)); 6401 __ mov(edi, Operand(esp, (argc_ + 2) * kPointerSize));
6414 6402
6415 // Check that the function really is a JavaScript function. 6403 // Check that the function really is a JavaScript function.
6416 __ test(edi, Immediate(kSmiTagMask)); 6404 __ test(edi, Immediate(kSmiTagMask));
6417 __ j(zero, &slow, not_taken); 6405 __ j(zero, &slow, not_taken);
6418 // Get the map. 6406 // Goto slow case if we do not have a function.
6419 __ mov(ecx, FieldOperand(edi, HeapObject::kMapOffset)); 6407 __ CmpObjectType(edi, JS_FUNCTION_TYPE, ecx);
6420 __ movzx_b(ecx, FieldOperand(ecx, Map::kInstanceTypeOffset));
6421 __ cmp(ecx, JS_FUNCTION_TYPE);
6422 __ j(not_equal, &slow, not_taken); 6408 __ j(not_equal, &slow, not_taken);
6423 6409
6424 // Fast-case: Just invoke the function. 6410 // Fast-case: Just invoke the function.
6425 ParameterCount actual(argc_); 6411 ParameterCount actual(argc_);
6426 __ InvokeFunction(edi, actual, JUMP_FUNCTION); 6412 __ InvokeFunction(edi, actual, JUMP_FUNCTION);
6427 6413
6428 // Slow-case: Non-function called. 6414 // Slow-case: Non-function called.
6429 __ bind(&slow); 6415 __ bind(&slow);
6430 __ Set(eax, Immediate(argc_)); 6416 __ Set(eax, Immediate(argc_));
6431 __ Set(ebx, Immediate(0)); 6417 __ Set(ebx, Immediate(0));
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
6833 6819
6834 // Slow-case: Go through the JavaScript implementation. 6820 // Slow-case: Go through the JavaScript implementation.
6835 __ bind(&slow); 6821 __ bind(&slow);
6836 __ InvokeBuiltin(Builtins::INSTANCE_OF, JUMP_FUNCTION); 6822 __ InvokeBuiltin(Builtins::INSTANCE_OF, JUMP_FUNCTION);
6837 } 6823 }
6838 6824
6839 6825
6840 #undef __ 6826 #undef __
6841 6827
6842 } } // namespace v8::internal 6828 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/builtins-ia32.cc ('k') | src/ic-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698