Chromium Code Reviews| 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 #ifndef V8_COMPILER_FAST_ACCESSOR_ASSEMBLER_H_ | |
| 6 #define V8_COMPILER_FAST_ACCESSOR_ASSEMBLER_H_ | |
| 7 | |
| 8 #include <stdint.h> | |
| 9 #include <vector> | |
| 10 | |
| 11 #include "src/base/macros.h" | |
| 12 #include "src/base/smart-pointers.h" | |
| 13 #include "src/compiler/raw-machine-assembler.h" | |
|
Michael Starzinger
2015/11/27 09:15:53
I understand that RMA::Label still forces us to in
Benedikt Meurer
2015/11/27 09:26:23
How about making RMA::Label forward declarable fir
epertoso
2015/11/27 10:04:56
+1.
vogelheim
2015/11/27 16:24:50
Will be done, once cl/1477413002 goes through.
vogelheim
2015/11/27 16:24:50
Done. (Comment. TODO now unnecessary, though.)
vogelheim
2015/11/30 13:41:54
Done.
| |
| 14 #include "src/handles.h" | |
| 15 | |
| 16 | |
| 17 namespace v8 { | |
| 18 namespace internal { | |
| 19 | |
| 20 class Code; | |
| 21 class Isolate; | |
| 22 class Zone; | |
| 23 | |
| 24 namespace compiler { | |
| 25 | |
| 26 class CallDescriptor; | |
| 27 class Label; | |
| 28 class Node; | |
| 29 | |
| 30 | |
| 31 // This interface "exports" an aggregated subset of RawMachineAssembler, for | |
| 32 // use by the API to implement Fast Dom Accessors. (crbug.com/508898). | |
|
Michael Starzinger
2015/11/27 09:15:53
nit: Let's drop the reference to the "crbug" in th
vogelheim
2015/11/27 16:24:50
Done.
| |
| 33 // | |
| 34 // This interface is made for this single purpose only and does not attempt | |
| 35 // to implement a general purpose solution. If you need one, please look at | |
| 36 // RawMachineAssembler instead. | |
| 37 // | |
| 38 // The life cycle of a FastAccessorAssembler has two phases: | |
| 39 // - After creating the instance, you can call an arbitrary sequence of | |
| 40 // builder functions to build the desired function. | |
| 41 // - When done, you can Build() the accessor and query for the build results. | |
| 42 // | |
| 43 // You cannot call any result getters before Build() was called & successful; | |
| 44 // and you cannot call any builder functions after Build() was called. | |
| 45 class FastAccessorAssembler { | |
| 46 public: | |
| 47 typedef v8::experimental::FastAccessorBuilder::ValueId ValueId; | |
| 48 typedef v8::experimental::FastAccessorBuilder::LabelId LabelId; | |
| 49 | |
| 50 explicit FastAccessorAssembler(Isolate* isolate); | |
| 51 ~FastAccessorAssembler(); | |
| 52 | |
| 53 // Builder / assembler functions: | |
| 54 ValueId IntegerConstant(int int_constant); | |
| 55 ValueId GetCallTarget(); | |
| 56 ValueId GetParameter(size_t parameter_no); | |
| 57 ValueId GetInternalField(ValueId value_id, int field_no); | |
| 58 ValueId LoadValue(ValueId value_id, int offset); | |
| 59 ValueId LoadObject(ValueId value_id, int offset); | |
| 60 // .. call native. | |
| 61 // .. throw exception | |
| 62 | |
| 63 // Builder / assembler functions for control flow. | |
| 64 void ReturnValue(ValueId value_id); | |
| 65 void CheckFlagSetOrReturnNull(ValueId value_id, int mask); | |
| 66 void CheckNotNullOrReturnNull(ValueId value_id); | |
| 67 // void CheckNotNullOrCallback(ValueId value_id, ..c++-callback type..., | |
| 68 // ValueId arg1, ValueId arg2, ...); | |
| 69 LabelId MakeLabel(); | |
| 70 void SetLabel(LabelId label_id); | |
| 71 void CheckNotNullOrJump(ValueId value_id, LabelId label_id); | |
| 72 | |
| 73 // Assemble the code. | |
| 74 Handle<Code> Build(); | |
| 75 | |
| 76 private: | |
| 77 ValueId FromRaw(Node* node); | |
| 78 LabelId FromRaw(RawMachineAssembler::Label* label); | |
| 79 Node* FromId(ValueId value) const; | |
| 80 RawMachineAssembler::Label* FromId(LabelId value) const; | |
| 81 | |
| 82 Zone* zone() { return &zone_; } | |
| 83 | |
| 84 Zone zone_; | |
| 85 base::SmartPointer<RawMachineAssembler> assembler_; | |
| 86 | |
| 87 // To prevent exposing the RMA internals to the outside world, we'll map | |
| 88 // Node + Label pointers to ValueId integers, and use two vectors to | |
| 89 // remember + check them. | |
| 90 // Since ValueIds can map to either nodes_ or labels_, we can't use the | |
| 91 // same slot for both. | |
| 92 std::vector<Node*> nodes_; | |
| 93 std::vector<RawMachineAssembler::Label*> labels_; | |
| 94 | |
| 95 // Remember the current state for easy error checking. (We prefer to be | |
| 96 // strict as this class will be exposed at the API.) | |
| 97 enum { BUILDING, BUILT, ERROR } state_; | |
|
Benedikt Meurer
2015/11/27 09:26:23
Nit: Can we follow the style guide and use kBuildi
vogelheim
2015/11/27 16:24:50
Done. We totally can.
| |
| 98 | |
| 99 DISALLOW_COPY_AND_ASSIGN(FastAccessorAssembler); | |
| 100 }; | |
| 101 | |
| 102 } // namespace compiler | |
| 103 } // namespace internal | |
| 104 } // namespace v8 | |
| 105 | |
| 106 #endif // V8_COMPILER_FAST_ACCESSOR_ASSEMBLER_H_ | |
| OLD | NEW |