mirror of https://github.com/lukechilds/node.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
105 lines
3.4 KiB
105 lines
3.4 KiB
9 years ago
|
// 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.
|
||
|
|
||
9 years ago
|
#ifndef V8_FAST_ACCESSOR_ASSEMBLER_H_
|
||
|
#define V8_FAST_ACCESSOR_ASSEMBLER_H_
|
||
9 years ago
|
|
||
|
#include <stdint.h>
|
||
|
#include <vector>
|
||
|
|
||
|
#include "include/v8-experimental.h"
|
||
|
#include "src/base/macros.h"
|
||
|
#include "src/base/smart-pointers.h"
|
||
|
#include "src/handles.h"
|
||
|
|
||
9 years ago
|
// For CodeStubAssembler::Label. (We cannot forward-declare inner classes.)
|
||
|
#include "src/compiler/code-stub-assembler.h"
|
||
9 years ago
|
|
||
|
namespace v8 {
|
||
|
namespace internal {
|
||
|
|
||
|
class Code;
|
||
|
class Isolate;
|
||
|
class Zone;
|
||
|
|
||
|
namespace compiler {
|
||
|
class Node;
|
||
9 years ago
|
}
|
||
9 years ago
|
|
||
|
// This interface "exports" an aggregated subset of RawMachineAssembler, for
|
||
|
// use by the API to implement Fast Dom Accessors.
|
||
|
//
|
||
|
// 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;
|
||
9 years ago
|
typedef v8::FunctionCallback FunctionCallback;
|
||
9 years ago
|
|
||
|
explicit FastAccessorAssembler(Isolate* isolate);
|
||
|
~FastAccessorAssembler();
|
||
|
|
||
|
// Builder / assembler functions:
|
||
|
ValueId IntegerConstant(int int_constant);
|
||
|
ValueId GetReceiver();
|
||
|
ValueId LoadInternalField(ValueId value_id, int field_no);
|
||
|
ValueId LoadValue(ValueId value_id, int offset);
|
||
|
ValueId LoadObject(ValueId value_id, int offset);
|
||
|
|
||
|
// Builder / assembler functions for control flow.
|
||
|
void ReturnValue(ValueId value_id);
|
||
|
void CheckFlagSetOrReturnNull(ValueId value_id, int mask);
|
||
|
void CheckNotZeroOrReturnNull(ValueId value_id);
|
||
|
LabelId MakeLabel();
|
||
|
void SetLabel(LabelId label_id);
|
||
|
void CheckNotZeroOrJump(ValueId value_id, LabelId label_id);
|
||
|
|
||
9 years ago
|
// C++ callback.
|
||
|
ValueId Call(FunctionCallback callback, ValueId arg);
|
||
|
|
||
9 years ago
|
// Assemble the code.
|
||
|
MaybeHandle<Code> Build();
|
||
|
|
||
|
private:
|
||
9 years ago
|
ValueId FromRaw(compiler::Node* node);
|
||
|
LabelId FromRaw(compiler::CodeStubAssembler::Label* label);
|
||
|
compiler::Node* FromId(ValueId value) const;
|
||
|
compiler::CodeStubAssembler::Label* FromId(LabelId value) const;
|
||
9 years ago
|
|
||
9 years ago
|
void Clear();
|
||
9 years ago
|
Zone* zone() { return &zone_; }
|
||
9 years ago
|
Isolate* isolate() const { return isolate_; }
|
||
9 years ago
|
|
||
|
Zone zone_;
|
||
9 years ago
|
Isolate* isolate_;
|
||
|
base::SmartPointer<compiler::CodeStubAssembler> assembler_;
|
||
9 years ago
|
|
||
|
// To prevent exposing the RMA internals to the outside world, we'll map
|
||
|
// Node + Label pointers integers wrapped in ValueId and LabelId instances.
|
||
|
// These vectors maintain this mapping.
|
||
9 years ago
|
std::vector<compiler::Node*> nodes_;
|
||
|
std::vector<compiler::CodeStubAssembler::Label*> labels_;
|
||
9 years ago
|
|
||
|
// Remember the current state for easy error checking. (We prefer to be
|
||
|
// strict as this class will be exposed at the API.)
|
||
|
enum { kBuilding, kBuilt, kError } state_;
|
||
|
|
||
|
DISALLOW_COPY_AND_ASSIGN(FastAccessorAssembler);
|
||
|
};
|
||
|
|
||
|
} // namespace internal
|
||
|
} // namespace v8
|
||
|
|
||
9 years ago
|
#endif // V8_FAST_ACCESSOR_ASSEMBLER_H_
|