OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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/interpreter/handler-table-builder.h" | 5 #include "src/interpreter/handler-table-builder.h" |
6 | 6 |
7 #include "src/factory.h" | 7 #include "src/factory.h" |
8 #include "src/isolate.h" | 8 #include "src/isolate.h" |
9 #include "src/objects-inl.h" | 9 #include "src/objects-inl.h" |
10 | 10 |
11 namespace v8 { | 11 namespace v8 { |
12 namespace internal { | 12 namespace internal { |
13 namespace interpreter { | 13 namespace interpreter { |
14 | 14 |
15 HandlerTableBuilder::HandlerTableBuilder(Isolate* isolate, Zone* zone) | 15 HandlerTableBuilder::HandlerTableBuilder(Isolate* isolate, Zone* zone) |
16 : isolate_(isolate), entries_(zone) {} | 16 : isolate_(isolate), entries_(zone) {} |
17 | 17 |
18 Handle<HandlerTable> HandlerTableBuilder::ToHandlerTable() { | 18 Handle<HandlerTable> HandlerTableBuilder::ToHandlerTable() { |
19 int handler_table_size = static_cast<int>(entries_.size()); | 19 int handler_table_size = static_cast<int>(entries_.size()); |
20 Handle<HandlerTable> table = | 20 Handle<HandlerTable> table = |
21 Handle<HandlerTable>::cast(isolate_->factory()->NewFixedArray( | 21 Handle<HandlerTable>::cast(isolate_->factory()->NewFixedArray( |
22 HandlerTable::LengthForRange(handler_table_size), TENURED)); | 22 HandlerTable::LengthForRange(handler_table_size), TENURED)); |
23 for (int i = 0; i < handler_table_size; ++i) { | 23 for (int i = 0; i < handler_table_size; ++i) { |
24 Entry& entry = entries_[i]; | 24 Entry& entry = entries_[i]; |
25 HandlerTable::CatchPrediction pred = | 25 HandlerTable::CatchPrediction pred = |
26 entry.will_catch ? HandlerTable::CAUGHT : HandlerTable::UNCAUGHT; | 26 entry.will_catch ? HandlerTable::CAUGHT : HandlerTable::UNCAUGHT; |
27 table->SetRangeStart(i, static_cast<int>(entry.offset_start)); | 27 table->SetRangeStart(i, static_cast<int>(entry.offset_start)); |
28 table->SetRangeEnd(i, static_cast<int>(entry.offset_end)); | 28 table->SetRangeEnd(i, static_cast<int>(entry.offset_end)); |
29 table->SetRangeHandler(i, static_cast<int>(entry.offset_target), pred); | 29 table->SetRangeHandler(i, static_cast<int>(entry.offset_target), pred); |
30 table->SetRangeDepth(i, entry.context.index()); | 30 table->SetRangeData(i, entry.context.index()); |
31 } | 31 } |
32 return table; | 32 return table; |
33 } | 33 } |
34 | 34 |
35 | 35 |
36 int HandlerTableBuilder::NewHandlerEntry() { | 36 int HandlerTableBuilder::NewHandlerEntry() { |
37 int handler_id = static_cast<int>(entries_.size()); | 37 int handler_id = static_cast<int>(entries_.size()); |
38 Entry entry = {0, 0, 0, Register(), false}; | 38 Entry entry = {0, 0, 0, Register(), false}; |
39 entries_.push_back(entry); | 39 entries_.push_back(entry); |
40 return handler_id; | 40 return handler_id; |
(...skipping 23 matching lines...) Expand all Loading... |
64 } | 64 } |
65 | 65 |
66 | 66 |
67 void HandlerTableBuilder::SetContextRegister(int handler_id, Register reg) { | 67 void HandlerTableBuilder::SetContextRegister(int handler_id, Register reg) { |
68 entries_[handler_id].context = reg; | 68 entries_[handler_id].context = reg; |
69 } | 69 } |
70 | 70 |
71 } // namespace interpreter | 71 } // namespace interpreter |
72 } // namespace internal | 72 } // namespace internal |
73 } // namespace v8 | 73 } // namespace v8 |
OLD | NEW |