49 }
else if (value->IsHeapNumber()) {
53 }
else if (value->IsString()) {
66 native_context_ = native_context;
69 BuildDictionary(code);
75 return static_cast<uint32_t
>(ast_id.
ToInt());
79 Handle<Object> TypeFeedbackOracle::GetInfo(TypeFeedbackId ast_id) {
80 int entry = dictionary_->FindEntry(IdToKey(ast_id));
89 if (map_or_code->IsMap())
return false;
90 if (map_or_code->IsCode()) {
92 return code->is_inline_cache_stub() && code->ic_state() ==
UNINITIALIZED;
100 if (map_or_code->IsMap())
return true;
101 if (map_or_code->IsCode()) {
103 bool preliminary_checks = code->is_keyed_load_stub() &&
106 if (!preliminary_checks)
return false;
107 Map* map = code->FindFirstMap();
116 if (map_or_code->IsCode()) {
119 return code->is_keyed_load_stub() &&
120 *code != builtins->
builtin(Builtins::kKeyedLoadIC_Generic) &&
129 if (map_or_code->IsMap())
return true;
130 if (map_or_code->IsCode()) {
135 bool preliminary_checks =
136 code->is_keyed_store_stub() &&
140 if (!preliminary_checks)
return false;
141 Map* map = code->FindFirstMap();
150 if (map_or_code->IsCode()) {
156 return code->is_keyed_store_stub() &&
158 *code != builtins->
builtin(Builtins::kKeyedStoreIC_Generic) &&
159 *code != builtins->
builtin(Builtins::kKeyedStoreIC_Generic_Strict) &&
168 return value->IsMap() || value->IsSmi() || value->IsJSFunction();
174 return value->IsJSFunction();
181 return map_or_code->IsMap();
187 return value->IsSmi() &&
195 if (map_or_code->IsCode()) {
197 Map* first_map = code->FindFirstMap();
211 if (map_or_code->IsCode()) {
213 Map* first_map = code->FindFirstMap();
278 function = native_context_->string_function();
281 function = native_context_->number_function();
284 function = native_context_->boolean_function();
318 if (!object->IsCode())
return unknown;
320 if (!code->is_compare_ic_stub())
return unknown;
347 if (!object->IsCode())
return false;
349 if (!code->is_compare_ic_stub())
return false;
364 Map* first_map = code->FindFirstMap();
375 if (!object->IsCode())
return unknown;
377 ASSERT(code->is_unary_op_stub());
379 code->unary_op_type());
394 if (!object->IsCode())
return unknown;
396 if (code->is_binary_op_stub()) {
398 code->binary_op_type());
400 code->binary_op_result_type());
407 switch (result_type) {
446 if (!object->IsCode())
return unknown;
448 if (!code->is_compare_ic_stub())
return unknown;
478 if (!object->IsCode())
return unknown;
480 if (!code->is_binary_op_stub())
return unknown;
483 code->binary_op_type());
504 void TypeFeedbackOracle::CollectReceiverTypes(
TypeFeedbackId ast_id,
509 if (object->IsUndefined() ||
object->IsSmi())
return;
516 }
else if (object->IsMap()) {
518 }
else if (FLAG_collect_megamorphic_maps_from_stub_cache &&
519 Handle<Code>::cast(
object)->ic_state() ==
MEGAMORPHIC) {
537 while (!map->prototype()->IsNull()) {
538 constructor = map->constructor();
539 if (!constructor->IsNull()) {
542 if (!constructor->IsJSFunction())
return true;
551 constructor = map->constructor();
552 if (constructor->IsNull())
return false;
560 return function->context()->global_object() != native_context->
global_object()
561 &&
function->context()->global_object() != native_context->
builtins();
567 for (
int i = 0; i < list->
length(); ++i) {
568 if (list->
at(i).is_identical_to(map))
return;
570 list->
Add(map, zone);
577 if (!object->IsCode())
return;
579 if (code->kind() == Code::KEYED_LOAD_IC ||
580 code->kind() == Code::KEYED_STORE_IC) {
582 int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT);
584 RelocInfo* info = it.rinfo();
585 Object*
object = info->target_object();
586 if (object->IsMap()) {
611 GetRelocInfos(code, &infos);
612 CreateDictionary(code, &infos);
613 ProcessRelocInfos(&infos);
614 ProcessTypeFeedbackCells(code);
620 void TypeFeedbackOracle::GetRelocInfos(
Handle<Code> code,
621 ZoneList<RelocInfo>* infos) {
622 int mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET_WITH_ID);
623 for (RelocIterator it(*code, mask); !it.done(); it.next()) {
624 infos->Add(*it.rinfo(),
zone());
629 void TypeFeedbackOracle::CreateDictionary(Handle<Code> code,
630 ZoneList<RelocInfo>* infos) {
631 DisableAssertNoAllocation allocation_allowed;
632 int cell_count = code->type_feedback_info()->IsTypeFeedbackInfo()
634 type_feedback_cells()->CellCount()
636 int length = infos->length() + cell_count;
637 byte* old_start = code->instruction_start();
638 dictionary_ =
FACTORY->NewUnseededNumberDictionary(length);
639 byte* new_start = code->instruction_start();
640 RelocateRelocInfos(infos, old_start, new_start);
644 void TypeFeedbackOracle::RelocateRelocInfos(ZoneList<RelocInfo>* infos,
647 for (
int i = 0; i < infos->length(); i++) {
648 RelocInfo* info = &(*infos)[i];
649 info->set_pc(new_start + (info->pc() - old_start));
654 void TypeFeedbackOracle::ProcessRelocInfos(ZoneList<RelocInfo>* infos) {
655 for (
int i = 0; i < infos->length(); i++) {
656 RelocInfo reloc_entry = (*infos)[i];
657 Address target_address = reloc_entry.target_address();
658 TypeFeedbackId ast_id =
659 TypeFeedbackId(static_cast<unsigned>((*infos)[i].data()));
661 switch (target->kind()) {
665 case Code::KEYED_CALL_IC:
667 if (target->kind() == Code::CALL_IC &&
671 Object* map = target->FindFirstMap();
673 SetInfo(ast_id, static_cast<Object*>(target));
676 SetInfo(ast_id, map);
680 SetInfo(ast_id, target);
684 case Code::KEYED_LOAD_IC:
685 case Code::KEYED_STORE_IC:
688 SetInfo(ast_id, target);
692 case Code::UNARY_OP_IC:
693 case Code::BINARY_OP_IC:
694 case Code::COMPARE_IC:
695 case Code::TO_BOOLEAN_IC:
696 SetInfo(ast_id, target);
706 void TypeFeedbackOracle::ProcessTypeFeedbackCells(Handle<Code> code) {
707 Object* raw_info = code->type_feedback_info();
708 if (!raw_info->IsTypeFeedbackInfo())
return;
709 Handle<TypeFeedbackCells> cache(
711 for (
int i = 0; i < cache->CellCount(); i++) {
712 TypeFeedbackId ast_id = cache->AstId(i);
713 Object* value = cache->Cell(i)->value();
714 if (value->IsSmi() ||
715 (value->IsJSFunction() &&
717 *native_context_))) {
718 SetInfo(ast_id, value);
724 void TypeFeedbackOracle::SetInfo(TypeFeedbackId ast_id,
Object* target) {
725 ASSERT(dictionary_->FindEntry(IdToKey(ast_id)) ==
727 MaybeObject* maybe_result = dictionary_->AtNumberPut(IdToKey(ast_id), target);
732 ASSERT(maybe_result->ToObject(&result));
733 ASSERT(*dictionary_ == result);
Handle< JSFunction > GetCallNewTarget(CallNew *expr)
Code * builtin(Name name)
Handle< Map > at(int i) const
static const int kNotFound
Handle< Map > GetCompareMap(CompareOperation *expr)
static bool IsInt32Double(double value)
TypeFeedbackId CallNewFeedbackId() const
void CollectKeyedReceiverTypes(TypeFeedbackId ast_id, SmallMapList *types)
static TypeInfo NonPrimitive()
TypeFeedbackId CallFeedbackId() const
static TypeFeedbackInfo * cast(Object *obj)
TypeFeedbackId UnaryOperationFeedbackId() const
bool IsForInFastCase(ForInStatement *expr)
static uint32_t encode(boolvalue)
static Smi * FromInt(int value)
ZoneList< Expression * > * arguments() const
static HeapObject * cast(Object *obj)
static Handle< T > cast(Handle< S > that)
static bool CanRetainOtherContext(Map *map, Context *native_context)
static Map * cast(Object *obj)
static KeyedAccessGrowMode GetKeyedAccessGrowMode(ExtraICState extra_ic_state)
JSBuiltinsObject * builtins()
static StubType ExtractTypeFromFlags(Flags flags)
static TypeInfo Unknown()
TypeFeedbackId CountBinOpFeedbackId() const
Handle< Map > LoadMonomorphicReceiverType(Property *expr)
TypeFeedbackId PropertyFeedbackId()
#define ASSERT(condition)
bool StoreIsMonomorphicNormal(TypeFeedbackId ast_id)
TypeInfo IncrementType(CountOperation *expr)
void Reserve(int capacity, Zone *zone)
void CollectMatchingMaps(SmallMapList *types, String *name, Code::Flags flags, Handle< Context > native_context, Zone *zone)
static TypeInfo TypeFromValue(Handle< Object > value)
static Smi * cast(Object *object)
void CallReceiverTypes(Call *expr, Handle< String > name, CallKind call_kind, SmallMapList *types)
void LoadReceiverTypes(Property *expr, Handle< String > name, SmallMapList *types)
TypeFeedbackId CompareId()
GlobalObject * global_object()
TypeInfo SwitchType(CaseClause *clause)
static TypeInfo Integer32()
CheckType GetCallCheckType(Call *expr)
static const int kForInFastCaseMarker
bool StoreIsMegamorphicWithTypeInfo(TypeFeedbackId ast_id)
Handle< JSObject > GetPrototypeForPrimitiveCheck(CheckType check)
TypeFeedbackId LiteralFeedbackId() const
Handle< Map > StoreMonomorphicReceiverType(TypeFeedbackId ast_id)
static Code * GetCodeFromTargetAddress(Address address)
bool LoadIsUninitialized(Property *expr)
TypeFeedbackId CompareOperationFeedbackId() const
TypeInfo CompareType(CompareOperation *expr)
TypeInfo BinaryType(BinaryOperation *expr)
static HeapNumber * cast(Object *obj)
byte ToBooleanTypes(TypeFeedbackId ast_id)
Handle< Map > GetObjectLiteralStoreMap(ObjectLiteral::Property *prop)
bool LoadIsBuiltin(Property *expr, Builtins::Name id)
static Handle< T > null()
TypeFeedbackOracle(Handle< Code > code, Handle< Context > native_context, Isolate *isolate, Zone *zone)
TypeFeedbackId ForInFeedbackId() const
static TypeInfo Uninitialized()
void StoreReceiverTypes(Assignment *expr, Handle< String > name, SmallMapList *types)
activate correct semantics for inheriting readonliness enable harmony semantics for typeof enable harmony enable harmony proxies enable all harmony harmony_scoping harmony_proxies harmony_scoping tracks arrays with only smi values automatically unbox arrays of doubles use crankshaft use hydrogen range analysis use hydrogen global value numbering use function inlining maximum number of AST nodes considered for a single inlining loop invariant code motion print statistics for hydrogen trace generated IR for specified phases trace register allocator trace range analysis trace representation types environment for every instruction put a break point before deoptimizing polymorphic inlining perform array bounds checks elimination use dead code elimination trace on stack replacement optimize closures cache optimized code for closures functions with arguments object loop weight for representation inference allow uint32 values on optimize frames if they are used only in safe operations track parallel recompilation enable all profiler experiments number of stack frames inspected by the profiler call recompile stub directly when self optimizing trigger profiler ticks based on counting instead of timing weight back edges by jump distance for interrupt triggering percentage of ICs that must have type info to allow optimization watch_ic_patching retry_self_opt interrupt_at_exit extra verbose compilation tracing generate extra emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of SAHF instruction if enable use of VFP3 instructions if available this implies enabling ARMv7 and VFP2 enable use of VFP2 instructions if available enable use of SDIV and UDIV instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of MIPS FPU instructions if NULL
bool CallIsMonomorphic(Call *expr)
bool IsSymbolCompare(CompareOperation *expr)
Handle< JSFunction > GetCallTarget(Call *expr)
bool ObjectLiteralStoreIsMonomorphic(ObjectLiteral::Property *prop)
activate correct semantics for inheriting readonliness enable harmony semantics for typeof enable harmony enable harmony proxies enable all harmony harmony_scoping harmony_proxies harmony_scoping tracks arrays with only smi values automatically unbox arrays of doubles use crankshaft use hydrogen range analysis use hydrogen global value numbering use function inlining maximum number of AST nodes considered for a single inlining loop invariant code motion print statistics for hydrogen trace generated IR for specified phases trace register allocator trace range analysis trace representation types environment for every instruction put a break point before deoptimizing polymorphic inlining perform array bounds checks elimination use dead code elimination trace on stack replacement optimize closures cache optimized code for closures functions with arguments object loop weight for representation inference allow uint32 values on optimize frames if they are used only in safe operations track parallel recompilation enable all profiler experiments number of stack frames inspected by the profiler call recompile stub directly when self optimizing trigger profiler ticks based on counting instead of timing weight back edges by jump distance for interrupt triggering percentage of ICs that must have type info to allow optimization watch_ic_patching retry_self_opt interrupt_at_exit extra verbose compilation tracing generate extra code(assertions) for debugging") DEFINE_bool(code_comments
void Add(Handle< Map > handle, Zone *zone)
activate correct semantics for inheriting readonliness enable harmony semantics for typeof enable harmony enable harmony proxies enable all harmony harmony_scoping harmony_proxies harmony_scoping tracks arrays with only smi values automatically unbox arrays of doubles use crankshaft use hydrogen range analysis use hydrogen global value numbering use function inlining maximum number of AST nodes considered for a single inlining loop invariant code motion print statistics for hydrogen trace generated IR for specified phases trace register allocator trace range analysis trace representation types environment for every instruction put a break point before deoptimizing polymorphic inlining perform array bounds checks elimination use dead code elimination trace on stack replacement optimize closures cache optimized code for closures functions with arguments object loop weight for representation inference allow uint32 values on optimize frames if they are used only in safe operations track parallel recompilation enable all profiler experiments number of stack frames inspected by the profiler call recompile stub directly when self optimizing trigger profiler ticks based on counting instead of timing weight back edges by jump distance for interrupt triggering percentage of ICs that must have type info to allow optimization watch_ic_patching retry_self_opt interrupt_at_exit extra verbose compilation tracing generate extra emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of SAHF instruction if enable use of VFP3 instructions if available this implies enabling ARMv7 and VFP2 enable use of VFP2 instructions if available enable use of SDIV and UDIV instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of MIPS FPU instructions if expose natives in global object expose gc extension number of stack frames to capture disable builtin natives files print a stack trace if an assertion failure occurs use random jit cookie to mask large constants trace lazy optimization use adaptive optimizations prepare for turning on always opt minimum length for automatic enable preparsing maximum number of optimization attempts before giving up cache prototype transitions automatically set the debug break flag when debugger commands are in the queue always cause a debug break before aborting maximum length of function source code printed in a stack trace max size of the new max size of the old max size of executable always perform global GCs print one trace line following each garbage collection do not print trace line after scavenger collection print more details following each garbage collection print amount of external allocated memory after each time it is adjusted flush code that we expect not to use again before full gc do incremental marking steps track object counts and memory usage use caching Perform compaction on every full GC Never perform compaction on full GC testing only Compact code space on full incremental collections Default seed for initializing random allows verbose printing trace parsing and preparsing Check icache flushes in ARM and MIPS simulator Stack alingment in bytes in print stack trace when throwing exceptions randomize hashes to avoid predictable hash Fixed seed to use to hash property activate a timer that switches between V8 threads testing_bool_flag float flag Seed used for threading test randomness A filename with extra code to be included in the Print usage including flags
bool LoadIsMonomorphicNormal(Property *expr)
TypeFeedbackId BinaryOperationFeedbackId() const
bool LoadIsMegamorphicWithTypeInfo(Property *expr)
void check(i::Vector< const char > string)
TypeInfo UnaryType(UnaryOperation *expr)
static JSObject * cast(Object *obj)
bool CallNewIsMonomorphic(CallNew *expr)
TypeFeedbackId AssignmentFeedbackId()
const Address kHandleZapValue
static Flags ComputeMonomorphicFlags(Kind kind, StubType type, ExtraICState extra_ic_state=kNoExtraICState, InlineCacheHolderFlag holder=OWN_MAP, int argc=-1)
Handle< T > CloseAndEscape(Handle< T > handle_value)
static JSFunction * cast(Object *obj)