Index: src/compiler/fast-accessor-assembler.h |
diff --git a/src/compiler/fast-accessor-assembler.h b/src/compiler/fast-accessor-assembler.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..2c98d9141c4547e26e68fd39fe46fb1a028ce769 |
--- /dev/null |
+++ b/src/compiler/fast-accessor-assembler.h |
@@ -0,0 +1,106 @@ |
+// Copyright 2015 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. |
+ |
+#ifndef V8_COMPILER_FAST_ACCESSOR_ASSEMBLER_H_ |
+#define V8_COMPILER_FAST_ACCESSOR_ASSEMBLER_H_ |
+ |
+#include <stdint.h> |
+#include <vector> |
+ |
+#include "src/base/macros.h" |
+#include "src/base/smart-pointers.h" |
+#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.
|
+#include "src/handles.h" |
+ |
+ |
+namespace v8 { |
+namespace internal { |
+ |
+class Code; |
+class Isolate; |
+class Zone; |
+ |
+namespace compiler { |
+ |
+class CallDescriptor; |
+class Label; |
+class Node; |
+ |
+ |
+// This interface "exports" an aggregated subset of RawMachineAssembler, for |
+// 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.
|
+// |
+// This interface is made for this single purpose only and does not attempt |
+// to implement a general purpose solution. If you need one, please look at |
+// RawMachineAssembler instead. |
+// |
+// The life cycle of a FastAccessorAssembler has two phases: |
+// - After creating the instance, you can call an arbitrary sequence of |
+// builder functions to build the desired function. |
+// - When done, you can Build() the accessor and query for the build results. |
+// |
+// You cannot call any result getters before Build() was called & successful; |
+// and you cannot call any builder functions after Build() was called. |
+class FastAccessorAssembler { |
+ public: |
+ typedef v8::experimental::FastAccessorBuilder::ValueId ValueId; |
+ typedef v8::experimental::FastAccessorBuilder::LabelId LabelId; |
+ |
+ explicit FastAccessorAssembler(Isolate* isolate); |
+ ~FastAccessorAssembler(); |
+ |
+ // Builder / assembler functions: |
+ ValueId IntegerConstant(int int_constant); |
+ ValueId GetCallTarget(); |
+ ValueId GetParameter(size_t parameter_no); |
+ ValueId GetInternalField(ValueId value_id, int field_no); |
+ ValueId LoadValue(ValueId value_id, int offset); |
+ ValueId LoadObject(ValueId value_id, int offset); |
+ // .. call native. |
+ // .. throw exception |
+ |
+ // Builder / assembler functions for control flow. |
+ void ReturnValue(ValueId value_id); |
+ void CheckFlagSetOrReturnNull(ValueId value_id, int mask); |
+ void CheckNotNullOrReturnNull(ValueId value_id); |
+ // void CheckNotNullOrCallback(ValueId value_id, ..c++-callback type..., |
+ // ValueId arg1, ValueId arg2, ...); |
+ LabelId MakeLabel(); |
+ void SetLabel(LabelId label_id); |
+ void CheckNotNullOrJump(ValueId value_id, LabelId label_id); |
+ |
+ // Assemble the code. |
+ Handle<Code> Build(); |
+ |
+ private: |
+ ValueId FromRaw(Node* node); |
+ LabelId FromRaw(RawMachineAssembler::Label* label); |
+ Node* FromId(ValueId value) const; |
+ RawMachineAssembler::Label* FromId(LabelId value) const; |
+ |
+ Zone* zone() { return &zone_; } |
+ |
+ Zone zone_; |
+ base::SmartPointer<RawMachineAssembler> assembler_; |
+ |
+ // To prevent exposing the RMA internals to the outside world, we'll map |
+ // Node + Label pointers to ValueId integers, and use two vectors to |
+ // remember + check them. |
+ // Since ValueIds can map to either nodes_ or labels_, we can't use the |
+ // same slot for both. |
+ std::vector<Node*> nodes_; |
+ std::vector<RawMachineAssembler::Label*> labels_; |
+ |
+ // Remember the current state for easy error checking. (We prefer to be |
+ // strict as this class will be exposed at the API.) |
+ 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.
|
+ |
+ DISALLOW_COPY_AND_ASSIGN(FastAccessorAssembler); |
+}; |
+ |
+} // namespace compiler |
+} // namespace internal |
+} // namespace v8 |
+ |
+#endif // V8_COMPILER_FAST_ACCESSOR_ASSEMBLER_H_ |