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

Unified Diff: src/ia32/lithium-codegen-ia32.cc

Issue 10910161: Partial ia32 implementation of optimized try/catch (by Kevin Millikin) (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fixed build. Created 8 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/ia32/lithium-codegen-ia32.h ('k') | src/ia32/lithium-ia32.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ia32/lithium-codegen-ia32.cc
diff --git a/src/ia32/lithium-codegen-ia32.cc b/src/ia32/lithium-codegen-ia32.cc
index 33efdd89e1dce0c9fcea673f3b5ff3ed8feb61ac..e5dd4ac8a432bb0de364a2f09352efb7f89eb033 100644
--- a/src/ia32/lithium-codegen-ia32.cc
+++ b/src/ia32/lithium-codegen-ia32.cc
@@ -83,6 +83,10 @@ bool LCodeGen::GenerateCode() {
!chunk()->graph()->is_recursive()) ||
!info()->osr_ast_id().IsNone();
+ handler_table_ = isolate()->factory()->NewFixedArray(
+ info()->function()->handler_count(), TENURED);
+
+
return GeneratePrologue() &&
GenerateBody() &&
GenerateDeferredCode() &&
@@ -94,6 +98,7 @@ void LCodeGen::FinishCode(Handle<Code> code) {
ASSERT(is_done());
code->set_stack_slots(GetStackSlotCount());
code->set_safepoint_table_offset(safepoints_.GetCodeOffset());
+ code->set_handler_table(*handler_table_);
PopulateDeoptimizationData(code);
Deoptimizer::EnsureRelocSpaceForLazyDeoptimization(code);
}
@@ -418,7 +423,8 @@ void LCodeGen::WriteTranslation(LEnvironment* environment,
: Translation::kSelfLiteralId;
switch (environment->frame_type()) {
case JS_FUNCTION:
- translation->BeginJSFrame(environment->ast_id(), closure_id, height);
+ translation->BeginJSFrame(environment->ast_id(), closure_id, height,
+ environment->handler_count());
break;
case JS_CONSTRUCT:
translation->BeginConstructStubFrame(closure_id, translation_size);
@@ -697,6 +703,16 @@ void LCodeGen::PopulateDeoptimizationData(Handle<Code> code) {
data->SetTranslationIndex(i, Smi::FromInt(env->translation_index()));
data->SetArgumentsStackHeight(i,
Smi::FromInt(env->arguments_stack_height()));
+ // Write the total handler count to the deoptimization data, used to
+ // determine the stack sizes.
+ int handler_count = 0;
+ LEnvironment* current = env;
+ do {
+ handler_count += current->handler_count();
+ current = current->outer();
+ } while (current != NULL);
+ data->SetHandlerCount(i, Smi::FromInt(handler_count));
+
data->SetPc(i, Smi::FromInt(env->pc_offset()));
}
code->set_deoptimization_data(*data);
@@ -819,6 +835,38 @@ void LCodeGen::DoInstructionGap(LInstructionGap* instr) {
}
+void LCodeGen::DoEnterTry(LEnterTry* instr) {
+ Label try_entry, handler_entry;
+ __ jmp(&try_entry);
+ __ bind(&handler_entry);
+ handler_table_->set(instr->hydrogen()->index(),
+ Smi::FromInt(handler_entry.pos()));
+ // Save code object.
+ __ push(edi);
+ // Pass code object as argument.
+ __ push(edi);
+ // Call Runtime_CatchInOptimizedCode which patches the code with the call to
+ // the deopt stub and returns the offset to the address we must jump to.
+ __ CallRuntime(Runtime::kCatchInOptimizedCode, 1);
+ // Get actual offset.
+ __ SmiUntag(eax);
+ // Restore code object.
+ __ pop(edi);
+ // Compute the target PC adding the offset to the code object.
+ __ add(edi, eax);
+ // Jump to target PC.
+ __ jmp(edi);
+ __ Abort("Unreachable (the exception should have been caught).");
+ __ bind(&try_entry);
+ __ PushTryHandler(StackHandler::OPTIMIZED_CATCH, instr->index());
+}
+
+
+void LCodeGen::DoLeaveTry(LLeaveTry* instr) {
+ __ PopTryHandler();
+}
+
+
void LCodeGen::DoParameter(LParameter* instr) {
// Nothing to do.
}
@@ -1488,10 +1536,13 @@ void LCodeGen::DoThrow(LThrow* instr) {
ASSERT(ToRegister(instr->context()).is(esi));
CallRuntime(Runtime::kThrow, 1, instr);
+ // Code after a throw now is reachable...
+#if false
if (FLAG_debug_code) {
- Comment("Unreachable code.");
+ Comment("Code after a throw should be unreachable.");
__ int3();
}
+#endif
}
« no previous file with comments | « src/ia32/lithium-codegen-ia32.h ('k') | src/ia32/lithium-ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698