OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 /** |
| 6 * Implementation for v8-experimental.h. |
| 7 */ |
| 8 |
| 9 #include "src/api-experimental.h" |
| 10 |
| 11 #include "include/v8.h" |
| 12 #include "include/v8-experimental.h" |
| 13 #include "src/api.h" |
| 14 #include "src/compiler/fast-accessor-assembler.h" |
| 15 |
| 16 namespace { |
| 17 |
| 18 |
| 19 v8::internal::compiler::FastAccessorAssembler* FromApi( |
| 20 v8::experimental::FastAccessorBuilder* builder) { |
| 21 return reinterpret_cast<v8::internal::compiler::FastAccessorAssembler*>( |
| 22 builder); |
| 23 } |
| 24 |
| 25 |
| 26 v8::experimental::FastAccessorBuilder* FromInternal( |
| 27 v8::internal::compiler::FastAccessorAssembler* fast_accessor_assembler) { |
| 28 return reinterpret_cast<v8::experimental::FastAccessorBuilder*>( |
| 29 fast_accessor_assembler); |
| 30 } |
| 31 |
| 32 } // namespace |
| 33 |
| 34 namespace v8 { |
| 35 namespace internal { |
| 36 namespace experimental { |
| 37 |
| 38 |
| 39 MaybeHandle<Code> BuildCodeFromFastAccessorBuilder( |
| 40 v8::experimental::FastAccessorBuilder* fast_handler) { |
| 41 i::MaybeHandle<i::Code> code; |
| 42 if (fast_handler != nullptr) { |
| 43 auto faa = FromApi(fast_handler); |
| 44 code = faa->Build(); |
| 45 CHECK(!code.is_null()); |
| 46 delete faa; |
| 47 } |
| 48 return code; |
| 49 } |
| 50 |
| 51 } // namespace experimental |
| 52 } // namespace internal |
| 53 |
| 54 |
| 55 namespace experimental { |
| 56 |
| 57 |
| 58 FastAccessorBuilder* FastAccessorBuilder::New(Isolate* isolate) { |
| 59 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 60 internal::compiler::FastAccessorAssembler* faa = |
| 61 new internal::compiler::FastAccessorAssembler(i_isolate); |
| 62 return FromInternal(faa); |
| 63 } |
| 64 |
| 65 |
| 66 FastAccessorBuilder::ValueId FastAccessorBuilder::IntegerConstant( |
| 67 int const_value) { |
| 68 return FromApi(this)->IntegerConstant(const_value); |
| 69 } |
| 70 |
| 71 |
| 72 FastAccessorBuilder::ValueId FastAccessorBuilder::GetReceiver() { |
| 73 return FromApi(this)->GetReceiver(); |
| 74 } |
| 75 |
| 76 |
| 77 FastAccessorBuilder::ValueId FastAccessorBuilder::LoadInternalField( |
| 78 ValueId value, int field_no) { |
| 79 return FromApi(this)->LoadInternalField(value, field_no); |
| 80 } |
| 81 |
| 82 |
| 83 FastAccessorBuilder::ValueId FastAccessorBuilder::LoadValue(ValueId value_id, |
| 84 int offset) { |
| 85 return FromApi(this)->LoadValue(value_id, offset); |
| 86 } |
| 87 |
| 88 |
| 89 FastAccessorBuilder::ValueId FastAccessorBuilder::LoadObject(ValueId value_id, |
| 90 int offset) { |
| 91 return FromApi(this)->LoadObject(value_id, offset); |
| 92 } |
| 93 |
| 94 |
| 95 void FastAccessorBuilder::ReturnValue(ValueId value) { |
| 96 FromApi(this)->ReturnValue(value); |
| 97 } |
| 98 |
| 99 |
| 100 void FastAccessorBuilder::CheckFlagSetOrReturnNull(ValueId value_id, int mask) { |
| 101 FromApi(this)->CheckFlagSetOrReturnNull(value_id, mask); |
| 102 } |
| 103 |
| 104 |
| 105 void FastAccessorBuilder::CheckNotZeroOrReturnNull(ValueId value_id) { |
| 106 FromApi(this)->CheckNotZeroOrReturnNull(value_id); |
| 107 } |
| 108 |
| 109 |
| 110 FastAccessorBuilder::LabelId FastAccessorBuilder::MakeLabel() { |
| 111 return FromApi(this)->MakeLabel(); |
| 112 } |
| 113 |
| 114 |
| 115 void FastAccessorBuilder::SetLabel(LabelId label_id) { |
| 116 FromApi(this)->SetLabel(label_id); |
| 117 } |
| 118 |
| 119 |
| 120 void FastAccessorBuilder::CheckNotZeroOrJump(ValueId value_id, |
| 121 LabelId label_id) { |
| 122 FromApi(this)->CheckNotZeroOrJump(value_id, label_id); |
| 123 } |
| 124 |
| 125 } // namespace experimental |
| 126 } // namespace v8 |
OLD | NEW |