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

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

Issue 6542062: Merge revisions 6894 and 6895 to the 3.0 branch. (Closed) Base URL: http://v8.googlecode.com/svn/branches/3.0/
Patch Set: Created 9 years, 10 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/ia32/lithium-codegen-ia32.h ('k') | src/version.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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 : codegen_(codegen), 48 : codegen_(codegen),
49 pointers_(pointers), 49 pointers_(pointers),
50 deoptimization_index_(deoptimization_index), 50 deoptimization_index_(deoptimization_index),
51 ensure_reloc_space_(ensure_reloc_space) { } 51 ensure_reloc_space_(ensure_reloc_space) { }
52 virtual ~SafepointGenerator() { } 52 virtual ~SafepointGenerator() { }
53 53
54 virtual void Generate() { 54 virtual void Generate() {
55 // Ensure that we have enough space in the reloc info to patch 55 // Ensure that we have enough space in the reloc info to patch
56 // this with calls when doing deoptimization. 56 // this with calls when doing deoptimization.
57 if (ensure_reloc_space_) { 57 if (ensure_reloc_space_) {
58 codegen_->masm()->RecordComment(RelocInfo::kFillerCommentString, true); 58 codegen_->EnsureRelocSpaceForDeoptimization();
59 } 59 }
60 codegen_->RecordSafepoint(pointers_, deoptimization_index_); 60 codegen_->RecordSafepoint(pointers_, deoptimization_index_);
61 } 61 }
62 62
63 private: 63 private:
64 LCodeGen* codegen_; 64 LCodeGen* codegen_;
65 LPointerMap* pointers_; 65 LPointerMap* pointers_;
66 int deoptimization_index_; 66 int deoptimization_index_;
67 bool ensure_reloc_space_; 67 bool ensure_reloc_space_;
68 }; 68 };
69 69
70 70
71 #define __ masm()-> 71 #define __ masm()->
72 72
73 bool LCodeGen::GenerateCode() { 73 bool LCodeGen::GenerateCode() {
74 HPhase phase("Code generation", chunk()); 74 HPhase phase("Code generation", chunk());
75 ASSERT(is_unused()); 75 ASSERT(is_unused());
76 status_ = GENERATING; 76 status_ = GENERATING;
77 CpuFeatures::Scope scope(SSE2); 77 CpuFeatures::Scope scope(SSE2);
78 return GeneratePrologue() && 78 return GeneratePrologue() &&
79 GenerateBody() && 79 GenerateBody() &&
80 GenerateDeferredCode() && 80 GenerateDeferredCode() &&
81 GenerateRelocPadding() &&
81 GenerateSafepointTable(); 82 GenerateSafepointTable();
82 } 83 }
83 84
84 85
85 void LCodeGen::FinishCode(Handle<Code> code) { 86 void LCodeGen::FinishCode(Handle<Code> code) {
86 ASSERT(is_done()); 87 ASSERT(is_done());
87 code->set_stack_slots(StackSlotCount()); 88 code->set_stack_slots(StackSlotCount());
88 code->set_safepoint_table_offset(safepoints_.GetCodeOffset()); 89 code->set_safepoint_table_offset(safepoints_.GetCodeOffset());
89 PopulateDeoptimizationData(code); 90 PopulateDeoptimizationData(code);
90 } 91 }
(...skipping 24 matching lines...) Expand all
115 116
116 // Copy the string before recording it in the assembler to avoid 117 // Copy the string before recording it in the assembler to avoid
117 // issues when the stack allocated buffer goes out of scope. 118 // issues when the stack allocated buffer goes out of scope.
118 size_t length = builder.position(); 119 size_t length = builder.position();
119 Vector<char> copy = Vector<char>::New(length + 1); 120 Vector<char> copy = Vector<char>::New(length + 1);
120 memcpy(copy.start(), builder.Finalize(), copy.length()); 121 memcpy(copy.start(), builder.Finalize(), copy.length());
121 masm()->RecordComment(copy.start()); 122 masm()->RecordComment(copy.start());
122 } 123 }
123 124
124 125
126 bool LCodeGen::GenerateRelocPadding() {
127 int reloc_size = masm()->relocation_writer_size();
128 while (reloc_size < deoptimization_reloc_size.min_size) {
129 __ RecordComment(RelocInfo::kFillerCommentString, true);
130 reloc_size += RelocInfo::kRelocCommentSize;
131 }
132 return !is_aborted();
133 }
134
135
125 bool LCodeGen::GeneratePrologue() { 136 bool LCodeGen::GeneratePrologue() {
126 ASSERT(is_generating()); 137 ASSERT(is_generating());
127 138
128 #ifdef DEBUG 139 #ifdef DEBUG
129 if (strlen(FLAG_stop_at) > 0 && 140 if (strlen(FLAG_stop_at) > 0 &&
130 info_->function()->name()->IsEqualTo(CStrVector(FLAG_stop_at))) { 141 info_->function()->name()->IsEqualTo(CStrVector(FLAG_stop_at))) {
131 __ int3(); 142 __ int3();
132 } 143 }
133 #endif 144 #endif
134 145
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 environment->spilled_double_registers()[value->index()], 337 environment->spilled_double_registers()[value->index()],
327 false); 338 false);
328 } 339 }
329 } 340 }
330 341
331 AddToTranslation(translation, value, environment->HasTaggedValueAt(i)); 342 AddToTranslation(translation, value, environment->HasTaggedValueAt(i));
332 } 343 }
333 } 344 }
334 345
335 346
347 void LCodeGen::EnsureRelocSpaceForDeoptimization() {
348 // Since we patch the reloc info with RUNTIME_ENTRY calls every patch
349 // site will take up 2 bytes + any pc-jumps.
350 // We are conservative and always reserver 6 bytes in case where a
351 // simple pc-jump is not enough.
352 uint32_t pc_delta =
353 masm()->pc_offset() - deoptimization_reloc_size.last_pc_offset;
354 if (is_uintn(pc_delta, 6)) {
355 deoptimization_reloc_size.min_size += 2;
356 } else {
357 deoptimization_reloc_size.min_size += 6;
358 }
359 deoptimization_reloc_size.last_pc_offset = masm()->pc_offset();
360 }
361
362
336 void LCodeGen::AddToTranslation(Translation* translation, 363 void LCodeGen::AddToTranslation(Translation* translation,
337 LOperand* op, 364 LOperand* op,
338 bool is_tagged) { 365 bool is_tagged) {
339 if (op == NULL) { 366 if (op == NULL) {
340 // TODO(twuerthinger): Introduce marker operands to indicate that this value 367 // TODO(twuerthinger): Introduce marker operands to indicate that this value
341 // is not present and must be reconstructed from the deoptimizer. Currently 368 // is not present and must be reconstructed from the deoptimizer. Currently
342 // this is only used for the arguments object. 369 // this is only used for the arguments object.
343 translation->StoreArgumentsObject(); 370 translation->StoreArgumentsObject();
344 } else if (op->IsStackSlot()) { 371 } else if (op->IsStackSlot()) {
345 if (is_tagged) { 372 if (is_tagged) {
(...skipping 27 matching lines...) Expand all
373 } 400 }
374 401
375 402
376 void LCodeGen::CallCode(Handle<Code> code, 403 void LCodeGen::CallCode(Handle<Code> code,
377 RelocInfo::Mode mode, 404 RelocInfo::Mode mode,
378 LInstruction* instr) { 405 LInstruction* instr) {
379 ASSERT(instr != NULL); 406 ASSERT(instr != NULL);
380 LPointerMap* pointers = instr->pointer_map(); 407 LPointerMap* pointers = instr->pointer_map();
381 RecordPosition(pointers->position()); 408 RecordPosition(pointers->position());
382 __ call(code, mode); 409 __ call(code, mode);
410 EnsureRelocSpaceForDeoptimization();
383 RegisterLazyDeoptimization(instr); 411 RegisterLazyDeoptimization(instr);
384 412
385 // Signal that we don't inline smi code before these stubs in the 413 // Signal that we don't inline smi code before these stubs in the
386 // optimizing code generator. 414 // optimizing code generator.
387 if (code->kind() == Code::TYPE_RECORDING_BINARY_OP_IC || 415 if (code->kind() == Code::TYPE_RECORDING_BINARY_OP_IC ||
388 code->kind() == Code::COMPARE_IC) { 416 code->kind() == Code::COMPARE_IC) {
389 __ nop(); 417 __ nop();
390 } 418 }
391 } 419 }
392 420
(...skipping 1813 matching lines...) Expand 10 before | Expand all | Expand 10 after
2206 __ mov(eax, arity); 2234 __ mov(eax, arity);
2207 } 2235 }
2208 2236
2209 LPointerMap* pointers = instr->pointer_map(); 2237 LPointerMap* pointers = instr->pointer_map();
2210 RecordPosition(pointers->position()); 2238 RecordPosition(pointers->position());
2211 2239
2212 // Invoke function. 2240 // Invoke function.
2213 if (*function == *graph()->info()->closure()) { 2241 if (*function == *graph()->info()->closure()) {
2214 __ CallSelf(); 2242 __ CallSelf();
2215 } else { 2243 } else {
2216 // This is an indirect call and will not be recorded in the reloc info.
2217 // Add a comment to the reloc info in case we need to patch this during
2218 // deoptimization.
2219 __ RecordComment(RelocInfo::kFillerCommentString, true);
2220 __ call(FieldOperand(edi, JSFunction::kCodeEntryOffset)); 2244 __ call(FieldOperand(edi, JSFunction::kCodeEntryOffset));
2245 EnsureRelocSpaceForDeoptimization();
2221 } 2246 }
2222 2247
2223 // Setup deoptimization. 2248 // Setup deoptimization.
2224 RegisterLazyDeoptimization(instr); 2249 RegisterLazyDeoptimization(instr);
2225 2250
2226 // Restore context. 2251 // Restore context.
2227 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); 2252 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset));
2228 } 2253 }
2229 2254
2230 2255
(...skipping 1406 matching lines...) Expand 10 before | Expand all | Expand 10 after
3637 ASSERT(osr_pc_offset_ == -1); 3662 ASSERT(osr_pc_offset_ == -1);
3638 osr_pc_offset_ = masm()->pc_offset(); 3663 osr_pc_offset_ = masm()->pc_offset();
3639 } 3664 }
3640 3665
3641 3666
3642 #undef __ 3667 #undef __
3643 3668
3644 } } // namespace v8::internal 3669 } } // namespace v8::internal
3645 3670
3646 #endif // V8_TARGET_ARCH_IA32 3671 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/lithium-codegen-ia32.h ('k') | src/version.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698