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

Side by Side Diff: src/runtime.cc

Issue 22424002: Wrap back edge table in an iterator. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 4 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/objects.cc ('k') | no next file » | 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 8529 matching lines...) Expand 10 before | Expand all | Expand 10 after
8540 // The top JS function is this one, the PC is somewhere in the 8540 // The top JS function is this one, the PC is somewhere in the
8541 // unoptimized code. 8541 // unoptimized code.
8542 JavaScriptFrameIterator it(isolate); 8542 JavaScriptFrameIterator it(isolate);
8543 JavaScriptFrame* frame = it.frame(); 8543 JavaScriptFrame* frame = it.frame();
8544 ASSERT(frame->function() == *function); 8544 ASSERT(frame->function() == *function);
8545 ASSERT(frame->LookupCode() == *unoptimized); 8545 ASSERT(frame->LookupCode() == *unoptimized);
8546 ASSERT(unoptimized->contains(frame->pc())); 8546 ASSERT(unoptimized->contains(frame->pc()));
8547 8547
8548 // Use linear search of the unoptimized code's back edge table to find 8548 // Use linear search of the unoptimized code's back edge table to find
8549 // the AST id matching the PC. 8549 // the AST id matching the PC.
8550 Address start = unoptimized->instruction_start(); 8550 uint32_t target_pc_offset = frame->pc() - unoptimized->instruction_start();
8551 unsigned target_pc_offset = static_cast<unsigned>(frame->pc() - start);
8552 Address table_cursor = start + unoptimized->back_edge_table_offset();
8553 uint32_t table_length = Memory::uint32_at(table_cursor);
8554 table_cursor += kIntSize;
8555 uint32_t loop_depth = 0; 8551 uint32_t loop_depth = 0;
8556 for (unsigned i = 0; i < table_length; ++i) { 8552
8557 // Table entries are (AST id, pc offset) pairs. 8553 for (FullCodeGenerator::BackEdgeTableIterator back_edges(*unoptimized);
8558 uint32_t pc_offset = Memory::uint32_at(table_cursor + kIntSize); 8554 !back_edges.Done();
8559 if (pc_offset == target_pc_offset) { 8555 back_edges.Next()) {
8560 ast_id = BailoutId(static_cast<int>(Memory::uint32_at(table_cursor))); 8556 if (back_edges.pc_offset() == target_pc_offset) {
8561 loop_depth = Memory::uint32_at(table_cursor + 2 * kIntSize); 8557 ast_id = back_edges.ast_id();
8558 loop_depth = back_edges.loop_depth();
8562 break; 8559 break;
8563 } 8560 }
8564 table_cursor += FullCodeGenerator::kBackEdgeEntrySize;
8565 } 8561 }
8566 ASSERT(!ast_id.IsNone()); 8562 ASSERT(!ast_id.IsNone());
8563
8567 if (FLAG_trace_osr) { 8564 if (FLAG_trace_osr) {
8568 PrintF("[replacing on-stack at AST id %d, loop depth %d in ", 8565 PrintF("[replacing on-stack at AST id %d, loop depth %d in ",
8569 ast_id.ToInt(), loop_depth); 8566 ast_id.ToInt(), loop_depth);
8570 function->PrintName(); 8567 function->PrintName();
8571 PrintF("]\n"); 8568 PrintF("]\n");
8572 } 8569 }
8573 8570
8574 // Try to compile the optimized code. A true return value from 8571 // Try to compile the optimized code. A true return value from
8575 // CompileOptimized means that compilation succeeded, not necessarily 8572 // CompileOptimized means that compilation succeeded, not necessarily
8576 // that optimization succeeded. 8573 // that optimization succeeded.
(...skipping 5584 matching lines...) Expand 10 before | Expand all | Expand 10 after
14161 // Handle last resort GC and make sure to allow future allocations 14158 // Handle last resort GC and make sure to allow future allocations
14162 // to grow the heap without causing GCs (if possible). 14159 // to grow the heap without causing GCs (if possible).
14163 isolate->counters()->gc_last_resort_from_js()->Increment(); 14160 isolate->counters()->gc_last_resort_from_js()->Increment();
14164 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, 14161 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags,
14165 "Runtime::PerformGC"); 14162 "Runtime::PerformGC");
14166 } 14163 }
14167 } 14164 }
14168 14165
14169 14166
14170 } } // namespace v8::internal 14167 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698