OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/lithium.h" | 7 #include "src/lithium.h" |
8 #include "src/scopes.h" | 8 #include "src/scopes.h" |
9 #include "src/serialize.h" | 9 #include "src/serialize.h" |
10 | 10 |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 values_[i]->PrintTo(stream); | 206 values_[i]->PrintTo(stream); |
207 } | 207 } |
208 } | 208 } |
209 stream->Add("]"); | 209 stream->Add("]"); |
210 } | 210 } |
211 | 211 |
212 | 212 |
213 void LPointerMap::RecordPointer(LOperand* op, Zone* zone) { | 213 void LPointerMap::RecordPointer(LOperand* op, Zone* zone) { |
214 // Do not record arguments as pointers. | 214 // Do not record arguments as pointers. |
215 if (op->IsStackSlot() && op->index() < 0) return; | 215 if (op->IsStackSlot() && op->index() < 0) return; |
216 ASSERT(!op->IsDoubleRegister() && !op->IsDoubleStackSlot()); | 216 DCHECK(!op->IsDoubleRegister() && !op->IsDoubleStackSlot()); |
217 pointer_operands_.Add(op, zone); | 217 pointer_operands_.Add(op, zone); |
218 } | 218 } |
219 | 219 |
220 | 220 |
221 void LPointerMap::RemovePointer(LOperand* op) { | 221 void LPointerMap::RemovePointer(LOperand* op) { |
222 // Do not record arguments as pointers. | 222 // Do not record arguments as pointers. |
223 if (op->IsStackSlot() && op->index() < 0) return; | 223 if (op->IsStackSlot() && op->index() < 0) return; |
224 ASSERT(!op->IsDoubleRegister() && !op->IsDoubleStackSlot()); | 224 DCHECK(!op->IsDoubleRegister() && !op->IsDoubleStackSlot()); |
225 for (int i = 0; i < pointer_operands_.length(); ++i) { | 225 for (int i = 0; i < pointer_operands_.length(); ++i) { |
226 if (pointer_operands_[i]->Equals(op)) { | 226 if (pointer_operands_[i]->Equals(op)) { |
227 pointer_operands_.Remove(i); | 227 pointer_operands_.Remove(i); |
228 --i; | 228 --i; |
229 } | 229 } |
230 } | 230 } |
231 } | 231 } |
232 | 232 |
233 | 233 |
234 void LPointerMap::RecordUntagged(LOperand* op, Zone* zone) { | 234 void LPointerMap::RecordUntagged(LOperand* op, Zone* zone) { |
235 // Do not record arguments as pointers. | 235 // Do not record arguments as pointers. |
236 if (op->IsStackSlot() && op->index() < 0) return; | 236 if (op->IsStackSlot() && op->index() < 0) return; |
237 ASSERT(!op->IsDoubleRegister() && !op->IsDoubleStackSlot()); | 237 DCHECK(!op->IsDoubleRegister() && !op->IsDoubleStackSlot()); |
238 untagged_operands_.Add(op, zone); | 238 untagged_operands_.Add(op, zone); |
239 } | 239 } |
240 | 240 |
241 | 241 |
242 void LPointerMap::PrintTo(StringStream* stream) { | 242 void LPointerMap::PrintTo(StringStream* stream) { |
243 stream->Add("{"); | 243 stream->Add("{"); |
244 for (int i = 0; i < pointer_operands_.length(); ++i) { | 244 for (int i = 0; i < pointer_operands_.length(); ++i) { |
245 if (i != 0) stream->Add(";"); | 245 if (i != 0) stream->Add(";"); |
246 pointer_operands_[i]->PrintTo(stream); | 246 pointer_operands_[i]->PrintTo(stream); |
247 } | 247 } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 int LChunk::LookupDestination(int block_id) const { | 283 int LChunk::LookupDestination(int block_id) const { |
284 LLabel* cur = GetLabel(block_id); | 284 LLabel* cur = GetLabel(block_id); |
285 while (cur->replacement() != NULL) { | 285 while (cur->replacement() != NULL) { |
286 cur = cur->replacement(); | 286 cur = cur->replacement(); |
287 } | 287 } |
288 return cur->block_id(); | 288 return cur->block_id(); |
289 } | 289 } |
290 | 290 |
291 Label* LChunk::GetAssemblyLabel(int block_id) const { | 291 Label* LChunk::GetAssemblyLabel(int block_id) const { |
292 LLabel* label = GetLabel(block_id); | 292 LLabel* label = GetLabel(block_id); |
293 ASSERT(!label->HasReplacement()); | 293 DCHECK(!label->HasReplacement()); |
294 return label->label(); | 294 return label->label(); |
295 } | 295 } |
296 | 296 |
297 | 297 |
298 void LChunk::MarkEmptyBlocks() { | 298 void LChunk::MarkEmptyBlocks() { |
299 LPhase phase("L_Mark empty blocks", this); | 299 LPhase phase("L_Mark empty blocks", this); |
300 for (int i = 0; i < graph()->blocks()->length(); ++i) { | 300 for (int i = 0; i < graph()->blocks()->length(); ++i) { |
301 HBasicBlock* block = graph()->blocks()->at(i); | 301 HBasicBlock* block = graph()->blocks()->at(i); |
302 int first = block->first_instruction_index(); | 302 int first = block->first_instruction_index(); |
303 int last = block->last_instruction_index(); | 303 int last = block->last_instruction_index(); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 } | 355 } |
356 | 356 |
357 | 357 |
358 int LChunk::GetParameterStackSlot(int index) const { | 358 int LChunk::GetParameterStackSlot(int index) const { |
359 // The receiver is at index 0, the first parameter at index 1, so we | 359 // The receiver is at index 0, the first parameter at index 1, so we |
360 // shift all parameter indexes down by the number of parameters, and | 360 // shift all parameter indexes down by the number of parameters, and |
361 // make sure they end up negative so they are distinguishable from | 361 // make sure they end up negative so they are distinguishable from |
362 // spill slots. | 362 // spill slots. |
363 int result = index - info()->num_parameters() - 1; | 363 int result = index - info()->num_parameters() - 1; |
364 | 364 |
365 ASSERT(result < 0); | 365 DCHECK(result < 0); |
366 return result; | 366 return result; |
367 } | 367 } |
368 | 368 |
369 | 369 |
370 // A parameter relative to ebp in the arguments stub. | 370 // A parameter relative to ebp in the arguments stub. |
371 int LChunk::ParameterAt(int index) { | 371 int LChunk::ParameterAt(int index) { |
372 ASSERT(-1 <= index); // -1 is the receiver. | 372 DCHECK(-1 <= index); // -1 is the receiver. |
373 return (1 + info()->scope()->num_parameters() - index) * | 373 return (1 + info()->scope()->num_parameters() - index) * |
374 kPointerSize; | 374 kPointerSize; |
375 } | 375 } |
376 | 376 |
377 | 377 |
378 LGap* LChunk::GetGapAt(int index) const { | 378 LGap* LChunk::GetGapAt(int index) const { |
379 return LGap::cast(instructions_[index]); | 379 return LGap::cast(instructions_[index]); |
380 } | 380 } |
381 | 381 |
382 | 382 |
(...skipping 22 matching lines...) Expand all Loading... |
405 Representation LChunk::LookupLiteralRepresentation( | 405 Representation LChunk::LookupLiteralRepresentation( |
406 LConstantOperand* operand) const { | 406 LConstantOperand* operand) const { |
407 return graph_->LookupValue(operand->index())->representation(); | 407 return graph_->LookupValue(operand->index())->representation(); |
408 } | 408 } |
409 | 409 |
410 | 410 |
411 void LChunk::CommitDependencies(Handle<Code> code) const { | 411 void LChunk::CommitDependencies(Handle<Code> code) const { |
412 for (MapSet::const_iterator it = deprecation_dependencies_.begin(), | 412 for (MapSet::const_iterator it = deprecation_dependencies_.begin(), |
413 iend = deprecation_dependencies_.end(); it != iend; ++it) { | 413 iend = deprecation_dependencies_.end(); it != iend; ++it) { |
414 Handle<Map> map = *it; | 414 Handle<Map> map = *it; |
415 ASSERT(!map->is_deprecated()); | 415 DCHECK(!map->is_deprecated()); |
416 ASSERT(map->CanBeDeprecated()); | 416 DCHECK(map->CanBeDeprecated()); |
417 Map::AddDependentCode(map, DependentCode::kTransitionGroup, code); | 417 Map::AddDependentCode(map, DependentCode::kTransitionGroup, code); |
418 } | 418 } |
419 | 419 |
420 for (MapSet::const_iterator it = stability_dependencies_.begin(), | 420 for (MapSet::const_iterator it = stability_dependencies_.begin(), |
421 iend = stability_dependencies_.end(); it != iend; ++it) { | 421 iend = stability_dependencies_.end(); it != iend; ++it) { |
422 Handle<Map> map = *it; | 422 Handle<Map> map = *it; |
423 ASSERT(map->is_stable()); | 423 DCHECK(map->is_stable()); |
424 ASSERT(map->CanTransition()); | 424 DCHECK(map->CanTransition()); |
425 Map::AddDependentCode(map, DependentCode::kPrototypeCheckGroup, code); | 425 Map::AddDependentCode(map, DependentCode::kPrototypeCheckGroup, code); |
426 } | 426 } |
427 | 427 |
428 info_->CommitDependencies(code); | 428 info_->CommitDependencies(code); |
429 } | 429 } |
430 | 430 |
431 | 431 |
432 LChunk* LChunk::NewChunk(HGraph* graph) { | 432 LChunk* LChunk::NewChunk(HGraph* graph) { |
433 DisallowHandleAllocation no_handles; | 433 DisallowHandleAllocation no_handles; |
434 DisallowHeapAllocation no_gc; | 434 DisallowHeapAllocation no_gc; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 CodeGenerator::MakeCodeEpilogue(&assembler, flags, info()); | 475 CodeGenerator::MakeCodeEpilogue(&assembler, flags, info()); |
476 generator.FinishCode(code); | 476 generator.FinishCode(code); |
477 CommitDependencies(code); | 477 CommitDependencies(code); |
478 code->set_is_crankshafted(true); | 478 code->set_is_crankshafted(true); |
479 void* jit_handler_data = | 479 void* jit_handler_data = |
480 assembler.positions_recorder()->DetachJITHandlerData(); | 480 assembler.positions_recorder()->DetachJITHandlerData(); |
481 LOG_CODE_EVENT(info()->isolate(), | 481 LOG_CODE_EVENT(info()->isolate(), |
482 CodeEndLinePosInfoRecordEvent(*code, jit_handler_data)); | 482 CodeEndLinePosInfoRecordEvent(*code, jit_handler_data)); |
483 | 483 |
484 CodeGenerator::PrintCode(code, info()); | 484 CodeGenerator::PrintCode(code, info()); |
485 ASSERT(!(info()->isolate()->serializer_enabled() && | 485 DCHECK(!(info()->isolate()->serializer_enabled() && |
486 info()->GetMustNotHaveEagerFrame() && | 486 info()->GetMustNotHaveEagerFrame() && |
487 generator.NeedsEagerFrame())); | 487 generator.NeedsEagerFrame())); |
488 return code; | 488 return code; |
489 } | 489 } |
490 assembler.AbortedCodeGeneration(); | 490 assembler.AbortedCodeGeneration(); |
491 return Handle<Code>::null(); | 491 return Handle<Code>::null(); |
492 } | 492 } |
493 | 493 |
494 | 494 |
495 void LChunk::set_allocated_double_registers(BitVector* allocated_registers) { | 495 void LChunk::set_allocated_double_registers(BitVector* allocated_registers) { |
(...skipping 16 matching lines...) Expand all Loading... |
512 LEnvironment* LChunkBuilderBase::CreateEnvironment( | 512 LEnvironment* LChunkBuilderBase::CreateEnvironment( |
513 HEnvironment* hydrogen_env, | 513 HEnvironment* hydrogen_env, |
514 int* argument_index_accumulator, | 514 int* argument_index_accumulator, |
515 ZoneList<HValue*>* objects_to_materialize) { | 515 ZoneList<HValue*>* objects_to_materialize) { |
516 if (hydrogen_env == NULL) return NULL; | 516 if (hydrogen_env == NULL) return NULL; |
517 | 517 |
518 LEnvironment* outer = CreateEnvironment(hydrogen_env->outer(), | 518 LEnvironment* outer = CreateEnvironment(hydrogen_env->outer(), |
519 argument_index_accumulator, | 519 argument_index_accumulator, |
520 objects_to_materialize); | 520 objects_to_materialize); |
521 BailoutId ast_id = hydrogen_env->ast_id(); | 521 BailoutId ast_id = hydrogen_env->ast_id(); |
522 ASSERT(!ast_id.IsNone() || | 522 DCHECK(!ast_id.IsNone() || |
523 hydrogen_env->frame_type() != JS_FUNCTION); | 523 hydrogen_env->frame_type() != JS_FUNCTION); |
524 int value_count = hydrogen_env->length() - hydrogen_env->specials_count(); | 524 int value_count = hydrogen_env->length() - hydrogen_env->specials_count(); |
525 LEnvironment* result = | 525 LEnvironment* result = |
526 new(zone()) LEnvironment(hydrogen_env->closure(), | 526 new(zone()) LEnvironment(hydrogen_env->closure(), |
527 hydrogen_env->frame_type(), | 527 hydrogen_env->frame_type(), |
528 ast_id, | 528 ast_id, |
529 hydrogen_env->parameter_count(), | 529 hydrogen_env->parameter_count(), |
530 argument_count_, | 530 argument_count_, |
531 value_count, | 531 value_count, |
532 outer, | 532 outer, |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
615 result->AddNewObject(is_arguments ? length - 1 : length, is_arguments); | 615 result->AddNewObject(is_arguments ? length - 1 : length, is_arguments); |
616 } | 616 } |
617 // Store the captured object's fields into the environment | 617 // Store the captured object's fields into the environment |
618 for (int i = is_arguments ? 1 : 0; i < length; ++i) { | 618 for (int i = is_arguments ? 1 : 0; i < length; ++i) { |
619 LOperand* op; | 619 LOperand* op; |
620 HValue* arg_value = value->OperandAt(i); | 620 HValue* arg_value = value->OperandAt(i); |
621 if (arg_value->IsArgumentsObject() || arg_value->IsCapturedObject()) { | 621 if (arg_value->IsArgumentsObject() || arg_value->IsCapturedObject()) { |
622 // Insert a hole for nested objects | 622 // Insert a hole for nested objects |
623 op = LEnvironment::materialization_marker(); | 623 op = LEnvironment::materialization_marker(); |
624 } else { | 624 } else { |
625 ASSERT(!arg_value->IsPushArguments()); | 625 DCHECK(!arg_value->IsPushArguments()); |
626 // For ordinary values, tell the register allocator we need the value | 626 // For ordinary values, tell the register allocator we need the value |
627 // to be alive here | 627 // to be alive here |
628 op = UseAny(arg_value); | 628 op = UseAny(arg_value); |
629 } | 629 } |
630 result->AddValue(op, | 630 result->AddValue(op, |
631 arg_value->representation(), | 631 arg_value->representation(), |
632 arg_value->CheckFlag(HInstruction::kUint32)); | 632 arg_value->CheckFlag(HInstruction::kUint32)); |
633 } | 633 } |
634 // Recursively store all the nested captured objects into the environment | 634 // Recursively store all the nested captured objects into the environment |
635 for (int i = is_arguments ? 1 : 0; i < length; ++i) { | 635 for (int i = is_arguments ? 1 : 0; i < length; ++i) { |
636 HValue* arg_value = value->OperandAt(i); | 636 HValue* arg_value = value->OperandAt(i); |
637 if (arg_value->IsArgumentsObject() || arg_value->IsCapturedObject()) { | 637 if (arg_value->IsArgumentsObject() || arg_value->IsCapturedObject()) { |
638 AddObjectToMaterialize(arg_value, objects_to_materialize, result); | 638 AddObjectToMaterialize(arg_value, objects_to_materialize, result); |
639 } | 639 } |
640 } | 640 } |
641 } | 641 } |
642 | 642 |
643 | 643 |
644 LPhase::~LPhase() { | 644 LPhase::~LPhase() { |
645 if (ShouldProduceTraceOutput()) { | 645 if (ShouldProduceTraceOutput()) { |
646 isolate()->GetHTracer()->TraceLithium(name(), chunk_); | 646 isolate()->GetHTracer()->TraceLithium(name(), chunk_); |
647 } | 647 } |
648 } | 648 } |
649 | 649 |
650 | 650 |
651 } } // namespace v8::internal | 651 } } // namespace v8::internal |
OLD | NEW |