40 bool CodeStub::FindCodeInCache(Code** code_out) {
41 Heap* heap = Isolate::Current()->heap();
42 int index = heap->code_stubs()->FindEntry(GetKey());
44 *code_out =
Code::cast(heap->code_stubs()->ValueAt(index));
51 void CodeStub::GenerateCode(MacroAssembler* masm) {
53 masm->isolate()->counters()->code_stubs()->Increment();
56 AllowStubCallsScope allow_scope(masm,
false);
59 masm->set_generating_stub(
true);
60 NoCurrentFrameScope scope(masm);
65 SmartArrayPointer<const char> CodeStub::GetName() {
67 NoAllocationStringAllocator allocator(buffer,
68 static_cast<unsigned>(
sizeof(buffer)));
69 StringStream stream(&allocator);
71 return stream.ToCString();
75 void CodeStub::RecordCodeGeneration(Code*
code, MacroAssembler* masm) {
76 Isolate* isolate = masm->isolate();
77 SmartArrayPointer<const char> name = GetName();
78 PROFILE(isolate, CodeCreateEvent(Logger::STUB_TAG, code, *name));
79 GDBJIT(AddCode(GDBJITInterface::STUB, *name, code));
80 Counters* counters = isolate->counters();
81 counters->total_stubs_code_size()->Increment(code->instruction_size());
85 int CodeStub::GetCodeKind() {
90 Handle<Code> CodeStub::GetCode() {
91 Isolate* isolate = Isolate::Current();
92 Factory* factory = isolate->factory();
93 Heap* heap = isolate->heap();
96 ? FindCodeInSpecialCache(&code)
97 : FindCodeInCache(&code)) {
98 ASSERT(IsPregenerated() == code->is_pregenerated());
99 return Handle<Code>(
code);
103 HandleScope scope(isolate);
106 MacroAssembler masm(isolate,
NULL, 256);
115 static_cast<Code::Kind>(GetCodeKind()),
117 Handle<Code> new_object = factory->NewCode(
118 desc, flags, masm.CodeObject(), NeedsImmovableCode());
119 new_object->set_major_key(MajorKey());
120 FinishCode(new_object);
121 RecordCodeGeneration(*new_object, &masm);
123 #ifdef ENABLE_DISASSEMBLER
124 if (FLAG_print_code_stubs) {
125 new_object->Disassemble(*GetName());
130 if (UseSpecialCache()) {
131 AddToSpecialCache(new_object);
134 Handle<UnseededNumberDictionary> dict =
135 factory->DictionaryAtNumberPut(
136 Handle<UnseededNumberDictionary>(heap->code_stubs()),
139 heap->public_set_code_stubs(*dict);
145 ASSERT(!NeedsImmovableCode() ||
146 heap->lo_space()->Contains(code) ||
147 heap->code_space()->FirstPage()->Contains(code->address()));
148 return Handle<Code>(
code, isolate);
152 const char* CodeStub::MajorName(CodeStub::Major major_key,
153 bool allow_unknown_keys) {
155 #define DEF_CASE(name) case name: return #name "Stub";
159 if (!allow_unknown_keys) {
167 void CodeStub::PrintName(StringStream* stream) {
168 stream->Add(
"%s", MajorName(MajorKey(),
false));
172 void ICCompareStub::AddToSpecialCache(Handle<Code> new_object) {
174 Isolate* isolate = new_object->GetIsolate();
175 Factory* factory = isolate->factory();
178 factory->strict_compare_ic_symbol() :
179 factory->compare_ic_symbol(),
184 bool ICCompareStub::FindCodeInSpecialCache(Code** code_out) {
185 Isolate* isolate = known_map_->GetIsolate();
186 Factory* factory = isolate->factory();
188 static_cast<Code::Kind>(GetCodeKind()),
191 Handle<Object> probe(
192 known_map_->FindInCodeCache(
194 *factory->strict_compare_ic_symbol() :
195 *factory->compare_ic_symbol(),
197 if (probe->IsCode()) {
206 int ICCompareStub::MinorKey() {
207 return OpField::encode(op_ -
Token::EQ) | StateField::encode(state_);
220 GenerateHeapNumbers(masm);
223 GenerateStrings(masm);
226 GenerateSymbols(masm);
229 GenerateObjects(masm);
233 GenerateKnownObjects(masm);
242 const char* args =
"";
243 if (HasArgsInRegisters()) {
247 const char* inline_check =
"";
248 if (HasCallSiteInlineCheck()) {
249 inline_check =
"_INLINE";
252 const char* return_true_false_object =
"";
253 if (ReturnTrueFalseObject()) {
254 return_true_false_object =
"_TRUEFALSE";
257 stream->
Add(
"InstanceofStub%s%s%s",
260 return_true_false_object);
264 void JSEntryStub::FinishCode(Handle<Code> code) {
265 Handle<FixedArray> handler_table =
266 code->GetIsolate()->factory()->NewFixedArray(1,
TENURED);
268 code->set_handler_table(*handler_table);
273 switch (elements_kind_) {
306 switch (elements_kind_) {
344 void ArgumentsAccessStub::PrintName(
StringStream* stream) {
345 stream->
Add(
"ArgumentsAccessStub_");
355 void CallFunctionStub::PrintName(StringStream* stream) {
356 stream->Add(
"CallFunctionStub_Args%d", argc_);
357 if (ReceiverMightBeImplicit()) stream->Add(
"_Implicit");
358 if (RecordCallTarget()) stream->Add(
"_Recording");
362 void CallConstructStub::PrintName(StringStream* stream) {
363 stream->Add(
"CallConstructStub");
364 if (RecordCallTarget()) stream->Add(
"_Recording");
369 stream->
Add(
"ToBooleanStub_");
370 types_.
Print(stream);
387 if (!FLAG_trace_ic)
return;
390 static_cast<unsigned>(
sizeof(buffer)));
392 stream.
Add(
"[ToBooleanIC (");
402 if (object->IsUndefined()) {
405 }
else if (object->IsBoolean()) {
407 return object->IsTrue();
408 }
else if (object->IsNull()) {
411 }
else if (object->IsSmi()) {
414 }
else if (object->IsSpecObject()) {
416 return !
object->IsUndetectableObject();
417 }
else if (object->IsString()) {
419 return !
object->IsUndetectableObject() &&
421 }
else if (object->IsHeapNumber()) {
422 ASSERT(!object->IsUndetectableObject());
425 return value != 0 && !
isnan(value);
447 void ElementsTransitionAndStoreStub::Generate(
MacroAssembler* masm) {
450 if (!FLAG_trace_elements_transitions) {
487 void ProfileEntryHookStub::EntryHookTrampoline(intptr_t
function,
488 intptr_t stack_pointer) {
489 if (entry_hook_ !=
NULL)
490 entry_hook_(
function, stack_pointer);
497 if (entry_hook != 0 && entry_hook_ != 0)
500 entry_hook_ = entry_hook;
static const int kNotFound
void PrintF(const char *format,...)
static String * cast(Object *obj)
static Smi * FromInt(int value)
static void GenerateStoreExternalArray(MacroAssembler *masm, ElementsKind elements_kind)
static void GenerateLoadFastDoubleElement(MacroAssembler *masm)
virtual void PrintName(StringStream *stream)
bool Record(Handle< Object > object)
bool CanBeUndetectable() const
#define ASSERT(condition)
v8::Handle< v8::Value > Print(const v8::Arguments &args)
static bool SetFunctionEntryHook(FunctionEntryHook entry_hook)
#define PROFILE(isolate, Call)
static Code * cast(Object *obj)
static Smi * cast(Object *object)
void Add(Vector< const char > format, Vector< FmtElm > elms)
void(* FunctionEntryHook)(uintptr_t function, uintptr_t return_addr_location)
static void GenerateStoreFastElement(MacroAssembler *masm, bool is_js_array, ElementsKind element_kind, KeyedAccessGrowMode grow_mode)
static Flags ComputeFlags(Kind kind, InlineCacheState ic_state=UNINITIALIZED, ExtraICState extra_ic_state=kNoExtraICState, StubType type=NORMAL, int argc=-1, InlineCacheHolderFlag holder=OWN_MAP)
bool IsFastSmiElementsKind(ElementsKind kind)
static void GenerateSmiToDouble(MacroAssembler *masm, Label *fail)
static void GenerateMapChangeElementsTransition(MacroAssembler *masm)
static void GenerateLoadDictionaryElement(MacroAssembler *masm)
static void GenerateLoadExternalArray(MacroAssembler *masm, ElementsKind elements_kind)
bool IsFastSmiOrObjectElementsKind(ElementsKind kind)
static void UpdateCodeCache(Handle< Map > map, Handle< String > name, Handle< Code > code)
static HeapNumber * cast(Object *obj)
static void GenerateRuntimeSetProperty(MacroAssembler *masm, StrictModeFlag strict_mode)
static void GenerateDoubleToObject(MacroAssembler *masm, Label *fail)
static void GenerateLoadFastElement(MacroAssembler *masm)
static void GenerateStoreFastDoubleElement(MacroAssembler *masm, bool is_js_array, KeyedAccessGrowMode grow_mode)
void Generate(MacroAssembler *masm)
void TraceTransition(Types to) const
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 IsFastHoleyElementsKind(ElementsKind kind)
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
bool Contains(Type type) const
virtual void Generate(MacroAssembler *masm)
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
#define CODE_STUB_LIST(V)
void Print(StringStream *stream) const
void Generate(MacroAssembler *masm)
bool IsFastDoubleElementsKind(ElementsKind kind)
static void GenerateStoreDictionaryElement(MacroAssembler *masm)