 Chromium Code Reviews
 Chromium Code Reviews Issue 1474543004:
  Implement Fast Accessor Builder  (Closed) 
  Base URL: https://chromium.googlesource.com/v8/v8.git@master
    
  
    Issue 1474543004:
  Implement Fast Accessor Builder  (Closed) 
  Base URL: https://chromium.googlesource.com/v8/v8.git@master| 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/handles.h" | |
| 14 | |
| 15 | |
| 16 namespace v8 { | |
| 17 namespace internal { | |
| 18 | |
| 19 class Code; | |
| 20 class Isolate; | |
| 21 class Zone; | |
| 22 | |
| 23 namespace compiler { | |
| 24 | |
| 25 class CallDescriptor; | |
| 26 class Label; | |
| 27 class Node; | |
| 28 class RawMachineAssembler; | |
| 29 | |
| 30 // This interface "exports" an aggregated subset of RawMachineAssembler, for | |
| 31 // use by the API to implement Fast Dom Accessors. (crbug.com/508898). | |
| 32 // | |
| 33 // This interface is made for this single purpose only and does not attempt | |
| 34 // to implement a general purpose solution. If you need one, please look at | |
| 35 // RawMachineAssembler instead. | |
| 36 // | |
| 37 // The life cycle of a FastAccessorAssembler has two phases: | |
| 38 // - After creating the instance, you can call an arbitrary sequence of | |
| 39 // builder functions to build the desired function. | |
| 40 // - When done, you can Build() the accessor and query for the build results. | |
| 41 // You cannot call any result getters before Build() was called & successful; | |
| 42 // and you cannot call any builder functions after Build() was called. | |
| 43 class FastAccessorAssembler { | |
| 44 public: | |
| 45 typedef size_t ValueId; | |
| 
epertoso
2015/11/25 10:31:16
vector<Node*>::size_type would be more accurate.
 | |
| 46 | |
| 47 explicit FastAccessorAssembler(Isolate* isolate); | |
| 48 ~FastAccessorAssembler(); | |
| 49 | |
| 50 // Builder / assembler functions: | |
| 
epertoso
2015/11/25 10:31:16
GetInternalField, LoadObject, CheckFlagsSetOrRetur
 | |
| 51 ValueId IntegerConstant(int int_constant); | |
| 52 ValueId GetParameter(size_t parameter_no); | |
| 53 ValueId GetInternalField(ValueId value_id, int field_no); | |
| 54 ValueId LoadValue(ValueId value_id, int offset); | |
| 55 ValueId LoadObject(ValueId value_id, int offset); | |
| 56 // .. call native. | |
| 57 // .. throw exception | |
| 58 | |
| 59 // Builder / assembler functions for control flow. | |
| 60 void ReturnValue(ValueId); | |
| 61 void CheckFlagSetOrReturnNull(ValueId value_id, int mask); | |
| 62 void CheckNotNullOrReturnNull(ValueId value_id); | |
| 63 // void CheckNotNullOrCallback(ValueId value_id, ..c++-callback type..., | |
| 64 // ValueId arg1, ValueId arg2, ...); | |
| 65 ValueId SetLabel(); | |
| 66 void CheckNotNullOrJump(ValueId value_id, ValueId label_id); | |
| 67 | |
| 68 // Assemble the code. | |
| 69 Handle<Code> Build(); | |
| 70 | |
| 71 // Obtain build results: | |
| 72 CallDescriptor* GetCallDescriptor() const; | |
| 73 //... GetGraph, Schedule, call descriptor ??? | |
| 74 | |
| 75 | |
| 76 private: | |
| 77 ValueId FromNode(Node* node); | |
| 78 ValueId FromLabel(Label* label); | |
| 
epertoso
2015/11/25 10:31:15
FromLabel and LabelFromValue are not implemented.
 | |
| 79 Node* FromValue(ValueId value) const; | |
| 80 Label* LabelFromValue(ValueId 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<Label*> labels_; | |
| 
epertoso
2015/11/25 10:31:16
You're never using labels_, are you?
 | |
| 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_; | |
| 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 |