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

Unified Diff: src/interpreter/handler-table-builder.cc

Issue 1607433005: [interpreter] Implement exception handler table building. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Added moar tests. Created 4 years, 11 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/interpreter/handler-table-builder.h ('k') | src/objects.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/interpreter/handler-table-builder.cc
diff --git a/src/interpreter/handler-table-builder.cc b/src/interpreter/handler-table-builder.cc
new file mode 100644
index 0000000000000000000000000000000000000000..866655306b29b6c9f90d32d738063b207dc66538
--- /dev/null
+++ b/src/interpreter/handler-table-builder.cc
@@ -0,0 +1,73 @@
+// Copyright 2016 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "src/interpreter/handler-table-builder.h"
+
+#include "src/factory.h"
+#include "src/isolate.h"
+#include "src/objects-inl.h"
+
+namespace v8 {
+namespace internal {
+namespace interpreter {
+
+HandlerTableBuilder::HandlerTableBuilder(Isolate* isolate, Zone* zone)
+ : isolate_(isolate), entries_(zone) {}
+
+Handle<HandlerTable> HandlerTableBuilder::ToHandlerTable() {
+ int handler_table_size = static_cast<int>(entries_.size());
+ Handle<HandlerTable> table =
+ Handle<HandlerTable>::cast(isolate_->factory()->NewFixedArray(
+ HandlerTable::LengthForRange(handler_table_size), TENURED));
+ for (int i = 0; i < handler_table_size; ++i) {
+ Entry& entry = entries_[i];
+ HandlerTable::CatchPrediction pred =
+ entry.will_catch ? HandlerTable::CAUGHT : HandlerTable::UNCAUGHT;
+ table->SetRangeStart(i, static_cast<int>(entry.offset_start));
+ table->SetRangeEnd(i, static_cast<int>(entry.offset_end));
+ table->SetRangeHandler(i, static_cast<int>(entry.offset_target), pred);
+ table->SetRangeDepth(i, entry.context.index());
+ }
+ return table;
+}
+
+
+int HandlerTableBuilder::NewHandlerEntry() {
+ int handler_id = static_cast<int>(entries_.size());
+ Entry entry = {0, 0, 0, Register(), false};
+ entries_.push_back(entry);
+ return handler_id;
+}
+
+
+void HandlerTableBuilder::SetTryRegionStart(int handler_id, size_t offset) {
+ DCHECK(Smi::IsValid(offset)); // Encoding of handler table requires this.
+ entries_[handler_id].offset_start = offset;
+}
+
+
+void HandlerTableBuilder::SetTryRegionEnd(int handler_id, size_t offset) {
+ DCHECK(Smi::IsValid(offset)); // Encoding of handler table requires this.
+ entries_[handler_id].offset_end = offset;
+}
+
+
+void HandlerTableBuilder::SetHandlerTarget(int handler_id, size_t offset) {
+ DCHECK(Smi::IsValid(offset)); // Encoding of handler table requires this.
+ entries_[handler_id].offset_target = offset;
+}
+
+
+void HandlerTableBuilder::SetPrediction(int handler_id, bool will_catch) {
+ entries_[handler_id].will_catch = will_catch;
+}
+
+
+void HandlerTableBuilder::SetContextRegister(int handler_id, Register reg) {
+ entries_[handler_id].context = reg;
+}
+
+} // namespace interpreter
+} // namespace internal
+} // namespace v8
« no previous file with comments | « src/interpreter/handler-table-builder.h ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698