2016-04-18 11:57:06 +00:00
|
|
|
// Copyright 2016 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_CODE_STUB_ASSEMBLER_H_
|
|
|
|
#define V8_CODE_STUB_ASSEMBLER_H_
|
|
|
|
|
2016-06-30 16:38:22 +00:00
|
|
|
#include <functional>
|
|
|
|
|
2016-04-18 11:57:06 +00:00
|
|
|
#include "src/compiler/code-assembler.h"
|
|
|
|
#include "src/objects.h"
|
|
|
|
|
|
|
|
namespace v8 {
|
|
|
|
namespace internal {
|
|
|
|
|
|
|
|
class CallInterfaceDescriptor;
|
2016-06-06 14:26:28 +00:00
|
|
|
class StatsCounter;
|
|
|
|
class StubCache;
|
2016-04-18 11:57:06 +00:00
|
|
|
|
2016-07-05 10:03:38 +00:00
|
|
|
enum class PrimitiveType { kBoolean, kNumber, kString, kSymbol };
|
|
|
|
|
2016-04-18 11:57:06 +00:00
|
|
|
// Provides JavaScript-specific "macro-assembler" functionality on top of the
|
|
|
|
// CodeAssembler. By factoring the JavaScript-isms out of the CodeAssembler,
|
|
|
|
// it's possible to add JavaScript-specific useful CodeAssembler "macros"
|
|
|
|
// without modifying files in the compiler directory (and requiring a review
|
|
|
|
// from a compiler directory OWNER).
|
|
|
|
class CodeStubAssembler : public compiler::CodeAssembler {
|
|
|
|
public:
|
|
|
|
// Create with CallStub linkage.
|
|
|
|
// |result_size| specifies the number of results returned by the stub.
|
|
|
|
// TODO(rmcilroy): move result_size to the CallInterfaceDescriptor.
|
|
|
|
CodeStubAssembler(Isolate* isolate, Zone* zone,
|
|
|
|
const CallInterfaceDescriptor& descriptor,
|
|
|
|
Code::Flags flags, const char* name,
|
|
|
|
size_t result_size = 1);
|
|
|
|
|
|
|
|
// Create with JSCall linkage.
|
|
|
|
CodeStubAssembler(Isolate* isolate, Zone* zone, int parameter_count,
|
|
|
|
Code::Flags flags, const char* name);
|
|
|
|
|
2016-05-19 15:49:03 +00:00
|
|
|
enum ParameterMode { INTEGER_PARAMETERS, SMI_PARAMETERS };
|
|
|
|
|
2016-04-21 06:45:44 +00:00
|
|
|
compiler::Node* BooleanMapConstant();
|
|
|
|
compiler::Node* EmptyStringConstant();
|
|
|
|
compiler::Node* HeapNumberMapConstant();
|
|
|
|
compiler::Node* NoContextConstant();
|
2016-07-11 05:27:14 +00:00
|
|
|
compiler::Node* NanConstant();
|
2016-04-21 06:45:44 +00:00
|
|
|
compiler::Node* NullConstant();
|
2016-07-14 08:53:06 +00:00
|
|
|
compiler::Node* MinusZeroConstant();
|
2016-04-21 06:45:44 +00:00
|
|
|
compiler::Node* UndefinedConstant();
|
2016-06-02 15:02:08 +00:00
|
|
|
compiler::Node* TheHoleConstant();
|
|
|
|
compiler::Node* HashSeed();
|
2016-04-28 14:54:39 +00:00
|
|
|
compiler::Node* StaleRegisterConstant();
|
2016-04-21 06:45:44 +00:00
|
|
|
|
2016-04-18 11:57:06 +00:00
|
|
|
// Float64 operations.
|
|
|
|
compiler::Node* Float64Ceil(compiler::Node* x);
|
|
|
|
compiler::Node* Float64Floor(compiler::Node* x);
|
|
|
|
compiler::Node* Float64Round(compiler::Node* x);
|
|
|
|
compiler::Node* Float64Trunc(compiler::Node* x);
|
|
|
|
|
2016-04-21 06:45:44 +00:00
|
|
|
// Tag a Word as a Smi value.
|
|
|
|
compiler::Node* SmiTag(compiler::Node* value);
|
|
|
|
// Untag a Smi value as a Word.
|
|
|
|
compiler::Node* SmiUntag(compiler::Node* value);
|
|
|
|
|
2016-04-18 11:57:06 +00:00
|
|
|
// Smi conversions.
|
|
|
|
compiler::Node* SmiToFloat64(compiler::Node* value);
|
2016-05-31 11:37:26 +00:00
|
|
|
compiler::Node* SmiFromWord(compiler::Node* value) { return SmiTag(value); }
|
2016-04-18 11:57:06 +00:00
|
|
|
compiler::Node* SmiFromWord32(compiler::Node* value);
|
|
|
|
compiler::Node* SmiToWord(compiler::Node* value) { return SmiUntag(value); }
|
|
|
|
compiler::Node* SmiToWord32(compiler::Node* value);
|
|
|
|
|
|
|
|
// Smi operations.
|
|
|
|
compiler::Node* SmiAdd(compiler::Node* a, compiler::Node* b);
|
|
|
|
compiler::Node* SmiAddWithOverflow(compiler::Node* a, compiler::Node* b);
|
|
|
|
compiler::Node* SmiSub(compiler::Node* a, compiler::Node* b);
|
|
|
|
compiler::Node* SmiSubWithOverflow(compiler::Node* a, compiler::Node* b);
|
|
|
|
compiler::Node* SmiEqual(compiler::Node* a, compiler::Node* b);
|
|
|
|
compiler::Node* SmiAboveOrEqual(compiler::Node* a, compiler::Node* b);
|
|
|
|
compiler::Node* SmiLessThan(compiler::Node* a, compiler::Node* b);
|
|
|
|
compiler::Node* SmiLessThanOrEqual(compiler::Node* a, compiler::Node* b);
|
|
|
|
compiler::Node* SmiMin(compiler::Node* a, compiler::Node* b);
|
2016-07-11 05:27:14 +00:00
|
|
|
// Computes a % b for Smi inputs a and b; result is not necessarily a Smi.
|
|
|
|
compiler::Node* SmiMod(compiler::Node* a, compiler::Node* b);
|
2016-07-14 13:21:55 +00:00
|
|
|
// Computes a * b for Smi inputs a and b; result is not necessarily a Smi.
|
|
|
|
compiler::Node* SmiMul(compiler::Node* a, compiler::Node* b);
|
2016-04-18 11:57:06 +00:00
|
|
|
|
2016-04-21 06:45:44 +00:00
|
|
|
// Allocate an object of the given size.
|
2016-04-22 09:17:58 +00:00
|
|
|
compiler::Node* Allocate(compiler::Node* size, AllocationFlags flags = kNone);
|
2016-04-21 06:45:44 +00:00
|
|
|
compiler::Node* Allocate(int size, AllocationFlags flags = kNone);
|
|
|
|
compiler::Node* InnerAllocate(compiler::Node* previous, int offset);
|
2016-04-29 14:19:22 +00:00
|
|
|
compiler::Node* InnerAllocate(compiler::Node* previous,
|
|
|
|
compiler::Node* offset);
|
2016-04-21 06:45:44 +00:00
|
|
|
|
2016-05-19 09:46:34 +00:00
|
|
|
void Assert(compiler::Node* condition);
|
|
|
|
|
2016-04-18 11:57:06 +00:00
|
|
|
// Check a value for smi-ness
|
|
|
|
compiler::Node* WordIsSmi(compiler::Node* a);
|
|
|
|
// Check that the value is a positive smi.
|
|
|
|
compiler::Node* WordIsPositiveSmi(compiler::Node* a);
|
|
|
|
|
2016-07-19 06:13:34 +00:00
|
|
|
void BranchIfSmiEqual(compiler::Node* a, compiler::Node* b, Label* if_true,
|
|
|
|
Label* if_false) {
|
|
|
|
BranchIf(SmiEqual(a, b), if_true, if_false);
|
|
|
|
}
|
|
|
|
|
2016-04-18 11:57:06 +00:00
|
|
|
void BranchIfSmiLessThan(compiler::Node* a, compiler::Node* b, Label* if_true,
|
|
|
|
Label* if_false) {
|
|
|
|
BranchIf(SmiLessThan(a, b), if_true, if_false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BranchIfSmiLessThanOrEqual(compiler::Node* a, compiler::Node* b,
|
|
|
|
Label* if_true, Label* if_false) {
|
|
|
|
BranchIf(SmiLessThanOrEqual(a, b), if_true, if_false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BranchIfFloat64IsNaN(compiler::Node* value, Label* if_true,
|
|
|
|
Label* if_false) {
|
|
|
|
BranchIfFloat64Equal(value, value, if_false, if_true);
|
|
|
|
}
|
|
|
|
|
2016-07-19 06:13:34 +00:00
|
|
|
// Branches to {if_true} if ToBoolean applied to {value} yields true,
|
|
|
|
// otherwise goes to {if_false}.
|
|
|
|
void BranchIfToBooleanIsTrue(compiler::Node* value, Label* if_true,
|
|
|
|
Label* if_false);
|
|
|
|
|
2016-06-06 14:26:28 +00:00
|
|
|
// Load value from current frame by given offset in bytes.
|
|
|
|
compiler::Node* LoadFromFrame(int offset,
|
|
|
|
MachineType rep = MachineType::AnyTagged());
|
|
|
|
// Load value from current parent frame by given offset in bytes.
|
|
|
|
compiler::Node* LoadFromParentFrame(
|
|
|
|
int offset, MachineType rep = MachineType::AnyTagged());
|
|
|
|
|
2016-04-18 11:57:06 +00:00
|
|
|
// Load an object pointer from a buffer that isn't in the heap.
|
|
|
|
compiler::Node* LoadBufferObject(compiler::Node* buffer, int offset,
|
|
|
|
MachineType rep = MachineType::AnyTagged());
|
|
|
|
// Load a field from an object on the heap.
|
|
|
|
compiler::Node* LoadObjectField(compiler::Node* object, int offset,
|
|
|
|
MachineType rep = MachineType::AnyTagged());
|
2016-06-27 12:26:57 +00:00
|
|
|
compiler::Node* LoadObjectField(compiler::Node* object,
|
|
|
|
compiler::Node* offset,
|
|
|
|
MachineType rep = MachineType::AnyTagged());
|
|
|
|
|
2016-04-18 11:57:06 +00:00
|
|
|
// Load the floating point value of a HeapNumber.
|
|
|
|
compiler::Node* LoadHeapNumberValue(compiler::Node* object);
|
|
|
|
// Load the Map of an HeapObject.
|
|
|
|
compiler::Node* LoadMap(compiler::Node* object);
|
|
|
|
// Load the instance type of an HeapObject.
|
|
|
|
compiler::Node* LoadInstanceType(compiler::Node* object);
|
2016-06-15 12:34:57 +00:00
|
|
|
// Checks that given heap object has given instance type.
|
|
|
|
void AssertInstanceType(compiler::Node* object, InstanceType instance_type);
|
2016-06-02 15:02:08 +00:00
|
|
|
// Load the properties backing store of a JSObject.
|
|
|
|
compiler::Node* LoadProperties(compiler::Node* object);
|
2016-04-18 11:57:06 +00:00
|
|
|
// Load the elements backing store of a JSObject.
|
|
|
|
compiler::Node* LoadElements(compiler::Node* object);
|
|
|
|
// Load the length of a fixed array base instance.
|
|
|
|
compiler::Node* LoadFixedArrayBaseLength(compiler::Node* array);
|
|
|
|
// Load the bit field of a Map.
|
|
|
|
compiler::Node* LoadMapBitField(compiler::Node* map);
|
|
|
|
// Load bit field 2 of a map.
|
|
|
|
compiler::Node* LoadMapBitField2(compiler::Node* map);
|
|
|
|
// Load bit field 3 of a map.
|
|
|
|
compiler::Node* LoadMapBitField3(compiler::Node* map);
|
|
|
|
// Load the instance type of a map.
|
|
|
|
compiler::Node* LoadMapInstanceType(compiler::Node* map);
|
|
|
|
// Load the instance descriptors of a map.
|
|
|
|
compiler::Node* LoadMapDescriptors(compiler::Node* map);
|
2016-05-03 11:11:27 +00:00
|
|
|
// Load the prototype of a map.
|
|
|
|
compiler::Node* LoadMapPrototype(compiler::Node* map);
|
2016-06-01 21:08:22 +00:00
|
|
|
// Load the instance size of a Map.
|
|
|
|
compiler::Node* LoadMapInstanceSize(compiler::Node* map);
|
2016-06-27 12:26:57 +00:00
|
|
|
// Load the inobject properties count of a Map (valid only for JSObjects).
|
|
|
|
compiler::Node* LoadMapInobjectProperties(compiler::Node* map);
|
2016-07-11 11:45:26 +00:00
|
|
|
// Load the constructor of a Map (equivalent to Map::GetConstructor()).
|
|
|
|
compiler::Node* LoadMapConstructor(compiler::Node* map);
|
2016-06-01 19:58:46 +00:00
|
|
|
|
2016-06-02 15:02:08 +00:00
|
|
|
// Load the hash field of a name.
|
|
|
|
compiler::Node* LoadNameHashField(compiler::Node* name);
|
|
|
|
// Load the hash value of a name. If {if_hash_not_computed} label
|
|
|
|
// is specified then it also checks if hash is actually computed.
|
|
|
|
compiler::Node* LoadNameHash(compiler::Node* name,
|
|
|
|
Label* if_hash_not_computed = nullptr);
|
|
|
|
|
|
|
|
// Load length field of a String object.
|
|
|
|
compiler::Node* LoadStringLength(compiler::Node* object);
|
|
|
|
// Load value field of a JSValue object.
|
|
|
|
compiler::Node* LoadJSValueValue(compiler::Node* object);
|
2016-06-06 14:26:28 +00:00
|
|
|
// Load value field of a WeakCell object.
|
2016-06-15 12:34:57 +00:00
|
|
|
compiler::Node* LoadWeakCellValue(compiler::Node* weak_cell,
|
|
|
|
Label* if_cleared = nullptr);
|
2016-06-02 15:02:08 +00:00
|
|
|
|
2016-04-22 09:17:58 +00:00
|
|
|
compiler::Node* AllocateUninitializedFixedArray(compiler::Node* length);
|
|
|
|
|
2016-04-18 11:57:06 +00:00
|
|
|
// Load an array element from a FixedArray.
|
2016-05-19 15:49:03 +00:00
|
|
|
compiler::Node* LoadFixedArrayElement(
|
|
|
|
compiler::Node* object, compiler::Node* int32_index,
|
|
|
|
int additional_offset = 0,
|
|
|
|
ParameterMode parameter_mode = INTEGER_PARAMETERS);
|
2016-06-02 15:02:08 +00:00
|
|
|
// Load an array element from a FixedDoubleArray.
|
|
|
|
compiler::Node* LoadFixedDoubleArrayElement(
|
|
|
|
compiler::Node* object, compiler::Node* int32_index,
|
|
|
|
MachineType machine_type, int additional_offset = 0,
|
|
|
|
ParameterMode parameter_mode = INTEGER_PARAMETERS);
|
2016-04-18 11:57:06 +00:00
|
|
|
|
2016-05-03 07:58:58 +00:00
|
|
|
// Context manipulation
|
|
|
|
compiler::Node* LoadNativeContext(compiler::Node* context);
|
|
|
|
|
2016-05-03 21:34:19 +00:00
|
|
|
compiler::Node* LoadJSArrayElementsMap(ElementsKind kind,
|
|
|
|
compiler::Node* native_context);
|
|
|
|
|
2016-04-18 11:57:06 +00:00
|
|
|
// Store the floating point value of a HeapNumber.
|
|
|
|
compiler::Node* StoreHeapNumberValue(compiler::Node* object,
|
|
|
|
compiler::Node* value);
|
|
|
|
// Store a field to an object on the heap.
|
2016-04-22 09:17:58 +00:00
|
|
|
compiler::Node* StoreObjectField(
|
|
|
|
compiler::Node* object, int offset, compiler::Node* value);
|
2016-04-18 11:57:06 +00:00
|
|
|
compiler::Node* StoreObjectFieldNoWriteBarrier(
|
|
|
|
compiler::Node* object, int offset, compiler::Node* value,
|
|
|
|
MachineRepresentation rep = MachineRepresentation::kTagged);
|
|
|
|
// Store the Map of an HeapObject.
|
|
|
|
compiler::Node* StoreMapNoWriteBarrier(compiler::Node* object,
|
|
|
|
compiler::Node* map);
|
|
|
|
// Store an array element to a FixedArray.
|
2016-05-19 15:49:03 +00:00
|
|
|
compiler::Node* StoreFixedArrayElement(
|
|
|
|
compiler::Node* object, compiler::Node* index, compiler::Node* value,
|
|
|
|
WriteBarrierMode barrier_mode = UPDATE_WRITE_BARRIER,
|
|
|
|
ParameterMode parameter_mode = INTEGER_PARAMETERS);
|
|
|
|
|
|
|
|
compiler::Node* StoreFixedDoubleArrayElement(
|
|
|
|
compiler::Node* object, compiler::Node* index, compiler::Node* value,
|
|
|
|
ParameterMode parameter_mode = INTEGER_PARAMETERS);
|
2016-04-18 11:57:06 +00:00
|
|
|
|
|
|
|
// Allocate a HeapNumber without initializing its value.
|
|
|
|
compiler::Node* AllocateHeapNumber();
|
|
|
|
// Allocate a HeapNumber with a specific value.
|
|
|
|
compiler::Node* AllocateHeapNumberWithValue(compiler::Node* value);
|
|
|
|
// Allocate a SeqOneByteString with the given length.
|
|
|
|
compiler::Node* AllocateSeqOneByteString(int length);
|
2016-05-31 11:37:26 +00:00
|
|
|
compiler::Node* AllocateSeqOneByteString(compiler::Node* context,
|
|
|
|
compiler::Node* length);
|
2016-04-18 11:57:06 +00:00
|
|
|
// Allocate a SeqTwoByteString with the given length.
|
|
|
|
compiler::Node* AllocateSeqTwoByteString(int length);
|
2016-05-31 11:37:26 +00:00
|
|
|
compiler::Node* AllocateSeqTwoByteString(compiler::Node* context,
|
|
|
|
compiler::Node* length);
|
2016-05-03 07:58:58 +00:00
|
|
|
// Allocated an JSArray
|
2016-05-03 21:34:19 +00:00
|
|
|
compiler::Node* AllocateJSArray(ElementsKind kind, compiler::Node* array_map,
|
2016-05-19 15:49:03 +00:00
|
|
|
compiler::Node* capacity,
|
|
|
|
compiler::Node* length,
|
|
|
|
compiler::Node* allocation_site = nullptr,
|
|
|
|
ParameterMode mode = INTEGER_PARAMETERS);
|
2016-05-03 07:58:58 +00:00
|
|
|
|
|
|
|
// Allocation site manipulation
|
|
|
|
void InitializeAllocationMemento(compiler::Node* base_allocation,
|
|
|
|
int base_allocation_size,
|
|
|
|
compiler::Node* allocation_site);
|
2016-04-18 11:57:06 +00:00
|
|
|
|
|
|
|
compiler::Node* TruncateTaggedToFloat64(compiler::Node* context,
|
|
|
|
compiler::Node* value);
|
|
|
|
compiler::Node* TruncateTaggedToWord32(compiler::Node* context,
|
|
|
|
compiler::Node* value);
|
|
|
|
// Truncate the floating point value of a HeapNumber to an Int32.
|
|
|
|
compiler::Node* TruncateHeapNumberValueToWord32(compiler::Node* object);
|
|
|
|
|
|
|
|
// Conversions.
|
|
|
|
compiler::Node* ChangeFloat64ToTagged(compiler::Node* value);
|
|
|
|
compiler::Node* ChangeInt32ToTagged(compiler::Node* value);
|
|
|
|
compiler::Node* ChangeUint32ToTagged(compiler::Node* value);
|
|
|
|
|
|
|
|
// Type conversions.
|
|
|
|
// Throws a TypeError for {method_name} if {value} is not coercible to Object,
|
|
|
|
// or returns the {value} converted to a String otherwise.
|
|
|
|
compiler::Node* ToThisString(compiler::Node* context, compiler::Node* value,
|
|
|
|
char const* method_name);
|
2016-07-05 10:03:38 +00:00
|
|
|
// Throws a TypeError for {method_name} if {value} is neither of the given
|
|
|
|
// {primitive_type} nor a JSValue wrapping a value of {primitive_type}, or
|
|
|
|
// returns the {value} (or wrapped value) otherwise.
|
|
|
|
compiler::Node* ToThisValue(compiler::Node* context, compiler::Node* value,
|
|
|
|
PrimitiveType primitive_type,
|
|
|
|
char const* method_name);
|
2016-04-18 11:57:06 +00:00
|
|
|
|
|
|
|
// String helpers.
|
|
|
|
// Load a character from a String (might flatten a ConsString).
|
|
|
|
compiler::Node* StringCharCodeAt(compiler::Node* string,
|
|
|
|
compiler::Node* smi_index);
|
|
|
|
// Return the single character string with only {code}.
|
|
|
|
compiler::Node* StringFromCharCode(compiler::Node* code);
|
|
|
|
|
|
|
|
// Returns a node that is true if the given bit is set in |word32|.
|
|
|
|
template <typename T>
|
|
|
|
compiler::Node* BitFieldDecode(compiler::Node* word32) {
|
|
|
|
return BitFieldDecode(word32, T::kShift, T::kMask);
|
|
|
|
}
|
|
|
|
|
|
|
|
compiler::Node* BitFieldDecode(compiler::Node* word32, uint32_t shift,
|
|
|
|
uint32_t mask);
|
2016-04-21 06:45:44 +00:00
|
|
|
|
2016-06-07 15:04:19 +00:00
|
|
|
void SetCounter(StatsCounter* counter, int value);
|
|
|
|
void IncrementCounter(StatsCounter* counter, int delta);
|
|
|
|
void DecrementCounter(StatsCounter* counter, int delta);
|
|
|
|
|
2016-06-30 16:38:22 +00:00
|
|
|
// Generates "if (false) goto label" code. Useful for marking a label as
|
|
|
|
// "live" to avoid assertion failures during graph building. In the resulting
|
|
|
|
// code this check will be eliminated.
|
|
|
|
void Use(Label* label);
|
|
|
|
|
2016-05-03 11:11:27 +00:00
|
|
|
// Various building blocks for stubs doing property lookups.
|
|
|
|
void TryToName(compiler::Node* key, Label* if_keyisindex, Variable* var_index,
|
2016-06-02 15:02:08 +00:00
|
|
|
Label* if_keyisunique, Label* if_bailout);
|
|
|
|
|
2016-06-27 12:26:57 +00:00
|
|
|
// Calculates array index for given dictionary entry and entry field.
|
|
|
|
// See Dictionary::EntryToIndex().
|
|
|
|
template <typename Dictionary>
|
|
|
|
compiler::Node* EntryToIndex(compiler::Node* entry, int field_index);
|
|
|
|
template <typename Dictionary>
|
|
|
|
compiler::Node* EntryToIndex(compiler::Node* entry) {
|
|
|
|
return EntryToIndex<Dictionary>(entry, Dictionary::kEntryKeyIndex);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Looks up an entry in a NameDictionaryBase successor. If the entry is found
|
|
|
|
// control goes to {if_found} and {var_name_index} contains an index of the
|
|
|
|
// key field of the entry found. If the key is not found control goes to
|
|
|
|
// {if_not_found}.
|
2016-06-02 15:02:08 +00:00
|
|
|
static const int kInlinedDictionaryProbes = 4;
|
|
|
|
template <typename Dictionary>
|
|
|
|
void NameDictionaryLookup(compiler::Node* dictionary,
|
|
|
|
compiler::Node* unique_name, Label* if_found,
|
2016-06-27 12:26:57 +00:00
|
|
|
Variable* var_name_index, Label* if_not_found,
|
2016-06-02 15:02:08 +00:00
|
|
|
int inlined_probes = kInlinedDictionaryProbes);
|
|
|
|
|
|
|
|
compiler::Node* ComputeIntegerHash(compiler::Node* key, compiler::Node* seed);
|
|
|
|
|
|
|
|
template <typename Dictionary>
|
|
|
|
void NumberDictionaryLookup(compiler::Node* dictionary, compiler::Node* key,
|
|
|
|
Label* if_found, Variable* var_entry,
|
|
|
|
Label* if_not_found);
|
2016-05-03 11:11:27 +00:00
|
|
|
|
2016-06-27 12:26:57 +00:00
|
|
|
// Tries to check if {object} has own {unique_name} property.
|
|
|
|
void TryHasOwnProperty(compiler::Node* object, compiler::Node* map,
|
2016-06-02 15:02:08 +00:00
|
|
|
compiler::Node* instance_type,
|
|
|
|
compiler::Node* unique_name, Label* if_found,
|
|
|
|
Label* if_not_found, Label* if_bailout);
|
2016-05-03 11:11:27 +00:00
|
|
|
|
2016-06-27 12:26:57 +00:00
|
|
|
// Tries to get {object}'s own {unique_name} property value. If the property
|
|
|
|
// is an accessor then it also calls a getter. If the property is a double
|
|
|
|
// field it re-wraps value in an immutable heap number.
|
|
|
|
void TryGetOwnProperty(compiler::Node* context, compiler::Node* receiver,
|
|
|
|
compiler::Node* object, compiler::Node* map,
|
|
|
|
compiler::Node* instance_type,
|
|
|
|
compiler::Node* unique_name, Label* if_found,
|
|
|
|
Variable* var_value, Label* if_not_found,
|
|
|
|
Label* if_bailout);
|
|
|
|
|
|
|
|
void LoadPropertyFromFastObject(compiler::Node* object, compiler::Node* map,
|
|
|
|
compiler::Node* descriptors,
|
|
|
|
compiler::Node* name_index,
|
|
|
|
Variable* var_details, Variable* var_value);
|
|
|
|
|
|
|
|
void LoadPropertyFromNameDictionary(compiler::Node* dictionary,
|
|
|
|
compiler::Node* entry,
|
|
|
|
Variable* var_details,
|
|
|
|
Variable* var_value);
|
|
|
|
|
|
|
|
void LoadPropertyFromGlobalDictionary(compiler::Node* dictionary,
|
|
|
|
compiler::Node* entry,
|
|
|
|
Variable* var_details,
|
|
|
|
Variable* var_value, Label* if_deleted);
|
|
|
|
|
|
|
|
// Generic property lookup generator. If the {object} is fast and
|
|
|
|
// {unique_name} property is found then the control goes to {if_found_fast}
|
|
|
|
// label and {var_meta_storage} and {var_name_index} will contain
|
|
|
|
// DescriptorArray and an index of the descriptor's name respectively.
|
|
|
|
// If the {object} is slow or global then the control goes to {if_found_dict}
|
|
|
|
// or {if_found_global} and the {var_meta_storage} and {var_name_index} will
|
|
|
|
// contain a dictionary and an index of the key field of the found entry.
|
|
|
|
// If property is not found or given lookup is not supported then
|
|
|
|
// the control goes to {if_not_found} or {if_bailout} respectively.
|
|
|
|
//
|
|
|
|
// Note: this code does not check if the global dictionary points to deleted
|
|
|
|
// entry! This has to be done by the caller.
|
|
|
|
void TryLookupProperty(compiler::Node* object, compiler::Node* map,
|
|
|
|
compiler::Node* instance_type,
|
|
|
|
compiler::Node* unique_name, Label* if_found_fast,
|
|
|
|
Label* if_found_dict, Label* if_found_global,
|
|
|
|
Variable* var_meta_storage, Variable* var_name_index,
|
|
|
|
Label* if_not_found, Label* if_bailout);
|
|
|
|
|
2016-05-03 11:11:27 +00:00
|
|
|
void TryLookupElement(compiler::Node* object, compiler::Node* map,
|
|
|
|
compiler::Node* instance_type, compiler::Node* index,
|
|
|
|
Label* if_found, Label* if_not_found,
|
2016-06-02 15:02:08 +00:00
|
|
|
Label* if_bailout);
|
2016-05-03 11:11:27 +00:00
|
|
|
|
2016-06-30 16:38:22 +00:00
|
|
|
// This is a type of a lookup in holder generator function. In case of a
|
|
|
|
// property lookup the {key} is guaranteed to be a unique name and in case of
|
|
|
|
// element lookup the key is an Int32 index.
|
|
|
|
typedef std::function<void(compiler::Node* receiver, compiler::Node* holder,
|
|
|
|
compiler::Node* map, compiler::Node* instance_type,
|
|
|
|
compiler::Node* key, Label* next_holder,
|
|
|
|
Label* if_bailout)>
|
|
|
|
LookupInHolder;
|
|
|
|
|
|
|
|
// Generic property prototype chain lookup generator.
|
|
|
|
// For properties it generates lookup using given {lookup_property_in_holder}
|
|
|
|
// and for elements it uses {lookup_element_in_holder}.
|
|
|
|
// Upon reaching the end of prototype chain the control goes to {if_end}.
|
|
|
|
// If it can't handle the case {receiver}/{key} case then the control goes
|
|
|
|
// to {if_bailout}.
|
|
|
|
void TryPrototypeChainLookup(compiler::Node* receiver, compiler::Node* key,
|
|
|
|
LookupInHolder& lookup_property_in_holder,
|
|
|
|
LookupInHolder& lookup_element_in_holder,
|
|
|
|
Label* if_end, Label* if_bailout);
|
|
|
|
|
2016-05-17 11:23:59 +00:00
|
|
|
// Instanceof helpers.
|
|
|
|
// ES6 section 7.3.19 OrdinaryHasInstance (C, O)
|
|
|
|
compiler::Node* OrdinaryHasInstance(compiler::Node* context,
|
|
|
|
compiler::Node* callable,
|
|
|
|
compiler::Node* object);
|
|
|
|
|
2016-06-06 14:26:28 +00:00
|
|
|
// LoadIC helpers.
|
|
|
|
struct LoadICParameters {
|
|
|
|
LoadICParameters(compiler::Node* context, compiler::Node* receiver,
|
|
|
|
compiler::Node* name, compiler::Node* slot,
|
|
|
|
compiler::Node* vector)
|
|
|
|
: context(context),
|
|
|
|
receiver(receiver),
|
|
|
|
name(name),
|
|
|
|
slot(slot),
|
|
|
|
vector(vector) {}
|
|
|
|
|
|
|
|
compiler::Node* context;
|
|
|
|
compiler::Node* receiver;
|
|
|
|
compiler::Node* name;
|
|
|
|
compiler::Node* slot;
|
|
|
|
compiler::Node* vector;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Load type feedback vector from the stub caller's frame.
|
|
|
|
compiler::Node* LoadTypeFeedbackVectorForStub();
|
|
|
|
|
|
|
|
compiler::Node* LoadReceiverMap(compiler::Node* receiver);
|
|
|
|
|
|
|
|
// Checks monomorphic case. Returns {feedback} entry of the vector.
|
|
|
|
compiler::Node* TryMonomorphicCase(const LoadICParameters* p,
|
|
|
|
compiler::Node* receiver_map,
|
|
|
|
Label* if_handler, Variable* var_handler,
|
|
|
|
Label* if_miss);
|
|
|
|
void HandlePolymorphicCase(const LoadICParameters* p,
|
|
|
|
compiler::Node* receiver_map,
|
|
|
|
compiler::Node* feedback, Label* if_handler,
|
|
|
|
Variable* var_handler, Label* if_miss,
|
|
|
|
int unroll_count);
|
|
|
|
|
|
|
|
compiler::Node* StubCachePrimaryOffset(compiler::Node* name,
|
|
|
|
compiler::Node* map);
|
|
|
|
|
|
|
|
compiler::Node* StubCacheSecondaryOffset(compiler::Node* name,
|
|
|
|
compiler::Node* seed);
|
|
|
|
|
|
|
|
// This enum is used here as a replacement for StubCache::Table to avoid
|
|
|
|
// including stub cache header.
|
|
|
|
enum StubCacheTable : int;
|
|
|
|
|
|
|
|
void TryProbeStubCacheTable(StubCache* stub_cache, StubCacheTable table_id,
|
|
|
|
compiler::Node* entry_offset,
|
2016-07-21 12:57:26 +00:00
|
|
|
compiler::Node* name, compiler::Node* map,
|
|
|
|
Label* if_handler, Variable* var_handler,
|
|
|
|
Label* if_miss);
|
2016-06-06 14:26:28 +00:00
|
|
|
|
2016-07-13 10:24:55 +00:00
|
|
|
void TryProbeStubCache(StubCache* stub_cache, compiler::Node* receiver,
|
|
|
|
compiler::Node* name, Label* if_handler,
|
|
|
|
Variable* var_handler, Label* if_miss);
|
2016-06-06 14:26:28 +00:00
|
|
|
|
2016-06-15 12:34:57 +00:00
|
|
|
void LoadIC(const LoadICParameters* p);
|
|
|
|
void LoadGlobalIC(const LoadICParameters* p);
|
2016-06-06 14:26:28 +00:00
|
|
|
|
2016-07-19 14:46:25 +00:00
|
|
|
// Get the enumerable length from |map| and return the result as a Smi.
|
|
|
|
compiler::Node* EnumLength(compiler::Node* map);
|
|
|
|
|
|
|
|
// Check the cache validity for |receiver|. Branch to |use_cache| if
|
|
|
|
// the cache is valid, otherwise branch to |use_runtime|.
|
|
|
|
void CheckEnumCache(compiler::Node* receiver,
|
|
|
|
CodeStubAssembler::Label* use_cache,
|
|
|
|
CodeStubAssembler::Label* use_runtime);
|
|
|
|
|
2016-04-21 06:45:44 +00:00
|
|
|
private:
|
2016-05-19 15:49:03 +00:00
|
|
|
compiler::Node* ElementOffsetFromIndex(compiler::Node* index,
|
|
|
|
ElementsKind kind, ParameterMode mode,
|
|
|
|
int base_size = 0);
|
|
|
|
|
2016-04-21 06:45:44 +00:00
|
|
|
compiler::Node* AllocateRawAligned(compiler::Node* size_in_bytes,
|
|
|
|
AllocationFlags flags,
|
|
|
|
compiler::Node* top_address,
|
|
|
|
compiler::Node* limit_address);
|
|
|
|
compiler::Node* AllocateRawUnaligned(compiler::Node* size_in_bytes,
|
|
|
|
AllocationFlags flags,
|
|
|
|
compiler::Node* top_adddress,
|
|
|
|
compiler::Node* limit_address);
|
2016-05-03 07:58:58 +00:00
|
|
|
|
|
|
|
static const int kElementLoopUnrollThreshold = 8;
|
2016-04-18 11:57:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace internal
|
|
|
|
} // namespace v8
|
|
|
|
#endif // V8_CODE_STUB_ASSEMBLER_H_
|