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

Side by Side Diff: src/full-codegen.cc

Issue 181453002: Reset trunk to 3.24.35.4 (Closed) Base URL: https://v8.googlecode.com/svn/trunk
Patch Set: Created 6 years, 9 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/full-codegen.h ('k') | src/global-handles.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 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 } 338 }
339 unsigned table_offset = cgen.EmitBackEdgeTable(); 339 unsigned table_offset = cgen.EmitBackEdgeTable();
340 340
341 Code::Flags flags = Code::ComputeFlags(Code::FUNCTION); 341 Code::Flags flags = Code::ComputeFlags(Code::FUNCTION);
342 Handle<Code> code = CodeGenerator::MakeCodeEpilogue(&masm, flags, info); 342 Handle<Code> code = CodeGenerator::MakeCodeEpilogue(&masm, flags, info);
343 code->set_optimizable(info->IsOptimizable() && 343 code->set_optimizable(info->IsOptimizable() &&
344 !info->function()->dont_optimize() && 344 !info->function()->dont_optimize() &&
345 info->function()->scope()->AllowsLazyCompilation()); 345 info->function()->scope()->AllowsLazyCompilation());
346 cgen.PopulateDeoptimizationData(code); 346 cgen.PopulateDeoptimizationData(code);
347 cgen.PopulateTypeFeedbackInfo(code); 347 cgen.PopulateTypeFeedbackInfo(code);
348 cgen.PopulateTypeFeedbackCells(code);
348 code->set_has_deoptimization_support(info->HasDeoptimizationSupport()); 349 code->set_has_deoptimization_support(info->HasDeoptimizationSupport());
349 code->set_handler_table(*cgen.handler_table()); 350 code->set_handler_table(*cgen.handler_table());
350 #ifdef ENABLE_DEBUGGER_SUPPORT 351 #ifdef ENABLE_DEBUGGER_SUPPORT
351 code->set_compiled_optimizable(info->IsOptimizable()); 352 code->set_compiled_optimizable(info->IsOptimizable());
352 #endif // ENABLE_DEBUGGER_SUPPORT 353 #endif // ENABLE_DEBUGGER_SUPPORT
353 code->set_allow_osr_at_loop_nesting_level(0); 354 code->set_allow_osr_at_loop_nesting_level(0);
354 code->set_profiler_ticks(0); 355 code->set_profiler_ticks(0);
355 code->set_back_edge_table_offset(table_offset); 356 code->set_back_edge_table_offset(table_offset);
356 code->set_back_edges_patched_for_osr(false); 357 code->set_back_edges_patched_for_osr(false);
357 CodeGenerator::PrintCode(code, info); 358 CodeGenerator::PrintCode(code, info);
(...skipping 21 matching lines...) Expand all
379 __ dd(length); 380 __ dd(length);
380 for (unsigned i = 0; i < length; ++i) { 381 for (unsigned i = 0; i < length; ++i) {
381 __ dd(back_edges_[i].id.ToInt()); 382 __ dd(back_edges_[i].id.ToInt());
382 __ dd(back_edges_[i].pc); 383 __ dd(back_edges_[i].pc);
383 __ dd(back_edges_[i].loop_depth); 384 __ dd(back_edges_[i].loop_depth);
384 } 385 }
385 return offset; 386 return offset;
386 } 387 }
387 388
388 389
389 void FullCodeGenerator::InitializeFeedbackVector() {
390 int length = info_->function()->slot_count();
391 ASSERT_EQ(isolate()->heap()->the_hole_value(),
392 *TypeFeedbackInfo::UninitializedSentinel(isolate()));
393 feedback_vector_ = isolate()->factory()->NewFixedArrayWithHoles(length,
394 TENURED);
395 }
396
397
398 void FullCodeGenerator::PopulateDeoptimizationData(Handle<Code> code) { 390 void FullCodeGenerator::PopulateDeoptimizationData(Handle<Code> code) {
399 // Fill in the deoptimization information. 391 // Fill in the deoptimization information.
400 ASSERT(info_->HasDeoptimizationSupport() || bailout_entries_.is_empty()); 392 ASSERT(info_->HasDeoptimizationSupport() || bailout_entries_.is_empty());
401 if (!info_->HasDeoptimizationSupport()) return; 393 if (!info_->HasDeoptimizationSupport()) return;
402 int length = bailout_entries_.length(); 394 int length = bailout_entries_.length();
403 Handle<DeoptimizationOutputData> data = isolate()->factory()-> 395 Handle<DeoptimizationOutputData> data = isolate()->factory()->
404 NewDeoptimizationOutputData(length, TENURED); 396 NewDeoptimizationOutputData(length, TENURED);
405 for (int i = 0; i < length; i++) { 397 for (int i = 0; i < length; i++) {
406 data->SetAstId(i, bailout_entries_[i].id); 398 data->SetAstId(i, bailout_entries_[i].id);
407 data->SetPcAndState(i, Smi::FromInt(bailout_entries_[i].pc_and_state)); 399 data->SetPcAndState(i, Smi::FromInt(bailout_entries_[i].pc_and_state));
408 } 400 }
409 code->set_deoptimization_data(*data); 401 code->set_deoptimization_data(*data);
410 } 402 }
411 403
412 404
413 void FullCodeGenerator::PopulateTypeFeedbackInfo(Handle<Code> code) { 405 void FullCodeGenerator::PopulateTypeFeedbackInfo(Handle<Code> code) {
414 Handle<TypeFeedbackInfo> info = isolate()->factory()->NewTypeFeedbackInfo(); 406 Handle<TypeFeedbackInfo> info = isolate()->factory()->NewTypeFeedbackInfo();
415 info->set_ic_total_count(ic_total_count_); 407 info->set_ic_total_count(ic_total_count_);
416 info->set_feedback_vector(*FeedbackVector());
417 ASSERT(!isolate()->heap()->InNewSpace(*info)); 408 ASSERT(!isolate()->heap()->InNewSpace(*info));
418 code->set_type_feedback_info(*info); 409 code->set_type_feedback_info(*info);
419 } 410 }
420 411
421 412
422 void FullCodeGenerator::Initialize() { 413 void FullCodeGenerator::Initialize() {
423 // The generation of debug code must match between the snapshot code and the 414 // The generation of debug code must match between the snapshot code and the
424 // code that is generated later. This is assumed by the debugger when it is 415 // code that is generated later. This is assumed by the debugger when it is
425 // calculating PC offsets after generating a debug version of code. Therefore 416 // calculating PC offsets after generating a debug version of code. Therefore
426 // we disable the production of debug code in the full compiler if we are 417 // we disable the production of debug code in the full compiler if we are
427 // either generating a snapshot or we booted from a snapshot. 418 // either generating a snapshot or we booted from a snapshot.
428 generate_debug_code_ = FLAG_debug_code && 419 generate_debug_code_ = FLAG_debug_code &&
429 !Serializer::enabled() && 420 !Serializer::enabled() &&
430 !Snapshot::HaveASnapshotToStartFrom(); 421 !Snapshot::HaveASnapshotToStartFrom();
431 masm_->set_emit_debug_code(generate_debug_code_); 422 masm_->set_emit_debug_code(generate_debug_code_);
432 masm_->set_predictable_code_size(true); 423 masm_->set_predictable_code_size(true);
433 InitializeAstVisitor(info_->zone()); 424 InitializeAstVisitor(info_->zone());
434 } 425 }
435 426
436 427
428 void FullCodeGenerator::PopulateTypeFeedbackCells(Handle<Code> code) {
429 if (type_feedback_cells_.is_empty()) return;
430 int length = type_feedback_cells_.length();
431 int array_size = TypeFeedbackCells::LengthOfFixedArray(length);
432 Handle<TypeFeedbackCells> cache = Handle<TypeFeedbackCells>::cast(
433 isolate()->factory()->NewFixedArray(array_size, TENURED));
434 for (int i = 0; i < length; i++) {
435 cache->SetAstId(i, type_feedback_cells_[i].ast_id);
436 cache->SetCell(i, *type_feedback_cells_[i].cell);
437 }
438 TypeFeedbackInfo::cast(code->type_feedback_info())->set_type_feedback_cells(
439 *cache);
440 }
441
442
437 void FullCodeGenerator::PrepareForBailout(Expression* node, State state) { 443 void FullCodeGenerator::PrepareForBailout(Expression* node, State state) {
438 PrepareForBailoutForId(node->id(), state); 444 PrepareForBailoutForId(node->id(), state);
439 } 445 }
440 446
441 447
442 void FullCodeGenerator::CallLoadIC(ContextualMode contextual_mode, 448 void FullCodeGenerator::CallLoadIC(ContextualMode contextual_mode,
443 TypeFeedbackId id) { 449 TypeFeedbackId id) {
444 ExtraICState extra_state = LoadIC::ComputeExtraICState(contextual_mode); 450 ExtraICState extra_state = LoadIC::ComputeExtraICState(contextual_mode);
445 Handle<Code> ic = LoadIC::initialize_stub(isolate(), extra_state); 451 Handle<Code> ic = LoadIC::initialize_stub(isolate(), extra_state);
446 CallIC(ic, id); 452 CallIC(ic, contextual_mode, id);
447 } 453 }
448 454
449 455
450 void FullCodeGenerator::CallStoreIC(TypeFeedbackId id) { 456 void FullCodeGenerator::CallStoreIC(ContextualMode mode, TypeFeedbackId id) {
451 Handle<Code> ic = StoreIC::initialize_stub(isolate(), strict_mode()); 457 Handle<Code> ic = StoreIC::initialize_stub(isolate(), strict_mode());
452 CallIC(ic, id); 458 CallIC(ic, mode, id);
453 } 459 }
454 460
455 461
456 void FullCodeGenerator::RecordJSReturnSite(Call* call) { 462 void FullCodeGenerator::RecordJSReturnSite(Call* call) {
457 // We record the offset of the function return so we can rebuild the frame 463 // We record the offset of the function return so we can rebuild the frame
458 // if the function was inlined, i.e., this is the return address in the 464 // if the function was inlined, i.e., this is the return address in the
459 // inlined function's frame. 465 // inlined function's frame.
460 // 466 //
461 // The state is ignored. We defensively set it to TOS_REG, which is the 467 // The state is ignored. We defensively set it to TOS_REG, which is the
462 // real state of the unoptimized code at the return site. 468 // real state of the unoptimized code at the return site.
(...skipping 14 matching lines...) Expand all
477 unsigned pc_and_state = 483 unsigned pc_and_state =
478 StateField::encode(state) | PcField::encode(masm_->pc_offset()); 484 StateField::encode(state) | PcField::encode(masm_->pc_offset());
479 ASSERT(Smi::IsValid(pc_and_state)); 485 ASSERT(Smi::IsValid(pc_and_state));
480 BailoutEntry entry = { id, pc_and_state }; 486 BailoutEntry entry = { id, pc_and_state };
481 ASSERT(!prepared_bailout_ids_.Contains(id.ToInt())); 487 ASSERT(!prepared_bailout_ids_.Contains(id.ToInt()));
482 prepared_bailout_ids_.Add(id.ToInt(), zone()); 488 prepared_bailout_ids_.Add(id.ToInt(), zone());
483 bailout_entries_.Add(entry, zone()); 489 bailout_entries_.Add(entry, zone());
484 } 490 }
485 491
486 492
493 void FullCodeGenerator::RecordTypeFeedbackCell(
494 TypeFeedbackId id, Handle<Cell> cell) {
495 TypeFeedbackCellEntry entry = { id, cell };
496 type_feedback_cells_.Add(entry, zone());
497 }
498
499
487 void FullCodeGenerator::RecordBackEdge(BailoutId ast_id) { 500 void FullCodeGenerator::RecordBackEdge(BailoutId ast_id) {
488 // The pc offset does not need to be encoded and packed together with a state. 501 // The pc offset does not need to be encoded and packed together with a state.
489 ASSERT(masm_->pc_offset() > 0); 502 ASSERT(masm_->pc_offset() > 0);
490 ASSERT(loop_depth() > 0); 503 ASSERT(loop_depth() > 0);
491 uint8_t depth = Min(loop_depth(), Code::kMaxLoopNestingMarker); 504 uint8_t depth = Min(loop_depth(), Code::kMaxLoopNestingMarker);
492 BackEdgeEntry entry = 505 BackEdgeEntry entry =
493 { ast_id, static_cast<unsigned>(masm_->pc_offset()), depth }; 506 { ast_id, static_cast<unsigned>(masm_->pc_offset()), depth };
494 back_edges_.Add(entry, zone()); 507 back_edges_.Add(entry, zone());
495 } 508 }
496 509
(...skipping 1231 matching lines...) Expand 10 before | Expand all | Expand 10 after
1728 } 1741 }
1729 return true; 1742 return true;
1730 } 1743 }
1731 #endif // DEBUG 1744 #endif // DEBUG
1732 1745
1733 1746
1734 #undef __ 1747 #undef __
1735 1748
1736 1749
1737 } } // namespace v8::internal 1750 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/full-codegen.h ('k') | src/global-handles.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698