Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 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 | 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 #ifndef V8_FAST_ACCESSOR_ASSEMBLER_H_ | 5 #ifndef V8_FAST_ACCESSOR_ASSEMBLER_H_ |
| 6 #define V8_FAST_ACCESSOR_ASSEMBLER_H_ | 6 #define V8_FAST_ACCESSOR_ASSEMBLER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 47 typedef v8::experimental::FastAccessorBuilder::LabelId LabelId; | 47 typedef v8::experimental::FastAccessorBuilder::LabelId LabelId; |
| 48 typedef v8::FunctionCallback FunctionCallback; | 48 typedef v8::FunctionCallback FunctionCallback; |
| 49 | 49 |
| 50 explicit FastAccessorAssembler(Isolate* isolate); | 50 explicit FastAccessorAssembler(Isolate* isolate); |
| 51 ~FastAccessorAssembler(); | 51 ~FastAccessorAssembler(); |
| 52 | 52 |
| 53 // Builder / assembler functions: | 53 // Builder / assembler functions: |
| 54 ValueId IntegerConstant(int int_constant); | 54 ValueId IntegerConstant(int int_constant); |
| 55 ValueId GetReceiver(); | 55 ValueId GetReceiver(); |
| 56 ValueId LoadInternalField(ValueId value_id, int field_no); | 56 ValueId LoadInternalField(ValueId value_id, int field_no); |
| 57 | |
| 58 // Loads internal field and assumes the object is indeed a valid API object | |
| 59 // with the proper internal fields present. | |
| 60 // The intended use is to call this on an object whose structure has already | |
| 61 // been checked previously, e.g. the accessor's receiver, which is map-checked | |
| 62 // before the fast accessor is called on it. Using this on an arbitrary object | |
| 63 // will result in unsafe memory accesses. | |
| 64 ValueId LoadInternalFieldUnchecked(ValueId value_id, int field_no); | |
| 65 | |
| 57 ValueId LoadValue(ValueId value_id, int offset); | 66 ValueId LoadValue(ValueId value_id, int offset); |
| 58 ValueId LoadObject(ValueId value_id, int offset); | 67 ValueId LoadObject(ValueId value_id, int offset); |
| 59 | 68 |
| 60 // Builder / assembler functions for control flow. | 69 // Builder / assembler functions for control flow. |
| 61 void ReturnValue(ValueId value_id); | 70 void ReturnValue(ValueId value_id); |
| 62 void CheckFlagSetOrReturnNull(ValueId value_id, int mask); | 71 void CheckFlagSetOrReturnNull(ValueId value_id, int mask); |
| 63 void CheckNotZeroOrReturnNull(ValueId value_id); | 72 void CheckNotZeroOrReturnNull(ValueId value_id); |
| 64 LabelId MakeLabel(); | 73 LabelId MakeLabel(); |
| 65 void SetLabel(LabelId label_id); | 74 void SetLabel(LabelId label_id); |
| 66 void CheckNotZeroOrJump(ValueId value_id, LabelId label_id); | 75 void CheckNotZeroOrJump(ValueId value_id, LabelId label_id); |
| 67 | 76 |
| 68 // C++ callback. | 77 // C++ callback. |
| 69 ValueId Call(FunctionCallback callback, ValueId arg); | 78 ValueId Call(FunctionCallback callback, ValueId arg); |
| 70 | 79 |
| 71 // Assemble the code. | 80 // Assemble the code. |
| 72 MaybeHandle<Code> Build(); | 81 MaybeHandle<Code> Build(); |
| 73 | 82 |
| 74 private: | 83 private: |
| 75 ValueId FromRaw(compiler::Node* node); | 84 ValueId FromRaw(compiler::Node* node); |
| 76 LabelId FromRaw(CodeStubAssembler::Label* label); | 85 LabelId FromRaw(CodeStubAssembler::Label* label); |
| 77 compiler::Node* FromId(ValueId value) const; | 86 compiler::Node* FromId(ValueId value) const; |
| 78 CodeStubAssembler::Label* FromId(LabelId value) const; | 87 CodeStubAssembler::Label* FromId(LabelId value) const; |
| 88 void CheckIsJSObjectOrJump(ValueId value, LabelId label_id); | |
|
vogelheim
2016/08/08 11:47:22
nitpick: Maybe add empty line. The previous 4 meth
Alfonso
2016/08/08 13:03:28
Acknowledged.
| |
| 79 | 89 |
| 80 void Clear(); | 90 void Clear(); |
| 81 Zone* zone() { return &zone_; } | 91 Zone* zone() { return &zone_; } |
| 82 Isolate* isolate() const { return isolate_; } | 92 Isolate* isolate() const { return isolate_; } |
| 83 | 93 |
| 84 Zone zone_; | 94 Zone zone_; |
| 85 Isolate* isolate_; | 95 Isolate* isolate_; |
| 86 std::unique_ptr<CodeStubAssembler> assembler_; | 96 std::unique_ptr<CodeStubAssembler> assembler_; |
| 87 | 97 |
| 88 // To prevent exposing the RMA internals to the outside world, we'll map | 98 // To prevent exposing the RMA internals to the outside world, we'll map |
| 89 // Node + Label pointers integers wrapped in ValueId and LabelId instances. | 99 // Node + Label pointers integers wrapped in ValueId and LabelId instances. |
| 90 // These vectors maintain this mapping. | 100 // These vectors maintain this mapping. |
| 91 std::vector<compiler::Node*> nodes_; | 101 std::vector<compiler::Node*> nodes_; |
| 92 std::vector<CodeStubAssembler::Label*> labels_; | 102 std::vector<CodeStubAssembler::Label*> labels_; |
| 93 | 103 |
| 94 // Remember the current state for easy error checking. (We prefer to be | 104 // Remember the current state for easy error checking. (We prefer to be |
| 95 // strict as this class will be exposed at the API.) | 105 // strict as this class will be exposed at the API.) |
| 96 enum { kBuilding, kBuilt, kError } state_; | 106 enum { kBuilding, kBuilt, kError } state_; |
| 97 | 107 |
| 98 DISALLOW_COPY_AND_ASSIGN(FastAccessorAssembler); | 108 DISALLOW_COPY_AND_ASSIGN(FastAccessorAssembler); |
| 99 }; | 109 }; |
| 100 | 110 |
| 101 } // namespace internal | 111 } // namespace internal |
| 102 } // namespace v8 | 112 } // namespace v8 |
| 103 | 113 |
| 104 #endif // V8_FAST_ACCESSOR_ASSEMBLER_H_ | 114 #endif // V8_FAST_ACCESSOR_ASSEMBLER_H_ |
| OLD | NEW |