| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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_X64 | 5 #if V8_TARGET_ARCH_X64 |
| 6 | 6 |
| 7 #include "src/crankshaft/x64/lithium-codegen-x64.h" | 7 #include "src/crankshaft/x64/lithium-codegen-x64.h" |
| 8 | 8 |
| 9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
| 10 #include "src/code-factory.h" | 10 #include "src/code-factory.h" |
| (...skipping 5359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5370 } | 5370 } |
| 5371 | 5371 |
| 5372 | 5372 |
| 5373 void LCodeGen::DoToFastProperties(LToFastProperties* instr) { | 5373 void LCodeGen::DoToFastProperties(LToFastProperties* instr) { |
| 5374 DCHECK(ToRegister(instr->value()).is(rax)); | 5374 DCHECK(ToRegister(instr->value()).is(rax)); |
| 5375 __ Push(rax); | 5375 __ Push(rax); |
| 5376 CallRuntime(Runtime::kToFastProperties, 1, instr); | 5376 CallRuntime(Runtime::kToFastProperties, 1, instr); |
| 5377 } | 5377 } |
| 5378 | 5378 |
| 5379 | 5379 |
| 5380 void LCodeGen::DoRegExpLiteral(LRegExpLiteral* instr) { | |
| 5381 DCHECK(ToRegister(instr->context()).is(rsi)); | |
| 5382 Label materialized; | |
| 5383 // Registers will be used as follows: | |
| 5384 // rcx = literals array. | |
| 5385 // rbx = regexp literal. | |
| 5386 // rax = regexp literal clone. | |
| 5387 int literal_offset = | |
| 5388 LiteralsArray::OffsetOfLiteralAt(instr->hydrogen()->literal_index()); | |
| 5389 __ Move(rcx, instr->hydrogen()->literals()); | |
| 5390 __ movp(rbx, FieldOperand(rcx, literal_offset)); | |
| 5391 __ CompareRoot(rbx, Heap::kUndefinedValueRootIndex); | |
| 5392 __ j(not_equal, &materialized, Label::kNear); | |
| 5393 | |
| 5394 // Create regexp literal using runtime function | |
| 5395 // Result will be in rax. | |
| 5396 __ Push(rcx); | |
| 5397 __ Push(Smi::FromInt(instr->hydrogen()->literal_index())); | |
| 5398 __ Push(instr->hydrogen()->pattern()); | |
| 5399 __ Push(instr->hydrogen()->flags()); | |
| 5400 CallRuntime(Runtime::kMaterializeRegExpLiteral, 4, instr); | |
| 5401 __ movp(rbx, rax); | |
| 5402 | |
| 5403 __ bind(&materialized); | |
| 5404 int size = JSRegExp::kSize + JSRegExp::kInObjectFieldCount * kPointerSize; | |
| 5405 Label allocated, runtime_allocate; | |
| 5406 __ Allocate(size, rax, rcx, rdx, &runtime_allocate, TAG_OBJECT); | |
| 5407 __ jmp(&allocated, Label::kNear); | |
| 5408 | |
| 5409 __ bind(&runtime_allocate); | |
| 5410 __ Push(rbx); | |
| 5411 __ Push(Smi::FromInt(size)); | |
| 5412 CallRuntime(Runtime::kAllocateInNewSpace, 1, instr); | |
| 5413 __ Pop(rbx); | |
| 5414 | |
| 5415 __ bind(&allocated); | |
| 5416 // Copy the content into the newly allocated memory. | |
| 5417 // (Unroll copy loop once for better throughput). | |
| 5418 for (int i = 0; i < size - kPointerSize; i += 2 * kPointerSize) { | |
| 5419 __ movp(rdx, FieldOperand(rbx, i)); | |
| 5420 __ movp(rcx, FieldOperand(rbx, i + kPointerSize)); | |
| 5421 __ movp(FieldOperand(rax, i), rdx); | |
| 5422 __ movp(FieldOperand(rax, i + kPointerSize), rcx); | |
| 5423 } | |
| 5424 if ((size % (2 * kPointerSize)) != 0) { | |
| 5425 __ movp(rdx, FieldOperand(rbx, size - kPointerSize)); | |
| 5426 __ movp(FieldOperand(rax, size - kPointerSize), rdx); | |
| 5427 } | |
| 5428 } | |
| 5429 | |
| 5430 | |
| 5431 void LCodeGen::DoTypeof(LTypeof* instr) { | 5380 void LCodeGen::DoTypeof(LTypeof* instr) { |
| 5432 DCHECK(ToRegister(instr->context()).is(rsi)); | 5381 DCHECK(ToRegister(instr->context()).is(rsi)); |
| 5433 DCHECK(ToRegister(instr->value()).is(rbx)); | 5382 DCHECK(ToRegister(instr->value()).is(rbx)); |
| 5434 Label end, do_call; | 5383 Label end, do_call; |
| 5435 Register value_register = ToRegister(instr->value()); | 5384 Register value_register = ToRegister(instr->value()); |
| 5436 __ JumpIfNotSmi(value_register, &do_call); | 5385 __ JumpIfNotSmi(value_register, &do_call); |
| 5437 __ Move(rax, isolate()->factory()->number_string()); | 5386 __ Move(rax, isolate()->factory()->number_string()); |
| 5438 __ jmp(&end); | 5387 __ jmp(&end); |
| 5439 __ bind(&do_call); | 5388 __ bind(&do_call); |
| 5440 TypeofStub stub(isolate()); | 5389 TypeofStub stub(isolate()); |
| (...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5841 RecordSafepoint(Safepoint::kNoLazyDeopt); | 5790 RecordSafepoint(Safepoint::kNoLazyDeopt); |
| 5842 } | 5791 } |
| 5843 | 5792 |
| 5844 | 5793 |
| 5845 #undef __ | 5794 #undef __ |
| 5846 | 5795 |
| 5847 } // namespace internal | 5796 } // namespace internal |
| 5848 } // namespace v8 | 5797 } // namespace v8 |
| 5849 | 5798 |
| 5850 #endif // V8_TARGET_ARCH_X64 | 5799 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |