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

Side by Side Diff: src/x64/macro-assembler-x64.cc

Issue 112863002: Merge bleeding_edge 18021:18297 (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Created 7 years 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/x64/macro-assembler-x64.h ('k') | src/x64/stub-cache-x64.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 27 matching lines...) Expand all
38 #include "debug.h" 38 #include "debug.h"
39 #include "heap.h" 39 #include "heap.h"
40 #include "isolate-inl.h" 40 #include "isolate-inl.h"
41 41
42 namespace v8 { 42 namespace v8 {
43 namespace internal { 43 namespace internal {
44 44
45 MacroAssembler::MacroAssembler(Isolate* arg_isolate, void* buffer, int size) 45 MacroAssembler::MacroAssembler(Isolate* arg_isolate, void* buffer, int size)
46 : Assembler(arg_isolate, buffer, size), 46 : Assembler(arg_isolate, buffer, size),
47 generating_stub_(false), 47 generating_stub_(false),
48 allow_stub_calls_(true),
49 has_frame_(false), 48 has_frame_(false),
50 root_array_available_(true) { 49 root_array_available_(true) {
51 if (isolate() != NULL) { 50 if (isolate() != NULL) {
52 code_object_ = Handle<Object>(isolate()->heap()->undefined_value(), 51 code_object_ = Handle<Object>(isolate()->heap()->undefined_value(),
53 isolate()); 52 isolate());
54 } 53 }
55 } 54 }
56 55
57 56
58 static const int kInvalidRootRegisterDelta = -1; 57 static const int kInvalidRootRegisterDelta = -1;
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 } 397 }
399 398
400 if (emit_debug_code()) { 399 if (emit_debug_code()) {
401 Label ok; 400 Label ok;
402 cmpq(value, Operand(address, 0)); 401 cmpq(value, Operand(address, 0));
403 j(equal, &ok, Label::kNear); 402 j(equal, &ok, Label::kNear);
404 int3(); 403 int3();
405 bind(&ok); 404 bind(&ok);
406 } 405 }
407 406
407 // Count number of write barriers in generated code.
408 isolate()->counters()->write_barriers_static()->Increment();
409 IncrementCounter(isolate()->counters()->write_barriers_dynamic(), 1);
410
408 // First, check if a write barrier is even needed. The tests below 411 // First, check if a write barrier is even needed. The tests below
409 // catch stores of smis and stores into the young generation. 412 // catch stores of smis and stores into the young generation.
410 Label done; 413 Label done;
411 414
412 if (smi_check == INLINE_SMI_CHECK) { 415 if (smi_check == INLINE_SMI_CHECK) {
413 // Skip barrier if writing a smi. 416 // Skip barrier if writing a smi.
414 JumpIfSmi(value, &done); 417 JumpIfSmi(value, &done);
415 } 418 }
416 419
417 CheckPageFlag(value, 420 CheckPageFlag(value,
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 } 547 }
545 548
546 549
547 void MacroAssembler::CallStub(CodeStub* stub, TypeFeedbackId ast_id) { 550 void MacroAssembler::CallStub(CodeStub* stub, TypeFeedbackId ast_id) {
548 ASSERT(AllowThisStubCall(stub)); // Calls are not allowed in some stubs 551 ASSERT(AllowThisStubCall(stub)); // Calls are not allowed in some stubs
549 Call(stub->GetCode(isolate()), RelocInfo::CODE_TARGET, ast_id); 552 Call(stub->GetCode(isolate()), RelocInfo::CODE_TARGET, ast_id);
550 } 553 }
551 554
552 555
553 void MacroAssembler::TailCallStub(CodeStub* stub) { 556 void MacroAssembler::TailCallStub(CodeStub* stub) {
554 ASSERT(allow_stub_calls_ ||
555 stub->CompilingCallsToThisStubIsGCSafe(isolate()));
556 Jump(stub->GetCode(isolate()), RelocInfo::CODE_TARGET); 557 Jump(stub->GetCode(isolate()), RelocInfo::CODE_TARGET);
557 } 558 }
558 559
559 560
560 void MacroAssembler::StubReturn(int argc) { 561 void MacroAssembler::StubReturn(int argc) {
561 ASSERT(argc >= 1 && generating_stub()); 562 ASSERT(argc >= 1 && generating_stub());
562 ret((argc - 1) * kPointerSize); 563 ret((argc - 1) * kPointerSize);
563 } 564 }
564 565
565 566
566 bool MacroAssembler::AllowThisStubCall(CodeStub* stub) { 567 bool MacroAssembler::AllowThisStubCall(CodeStub* stub) {
567 if (!has_frame_ && stub->SometimesSetsUpAFrame()) return false; 568 return has_frame_ || !stub->SometimesSetsUpAFrame();
568 return allow_stub_calls_ || stub->CompilingCallsToThisStubIsGCSafe(isolate());
569 } 569 }
570 570
571 571
572 void MacroAssembler::IllegalOperation(int num_arguments) { 572 void MacroAssembler::IllegalOperation(int num_arguments) {
573 if (num_arguments > 0) { 573 if (num_arguments > 0) {
574 addq(rsp, Immediate(num_arguments * kPointerSize)); 574 addq(rsp, Immediate(num_arguments * kPointerSize));
575 } 575 }
576 LoadRoot(rax, Heap::kUndefinedValueRootIndex); 576 LoadRoot(rax, Heap::kUndefinedValueRootIndex);
577 } 577 }
578 578
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
1038 } 1038 }
1039 LoadSmiConstant(kScratchRegister, source); 1039 LoadSmiConstant(kScratchRegister, source);
1040 return kScratchRegister; 1040 return kScratchRegister;
1041 } 1041 }
1042 1042
1043 1043
1044 void MacroAssembler::LoadSmiConstant(Register dst, Smi* source) { 1044 void MacroAssembler::LoadSmiConstant(Register dst, Smi* source) {
1045 if (emit_debug_code()) { 1045 if (emit_debug_code()) {
1046 movq(dst, Smi::FromInt(kSmiConstantRegisterValue), RelocInfo::NONE64); 1046 movq(dst, Smi::FromInt(kSmiConstantRegisterValue), RelocInfo::NONE64);
1047 cmpq(dst, kSmiConstantRegister); 1047 cmpq(dst, kSmiConstantRegister);
1048 if (allow_stub_calls()) { 1048 Assert(equal, kUninitializedKSmiConstantRegister);
1049 Assert(equal, kUninitializedKSmiConstantRegister);
1050 } else {
1051 Label ok;
1052 j(equal, &ok, Label::kNear);
1053 int3();
1054 bind(&ok);
1055 }
1056 } 1049 }
1057 int value = source->value(); 1050 int value = source->value();
1058 if (value == 0) { 1051 if (value == 0) {
1059 xorl(dst, dst); 1052 xorl(dst, dst);
1060 return; 1053 return;
1061 } 1054 }
1062 bool negative = value < 0; 1055 bool negative = value < 0;
1063 unsigned int uvalue = negative ? -value : value; 1056 unsigned int uvalue = negative ? -value : value;
1064 1057
1065 switch (uvalue) { 1058 switch (uvalue) {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1106 } 1099 }
1107 shl(dst, Immediate(kSmiShift)); 1100 shl(dst, Immediate(kSmiShift));
1108 } 1101 }
1109 1102
1110 1103
1111 void MacroAssembler::Integer32ToSmiField(const Operand& dst, Register src) { 1104 void MacroAssembler::Integer32ToSmiField(const Operand& dst, Register src) {
1112 if (emit_debug_code()) { 1105 if (emit_debug_code()) {
1113 testb(dst, Immediate(0x01)); 1106 testb(dst, Immediate(0x01));
1114 Label ok; 1107 Label ok;
1115 j(zero, &ok, Label::kNear); 1108 j(zero, &ok, Label::kNear);
1116 if (allow_stub_calls()) { 1109 Abort(kInteger32ToSmiFieldWritingToNonSmiLocation);
1117 Abort(kInteger32ToSmiFieldWritingToNonSmiLocation);
1118 } else {
1119 int3();
1120 }
1121 bind(&ok); 1110 bind(&ok);
1122 } 1111 }
1123 ASSERT(kSmiShift % kBitsPerByte == 0); 1112 ASSERT(kSmiShift % kBitsPerByte == 0);
1124 movl(Operand(dst, kSmiShift / kBitsPerByte), src); 1113 movl(Operand(dst, kSmiShift / kBitsPerByte), src);
1125 } 1114 }
1126 1115
1127 1116
1128 void MacroAssembler::Integer64PlusConstantToSmi(Register dst, 1117 void MacroAssembler::Integer64PlusConstantToSmi(Register dst,
1129 Register src, 1118 Register src,
1130 int constant) { 1119 int constant) {
(...skipping 1040 matching lines...) Expand 10 before | Expand all | Expand 10 after
2171 Register src2, 2160 Register src2,
2172 Label* on_not_smis, 2161 Label* on_not_smis,
2173 Label::Distance near_jump) { 2162 Label::Distance near_jump) {
2174 ASSERT(!dst.is(kScratchRegister)); 2163 ASSERT(!dst.is(kScratchRegister));
2175 ASSERT(!src1.is(kScratchRegister)); 2164 ASSERT(!src1.is(kScratchRegister));
2176 ASSERT(!src2.is(kScratchRegister)); 2165 ASSERT(!src2.is(kScratchRegister));
2177 ASSERT(!dst.is(src1)); 2166 ASSERT(!dst.is(src1));
2178 ASSERT(!dst.is(src2)); 2167 ASSERT(!dst.is(src2));
2179 // Both operands must not be smis. 2168 // Both operands must not be smis.
2180 #ifdef DEBUG 2169 #ifdef DEBUG
2181 if (allow_stub_calls()) { // Check contains a stub call. 2170 Condition not_both_smis = NegateCondition(CheckBothSmi(src1, src2));
2182 Condition not_both_smis = NegateCondition(CheckBothSmi(src1, src2)); 2171 Check(not_both_smis, kBothRegistersWereSmisInSelectNonSmi);
2183 Check(not_both_smis, kBothRegistersWereSmisInSelectNonSmi);
2184 }
2185 #endif 2172 #endif
2186 STATIC_ASSERT(kSmiTag == 0); 2173 STATIC_ASSERT(kSmiTag == 0);
2187 ASSERT_EQ(0, Smi::FromInt(0)); 2174 ASSERT_EQ(0, Smi::FromInt(0));
2188 movl(kScratchRegister, Immediate(kSmiTagMask)); 2175 movl(kScratchRegister, Immediate(kSmiTagMask));
2189 and_(kScratchRegister, src1); 2176 and_(kScratchRegister, src1);
2190 testl(kScratchRegister, src2); 2177 testl(kScratchRegister, src2);
2191 // If non-zero then both are smis. 2178 // If non-zero then both are smis.
2192 j(not_zero, on_not_smis, near_jump); 2179 j(not_zero, on_not_smis, near_jump);
2193 2180
2194 // Exactly one operand is a smi. 2181 // Exactly one operand is a smi.
(...skipping 1395 matching lines...) Expand 10 before | Expand all | Expand 10 after
3590 FieldOperand(rdx, SharedFunctionInfo::kFormalParameterCountOffset)); 3577 FieldOperand(rdx, SharedFunctionInfo::kFormalParameterCountOffset));
3591 // Advances rdx to the end of the Code object header, to the start of 3578 // Advances rdx to the end of the Code object header, to the start of
3592 // the executable code. 3579 // the executable code.
3593 movq(rdx, FieldOperand(rdi, JSFunction::kCodeEntryOffset)); 3580 movq(rdx, FieldOperand(rdi, JSFunction::kCodeEntryOffset));
3594 3581
3595 ParameterCount expected(rbx); 3582 ParameterCount expected(rbx);
3596 InvokeCode(rdx, expected, actual, flag, call_wrapper, call_kind); 3583 InvokeCode(rdx, expected, actual, flag, call_wrapper, call_kind);
3597 } 3584 }
3598 3585
3599 3586
3600 void MacroAssembler::InvokeFunction(Handle<JSFunction> function, 3587 void MacroAssembler::InvokeFunction(Register function,
3601 const ParameterCount& expected, 3588 const ParameterCount& expected,
3602 const ParameterCount& actual, 3589 const ParameterCount& actual,
3603 InvokeFlag flag, 3590 InvokeFlag flag,
3604 const CallWrapper& call_wrapper, 3591 const CallWrapper& call_wrapper,
3605 CallKind call_kind) { 3592 CallKind call_kind) {
3606 // You can't call a function without a valid frame. 3593 // You can't call a function without a valid frame.
3607 ASSERT(flag == JUMP_FUNCTION || has_frame()); 3594 ASSERT(flag == JUMP_FUNCTION || has_frame());
3608 3595
3609 // Get the function and setup the context. 3596 ASSERT(function.is(rdi));
3597 movq(rsi, FieldOperand(function, JSFunction::kContextOffset));
3598 // Advances rdx to the end of the Code object header, to the start of
3599 // the executable code.
3600 movq(rdx, FieldOperand(rdi, JSFunction::kCodeEntryOffset));
3601
3602 InvokeCode(rdx, expected, actual, flag, call_wrapper, call_kind);
3603 }
3604
3605
3606 void MacroAssembler::InvokeFunction(Handle<JSFunction> function,
3607 const ParameterCount& expected,
3608 const ParameterCount& actual,
3609 InvokeFlag flag,
3610 const CallWrapper& call_wrapper,
3611 CallKind call_kind) {
3610 Move(rdi, function); 3612 Move(rdi, function);
3611 movq(rsi, FieldOperand(rdi, JSFunction::kContextOffset)); 3613 InvokeFunction(rdi, expected, actual, flag, call_wrapper, call_kind);
3612
3613 // We call indirectly through the code field in the function to
3614 // allow recompilation to take effect without changing any of the
3615 // call sites.
3616 movq(rdx, FieldOperand(rdi, JSFunction::kCodeEntryOffset));
3617 InvokeCode(rdx, expected, actual, flag, call_wrapper, call_kind);
3618 } 3614 }
3619 3615
3620 3616
3621 void MacroAssembler::InvokePrologue(const ParameterCount& expected, 3617 void MacroAssembler::InvokePrologue(const ParameterCount& expected,
3622 const ParameterCount& actual, 3618 const ParameterCount& actual,
3623 Handle<Code> code_constant, 3619 Handle<Code> code_constant,
3624 Register code_register, 3620 Register code_register,
3625 Label* done, 3621 Label* done,
3626 bool* definitely_mismatches, 3622 bool* definitely_mismatches,
3627 InvokeFlag flag, 3623 InvokeFlag flag,
(...skipping 1423 matching lines...) Expand 10 before | Expand all | Expand 10 after
5051 j(equal, found); 5047 j(equal, found);
5052 movq(current, FieldOperand(current, Map::kPrototypeOffset)); 5048 movq(current, FieldOperand(current, Map::kPrototypeOffset));
5053 CompareRoot(current, Heap::kNullValueRootIndex); 5049 CompareRoot(current, Heap::kNullValueRootIndex);
5054 j(not_equal, &loop_again); 5050 j(not_equal, &loop_again);
5055 } 5051 }
5056 5052
5057 5053
5058 } } // namespace v8::internal 5054 } } // namespace v8::internal
5059 5055
5060 #endif // V8_TARGET_ARCH_X64 5056 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/macro-assembler-x64.h ('k') | src/x64/stub-cache-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698