Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 4112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4123 Load(args->at(0)); | 4123 Load(args->at(0)); |
| 4124 Load(args->at(1)); | 4124 Load(args->at(1)); |
| 4125 Load(args->at(2)); | 4125 Load(args->at(2)); |
| 4126 Load(args->at(3)); | 4126 Load(args->at(3)); |
| 4127 RegExpExecStub stub; | 4127 RegExpExecStub stub; |
| 4128 Result result = frame_->CallStub(&stub, 4); | 4128 Result result = frame_->CallStub(&stub, 4); |
| 4129 frame_->Push(&result); | 4129 frame_->Push(&result); |
| 4130 } | 4130 } |
| 4131 | 4131 |
| 4132 | 4132 |
| 4133 void CodeGenerator::GenerateRegExpConstructResult(ZoneList<Expression*>* args) { | |
| 4134 // No stub. This code only occurs a few times in regexp.js. | |
| 4135 const int kMaxInlineLength = 100; | |
| 4136 ASSERT_EQ(3, args->length()); | |
| 4137 Load(args->at(0)); // Size of array, smi. | |
| 4138 Load(args->at(1)); // "index" property value. | |
| 4139 Load(args->at(2)); // "input" property value. | |
| 4140 { | |
| 4141 VirtualFrame::SpilledScope spilled_scope; | |
| 4142 | |
| 4143 Label slowcase; | |
| 4144 Label done; | |
| 4145 __ movq(r8, Operand(rsp, kPointerSize * 2)); | |
| 4146 __ JumpIfNotSmi(r8, &slowcase); | |
| 4147 __ SmiToInteger32(rbx, r8); | |
| 4148 __ cmpl(rbx, Immediate(kMaxInlineLength)); | |
| 4149 __ j(above, &slowcase); | |
| 4150 // Smi-tagging is equivalent to multiplying by 2. | |
| 4151 STATIC_ASSERT(kSmiTag == 0); | |
| 4152 STATIC_ASSERT(kSmiTagSize == 1); | |
| 4153 // Allocate RegExpResult followed by FixedArray with size in ebx. | |
| 4154 // JSArray: [Map][empty properties][Elements][Length-smi][index][input] | |
| 4155 // Elements: [Map][Length][..elements..] | |
| 4156 __ AllocateInNewSpace(JSArray::kRegExpResultSize + FixedArray::kHeaderSize, | |
| 4157 times_pointer_size, | |
| 4158 rbx, // In: Number of elements. | |
| 4159 rax, // Out: Start of allocation (tagged). | |
| 4160 rcx, // Out: End of allocation. | |
| 4161 rdx, // Scratch register | |
| 4162 &slowcase, | |
| 4163 TAG_OBJECT); | |
| 4164 // rax: Start of allocated area, object-tagged. | |
| 4165 // rbx: Number of array elements as int32. | |
| 4166 // r8: Number of array elements as smi. | |
| 4167 | |
| 4168 // Set JSArray map to global.regexp_result_map(). | |
| 4169 __ movq(rdx, ContextOperand(rsi, Context::GLOBAL_INDEX)); | |
| 4170 __ movq(rdx, FieldOperand(rdx, GlobalObject::kGlobalContextOffset)); | |
| 4171 __ movq(rdx, ContextOperand(rdx, Context::REGEXP_RESULT_MAP_INDEX)); | |
| 4172 __ movq(FieldOperand(rax, HeapObject::kMapOffset), rdx); | |
| 4173 | |
| 4174 // Set empty properties FixedArray. | |
| 4175 __ Move(FieldOperand(rax, JSObject::kPropertiesOffset), | |
| 4176 Factory::empty_fixed_array()); | |
| 4177 | |
| 4178 // Set elements to point to FixedArray allocated right after the JSArray. | |
| 4179 __ lea(rcx, Operand(rax, JSArray::kRegExpResultSize)); | |
|
Lasse Reichstein
2010/04/13 09:50:56
Size moved to JSRegExpResult.
| |
| 4180 __ movq(FieldOperand(rax, JSObject::kElementsOffset), rcx); | |
| 4181 | |
| 4182 // Set input, index and length fields from arguments. | |
| 4183 __ pop(FieldOperand(rax, JSArray::kSize + kPointerSize)); | |
|
Søren Thygesen Gjesse
2010/04/13 07:22:29
Please add constants JSRegExpResult::kIndexOffset
Lasse Reichstein
2010/04/13 09:50:56
Done.
| |
| 4184 __ pop(FieldOperand(rax, JSArray::kSize)); | |
| 4185 __ lea(rsp, Operand(rsp, kPointerSize)); | |
| 4186 __ movq(FieldOperand(rax, JSArray::kLengthOffset), r8); | |
| 4187 | |
| 4188 // Fill out the elements FixedArray. | |
| 4189 // rax: JSArray. | |
| 4190 // rcx: FixedArray. | |
| 4191 // rbx: Number of elements in array. | |
|
Søren Thygesen Gjesse
2010/04/13 07:22:29
Maybe keep the same dsctiption for rbx "Number of
Lasse Reichstein
2010/04/13 09:50:56
Done.
| |
| 4192 | |
| 4193 // Set map. | |
| 4194 __ Move(FieldOperand(rcx, HeapObject::kMapOffset), | |
| 4195 Factory::fixed_array_map()); | |
| 4196 // Set length. | |
| 4197 __ movq(FieldOperand(rcx, FixedArray::kLengthOffset), rbx); | |
| 4198 // Fill contents of fixed-array with the-hole. | |
| 4199 __ Move(rdx, Factory::the_hole_value()); | |
| 4200 __ lea(rcx, FieldOperand(rcx, FixedArray::kHeaderSize)); | |
| 4201 // Fill fixed array elements with hole. | |
| 4202 // rax: JSArray. | |
| 4203 // rbx: Number of elements to fill (as int32). | |
|
Søren Thygesen Gjesse
2010/04/13 07:22:29
Ditto.
Lasse Reichstein
2010/04/13 09:50:56
Done, slightly reworded (since rbx is modified in
| |
| 4204 // rcx: Start of elements in FixedArray. | |
| 4205 // rdx: the hole. | |
| 4206 Label loop; | |
| 4207 __ testl(rbx, rbx); | |
| 4208 __ bind(&loop); | |
| 4209 __ j(less_equal, &done); // Jump if ecx is negative or zero. | |
| 4210 __ subl(rbx, Immediate(1)); | |
| 4211 __ movq(Operand(rcx, rbx, times_pointer_size, 0), rdx); | |
| 4212 __ jmp(&loop); | |
| 4213 | |
| 4214 __ bind(&slowcase); | |
| 4215 __ CallRuntime(Runtime::kRegExpConstructResult, 3); | |
| 4216 | |
| 4217 __ bind(&done); | |
| 4218 } | |
| 4219 frame_->Forget(3); | |
| 4220 frame_->Push(rax); | |
| 4221 } | |
| 4222 | |
| 4223 | |
| 4133 void CodeGenerator::GenerateNumberToString(ZoneList<Expression*>* args) { | 4224 void CodeGenerator::GenerateNumberToString(ZoneList<Expression*>* args) { |
| 4134 ASSERT_EQ(args->length(), 1); | 4225 ASSERT_EQ(args->length(), 1); |
| 4135 | 4226 |
| 4136 // Load the argument on the stack and jump to the runtime. | 4227 // Load the argument on the stack and jump to the runtime. |
| 4137 Load(args->at(0)); | 4228 Load(args->at(0)); |
| 4138 | 4229 |
| 4139 NumberToStringStub stub; | 4230 NumberToStringStub stub; |
| 4140 Result result = frame_->CallStub(&stub, 1); | 4231 Result result = frame_->CallStub(&stub, 1); |
| 4141 frame_->Push(&result); | 4232 frame_->Push(&result); |
| 4142 } | 4233 } |
| (...skipping 5932 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10075 // Call the function from C++. | 10166 // Call the function from C++. |
| 10076 return FUNCTION_CAST<ModuloFunction>(buffer); | 10167 return FUNCTION_CAST<ModuloFunction>(buffer); |
| 10077 } | 10168 } |
| 10078 | 10169 |
| 10079 #endif | 10170 #endif |
| 10080 | 10171 |
| 10081 | 10172 |
| 10082 #undef __ | 10173 #undef __ |
| 10083 | 10174 |
| 10084 } } // namespace v8::internal | 10175 } } // namespace v8::internal |
| OLD | NEW |