25 DCHECK(args.length() == 1);
28 if (FLAG_trace_lazy && !function->shared()->is_compiled()) {
30 function->PrintName();
36 DCHECK(function->shared()->allows_lazy_compilation());
41 DCHECK(code->kind() == Code::FUNCTION ||
42 code->kind() == Code::OPTIMIZED_FUNCTION);
43 function->ReplaceCode(*code);
50 DCHECK(args.length() == 2);
55 if (!isolate->use_crankshaft() ||
56 function->shared()->optimization_disabled() ||
57 isolate->DebuggerHasBreakPoints()) {
61 PrintF(
"[failed to optimize ");
62 function->PrintName();
63 PrintF(
": is code optimizable: %s, is debugger enabled: %s]\n",
64 function->shared()->optimization_disabled() ?
"F" :
"T",
65 isolate->DebuggerHasBreakPoints() ?
"T" :
"F");
67 function->ReplaceCode(*unoptimized);
68 return function->code();
75 function->ReplaceCode(*code);
77 function->ReplaceCode(function->shared()->code());
80 DCHECK(function->code()->kind() == Code::FUNCTION ||
81 function->code()->kind() == Code::OPTIMIZED_FUNCTION ||
82 function->IsInOptimizationQueue());
83 return function->code();
89 DCHECK(args.length() == 0);
91 DCHECK(AllowHeapAllocation::IsAllowed());
93 return isolate->heap()->undefined_value();
106 JavaScriptFrameIterator it(isolate, top);
111 for (; !it->done(); it->Advance()) {
121 DCHECK(args.length() == 1);
126 DCHECK(AllowHeapAllocation::IsAllowed());
131 DCHECK(optimized_code->kind() == Code::OPTIMIZED_FUNCTION);
135 JavaScriptFrameIterator it(isolate);
146 return isolate->heap()->undefined_value();
152 isolate->thread_manager()->IterateArchivedThreads(&activations_finder);
155 if (function->code() == *optimized_code) {
156 if (FLAG_trace_deopt) {
157 PrintF(
"[removing optimized code for: ");
158 function->PrintName();
161 function->ReplaceCode(function->shared()->code());
164 function->shared()->EvictFromOptimizedCodeMap(*optimized_code,
165 "notify deoptimized");
174 return isolate->heap()->undefined_value();
182 if (!isolate->
use_crankshaft() || !current_code->optimizable())
return false;
188 for (JavaScriptFrameIterator it(isolate); !it.done(); it.Advance()) {
190 if (frame->is_optimized() && frame->
function() == *
function)
return false;
199 DCHECK(args.length() == 1);
204 DCHECK(!function->shared()->uses_arguments());
210 JavaScriptFrameIterator it(isolate);
212 if (!caller_code->contains(frame->pc())) {
219 static_cast<uint32_t>(frame->pc() - caller_code->instruction_start());
223 DCHECK_EQ(frame->LookupCode(), *caller_code);
224 DCHECK(caller_code->contains(frame->pc()));
228 BailoutId ast_id = caller_code->TranslatePcOffsetToAstId(pc_offset);
232 isolate->concurrent_osr_enabled() &&
233 (
function->shared()->ast_node_count() > 512)
245 if (FLAG_trace_osr) {
246 PrintF(
"[OSR - Still waiting for queued: ");
247 function->PrintName();
257 if (FLAG_trace_osr) {
258 PrintF(
"[OSR - Found ready: ");
259 function->PrintName();
264 if (FLAG_trace_osr) {
265 PrintF(
"[OSR - Compiling: ");
266 function->PrintName();
271 if (maybe_result.ToHandle(&result) &&
272 result.is_identical_to(isolate->builtins()->InOptimizationQueue())) {
282 if (!result.
is_null() && result->kind() == Code::OPTIMIZED_FUNCTION) {
284 DeoptimizationInputData::cast(result->deoptimization_data());
286 if (data->OsrPcOffset()->value() >= 0) {
288 if (FLAG_trace_osr) {
289 PrintF(
"[OSR - Entry at AST id %d, offset %d in optimized code]\n",
290 ast_id.
ToInt(), data->OsrPcOffset()->value());
294 function->shared()->increment_deopt_count();
297 function->ReplaceCode(*result);
303 if (FLAG_trace_osr) {
304 PrintF(
"[OSR - Failed: ");
305 function->PrintName();
309 if (!function->IsOptimized()) {
310 function->ReplaceCode(function->shared()->code());
318 DCHECK(args.length() == 1);
322 StackLimitCheck check(isolate);
323 if (check.JsHasOverflowed()) {
324 SealHandleScope shs(isolate);
325 return isolate->StackOverflow();
328 isolate->optimizing_compiler_thread()->InstallOptimizedFunctions();
329 return (function->IsOptimized()) ?
function->code()
330 :
function->shared()->code();
336 DCHECK(context->allow_code_gen_from_strings()->IsFalse());
339 isolate->allow_code_gen_callback();
340 if (callback ==
NULL) {
353 DCHECK(args.length() == 2);
362 if (context->allow_code_gen_from_strings()->IsFalse() &&
365 context->ErrorMessageForCodeGenerationFromStrings();
367 isolate, NewEvalError(
"code_gen_from_strings",
368 HandleVector<Object>(&error_message, 1)));
387 int scope_position) {
393 if (native_context->allow_code_gen_from_strings()->IsFalse() &&
396 native_context->ErrorMessageForCodeGenerationFromStrings();
399 "code_gen_from_strings", HandleVector<Object>(&error_message, 1));
400 if (maybe_error.ToHandle(&error)) isolate->
Throw(*error);
413 return MakePair(*compiled, *receiver);
419 DCHECK(args.length() == 5);
428 if (*callee != isolate->native_context()->global_eval_fun() ||
429 !args[1]->IsString()) {
430 return MakePair(*callee, isolate->heap()->undefined_value());
438 strict_mode, args.smi_at(4));
static Local< Context > ToLocal(v8::internal::Handle< v8::internal::Context > obj)
bool has_code_activations_
void VisitFrames(JavaScriptFrameIterator *it)
ActivationsFinder(Code *code)
void VisitThread(Isolate *isolate, ThreadLocalTop *top)
static void Revert(Isolate *isolate, Code *unoptimized_code)
static void AddStackCheck(Handle< Code > code, uint32_t pc_offset)
static MUST_USE_RESULT MaybeHandle< JSFunction > GetFunctionFromEval(Handle< String > source, Handle< Context > context, StrictMode strict_mode, ParseRestriction restriction, int scope_position)
static MUST_USE_RESULT MaybeHandle< Code > GetOptimizedCode(Handle< JSFunction > function, Handle< Code > current_code, ConcurrencyMode mode, BailoutId osr_ast_id=BailoutId::None())
static MUST_USE_RESULT MaybeHandle< Code > GetLazyCode(Handle< JSFunction > function)
static Handle< Code > GetConcurrentlyOptimizedCode(OptimizedCompileJob *job)
static Deoptimizer * Grab(Isolate *isolate)
void MaterializeHeapObjects(JavaScriptFrameIterator *it)
static void DeoptimizeFunction(JSFunction *function)
Handle< JSFunction > function() const
Handle< Code > compiled_code() const
BailoutType bailout_type() const
static Handle< T > null()
Object * Throw(Object *exception, MessageLocation *location=NULL)
bool use_crankshaft() const
JSFunction * function() const
bool IsQueuedForOSR(Handle< JSFunction > function, BailoutId osr_ast_id)
OptimizedCompileJob * FindReadyOSRCandidate(Handle< JSFunction > function, BailoutId osr_ast_id)
static const int kNoPosition
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long mode(MIPS only)") DEFINE_BOOL(enable_always_align_csp
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long enable alignment of csp to bytes on platforms which prefer the register to always be NULL
#define ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, dst, call)
#define ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, dst, call, value)
#define THROW_NEW_ERROR_RETURN_FAILURE(isolate, call)
#define DCHECK(condition)
#define DCHECK_EQ(v1, v2)
RUNTIME_FUNCTION_RETURN_PAIR(Runtime_ResolvePossiblyDirectEval)
static ObjectPair CompileGlobalEval(Isolate *isolate, Handle< String > source, Handle< Object > receiver, StrictMode strict_mode, int scope_position)
static bool IsSuitableForOnStackReplacement(Isolate *isolate, Handle< JSFunction > function, Handle< Code > current_code)
void PrintF(const char *format,...)
bool CodeGenerationFromStringsAllowed(Isolate *isolate, Handle< Context > context)
@ ONLY_SINGLE_FUNCTION_LITERAL
static ObjectPair MakePair(Object *x, Object *y)
Debugger support for the V8 JavaScript engine.
bool(* AllowCodeGenerationFromStringsCallback)(Local< Context > context)
Callback to check if code generation from strings is allowed.
#define CONVERT_BOOLEAN_ARG_CHECKED(name, index)
#define RUNTIME_ASSERT(value)
#define CONVERT_ARG_HANDLE_CHECKED(Type, name, index)
#define CONVERT_SMI_ARG_CHECKED(name, index)