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 4003 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4014 Load(args->at(0)); | 4014 Load(args->at(0)); |
| 4015 Load(args->at(1)); | 4015 Load(args->at(1)); |
| 4016 Load(args->at(2)); | 4016 Load(args->at(2)); |
| 4017 Load(args->at(3)); | 4017 Load(args->at(3)); |
| 4018 | 4018 |
| 4019 frame_->CallRuntime(Runtime::kRegExpExec, 4); | 4019 frame_->CallRuntime(Runtime::kRegExpExec, 4); |
| 4020 frame_->EmitPush(r0); | 4020 frame_->EmitPush(r0); |
| 4021 } | 4021 } |
| 4022 | 4022 |
| 4023 | 4023 |
| 4024 void CodeGenerator::GenerateRegExpConstructResult(ZoneList<Expression*>* args) { | |
| 4025 // No stub. This code only occurs a few times in regexp.js. | |
| 4026 const int kMaxInlineLength = 100; | |
| 4027 ASSERT_EQ(3, args->length()); | |
| 4028 Load(args->at(0)); // Size of array, smi. | |
| 4029 Load(args->at(1)); // "index" property value. | |
| 4030 Load(args->at(2)); // "input" property value. | |
| 4031 { | |
| 4032 VirtualFrame::SpilledScope spilled_scope(frame_); | |
| 4033 Label slowcase; | |
| 4034 Label done; | |
| 4035 __ ldr(r1, MemOperand(sp, kPointerSize * 2)); | |
| 4036 STATIC_ASSERT(kSmiTag == 0); | |
| 4037 STATIC_ASSERT(kSmiTagSize == 1); | |
| 4038 __ tst(r1, Operand(0x01)); | |
|
Søren Thygesen Gjesse
2010/04/13 07:22:29
kHeapObjectTag?
Lasse Reichstein
2010/04/13 09:50:56
That, or kSmiTagMask.
Fixed.
| |
| 4039 __ b(ne, &slowcase); | |
| 4040 __ cmp(r1, Operand(Smi::FromInt(kMaxInlineLength))); | |
| 4041 __ b(hi, &slowcase); | |
| 4042 // Smi-tagging is equivalent to multiplying by 2. | |
| 4043 // Allocate RegExpResult followed by FixedArray with size in ebx. | |
| 4044 // JSArray: [Map][empty properties][Elements][Length-smi][index][input] | |
| 4045 // Elements: [Map][Length][..elements..] | |
| 4046 // Size of JSArray with two in-object properties and the header of a | |
| 4047 // FixedArray. | |
| 4048 int objects_size = | |
| 4049 (JSArray::kRegExpResultSize + FixedArray::kHeaderSize) / kPointerSize; | |
|
Søren Thygesen Gjesse
2010/04/13 07:22:29
JSArray::kRegExpResultSize -> JSRegExpResult::kSiz
Lasse Reichstein
2010/04/13 09:50:56
Done.
| |
| 4050 __ mov(r5, Operand(r1, LSR, kSmiTagSize + kSmiShiftSize)); | |
| 4051 __ add(r2, r5, Operand(objects_size)); | |
| 4052 __ AllocateInNewSpace(r2, // In: Size, in words. | |
| 4053 r0, // Out: Start of allocation (tagged). | |
| 4054 r3, // Scratch register. | |
| 4055 r4, // Scratch register. | |
| 4056 &slowcase, | |
| 4057 TAG_OBJECT); | |
| 4058 // r0: Start of allocated area, object-tagged. | |
| 4059 // r1: Number of elements in array, as smi. | |
| 4060 // r5: Number of elements, untagged. | |
| 4061 | |
| 4062 // Set JSArray map to global.regexp_result_map(). | |
| 4063 // Set empty properties FixedArray. | |
| 4064 // Set elements to point to FixedArray allocated right after the JSArray. | |
| 4065 // Interleave operations for better latency. | |
| 4066 __ ldr(r2, ContextOperand(cp, Context::GLOBAL_INDEX)); | |
| 4067 __ add(r3, r0, Operand(JSArray::kRegExpResultSize)); | |
| 4068 __ mov(r4, Operand(Factory::empty_fixed_array())); | |
| 4069 __ ldr(r2, FieldMemOperand(r2, GlobalObject::kGlobalContextOffset)); | |
| 4070 __ str(r3, FieldMemOperand(r0, JSObject::kElementsOffset)); | |
| 4071 __ ldr(r2, ContextOperand(r2, Context::REGEXP_RESULT_MAP_INDEX)); | |
| 4072 __ str(r4, FieldMemOperand(r0, JSObject::kPropertiesOffset)); | |
| 4073 __ str(r2, FieldMemOperand(r0, HeapObject::kMapOffset)); | |
| 4074 | |
| 4075 // Set input, index and length fields from arguments. | |
| 4076 __ ldm(ia_w, sp, static_cast<RegList>(r2.bit() | r4.bit())); | |
| 4077 __ str(r1, FieldMemOperand(r0, JSArray::kLengthOffset)); | |
| 4078 __ add(sp, sp, Operand(kPointerSize)); | |
| 4079 __ str(r4, FieldMemOperand(r0, JSArray::kSize)); | |
|
Søren Thygesen Gjesse
2010/04/13 07:22:29
Please add constants JSRegExpResult::kIndexOffset
Lasse Reichstein
2010/04/13 09:50:56
Done.
| |
| 4080 __ str(r2, FieldMemOperand(r0, JSArray::kSize + kPointerSize)); | |
| 4081 | |
| 4082 // Fill out the elements FixedArray. | |
| 4083 // r0: JSArray, tagged. | |
| 4084 // r3: FixedArray, tagged. | |
| 4085 // r1: Number of elements in array, as smi. | |
|
Søren Thygesen Gjesse
2010/04/13 07:22:29
r1 -> r5 but untagged.
Lasse Reichstein
2010/04/13 09:50:56
Whoops, code and comments out of sync. Well spotte
| |
| 4086 | |
| 4087 // Set map. | |
| 4088 __ mov(r2, Operand(Factory::fixed_array_map())); | |
| 4089 __ str(r2, FieldMemOperand(r3, HeapObject::kMapOffset)); | |
| 4090 // Untag r1 and set FixedArray length. | |
|
Søren Thygesen Gjesse
2010/04/13 07:22:29
Remove "Untag r1 and ".
Lasse Reichstein
2010/04/13 09:50:56
Done.
| |
| 4091 __ str(r5, FieldMemOperand(r3, FixedArray::kLengthOffset)); | |
| 4092 // Fill contents of fixed-array with the-hole. | |
| 4093 __ mov(r2, Operand(Factory::the_hole_value())); | |
| 4094 __ add(r3, r3, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); | |
| 4095 // Fill fixed array elements with hole. | |
| 4096 // r0: JSArray, tagged. | |
| 4097 // r1: Number of elements to fill. | |
| 4098 // r3: Start of elements in FixedArray. | |
| 4099 // r2: the hole. | |
|
Søren Thygesen Gjesse
2010/04/13 07:22:29
Add r5 to this comment.
Lasse Reichstein
2010/04/13 09:50:56
Fixed, r1->r5.
| |
| 4100 Label loop; | |
| 4101 __ tst(r5, Operand(r5)); | |
| 4102 __ bind(&loop); | |
| 4103 __ b(le, &done); // Jump if r1 is negative or zero. | |
| 4104 __ sub(r5, r5, Operand(1), SetCC); | |
| 4105 __ str(r2, MemOperand(r3, r5, LSL, kPointerSizeLog2)); | |
| 4106 __ jmp(&loop); | |
| 4107 | |
| 4108 __ bind(&slowcase); | |
| 4109 __ CallRuntime(Runtime::kRegExpConstructResult, 3); | |
| 4110 | |
| 4111 __ bind(&done); | |
| 4112 } | |
| 4113 frame_->Forget(3); | |
| 4114 frame_->EmitPush(r0); | |
| 4115 } | |
| 4116 | |
| 4117 | |
| 4024 void CodeGenerator::GenerateNumberToString(ZoneList<Expression*>* args) { | 4118 void CodeGenerator::GenerateNumberToString(ZoneList<Expression*>* args) { |
| 4025 ASSERT_EQ(args->length(), 1); | 4119 ASSERT_EQ(args->length(), 1); |
| 4026 | 4120 |
| 4027 // Load the argument on the stack and jump to the runtime. | 4121 // Load the argument on the stack and jump to the runtime. |
| 4028 Load(args->at(0)); | 4122 Load(args->at(0)); |
| 4029 | 4123 |
| 4030 NumberToStringStub stub; | 4124 NumberToStringStub stub; |
| 4031 frame_->CallStub(&stub, 1); | 4125 frame_->CallStub(&stub, 1); |
| 4032 frame_->EmitPush(r0); | 4126 frame_->EmitPush(r0); |
| 4033 } | 4127 } |
| (...skipping 4361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8395 | 8489 |
| 8396 // Just jump to runtime to add the two strings. | 8490 // Just jump to runtime to add the two strings. |
| 8397 __ bind(&string_add_runtime); | 8491 __ bind(&string_add_runtime); |
| 8398 __ TailCallRuntime(Runtime::kStringAdd, 2, 1); | 8492 __ TailCallRuntime(Runtime::kStringAdd, 2, 1); |
| 8399 } | 8493 } |
| 8400 | 8494 |
| 8401 | 8495 |
| 8402 #undef __ | 8496 #undef __ |
| 8403 | 8497 |
| 8404 } } // namespace v8::internal | 8498 } } // namespace v8::internal |
| OLD | NEW |