v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
execution.cc
Go to the documentation of this file.
1// Copyright 2014 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
6
7#include "src/api/api-inl.h"
8#include "src/debug/debug.h"
13
14#if V8_ENABLE_WEBASSEMBLY
15#include "src/compiler/wasm-compiler.h" // Only for static asserts.
18#endif // V8_ENABLE_WEBASSEMBLY
19
20namespace v8 {
21namespace internal {
22
23namespace {
24
25DirectHandle<Object> NormalizeReceiver(Isolate* isolate,
26 DirectHandle<Object> receiver) {
27 // Convert calls on global objects to be calls on the global
28 // receiver instead to avoid having a 'this' pointer which refers
29 // directly to a global object.
30 if (IsJSGlobalObject(*receiver)) {
31 return direct_handle(Cast<JSGlobalObject>(receiver)->global_proxy(),
32 isolate);
33 }
34 return receiver;
35}
36
37struct InvokeParams {
38 static InvokeParams SetUpForNew(
39 Isolate* isolate, DirectHandle<Object> constructor,
40 DirectHandle<Object> new_target,
41 base::Vector<const DirectHandle<Object>> args);
42
43 static InvokeParams SetUpForCall(
44 Isolate* isolate, DirectHandle<Object> callable,
45 DirectHandle<Object> receiver,
46 base::Vector<const DirectHandle<Object>> args);
47
48 static InvokeParams SetUpForTryCall(
49 Isolate* isolate, DirectHandle<Object> callable,
50 DirectHandle<Object> receiver,
51 base::Vector<const DirectHandle<Object>> args,
52 Execution::MessageHandling message_handling,
53 MaybeDirectHandle<Object>* exception_out);
54
55 static InvokeParams SetUpForRunMicrotasks(Isolate* isolate,
56 MicrotaskQueue* microtask_queue);
57
58 bool IsScript() const {
59 if (!IsJSFunction(*target)) return false;
60 auto function = Cast<JSFunction>(target);
61 return function->shared()->is_script();
62 }
63
64 DirectHandle<FixedArray> GetAndResetHostDefinedOptions() {
65 DCHECK(IsScript());
66 DCHECK_EQ(args.size(), 1);
67 auto options = Cast<FixedArray>(args[0]);
68 args = {};
69 return options;
70 }
71
72 DirectHandle<Object> target;
73 DirectHandle<Object> receiver;
74 base::Vector<const DirectHandle<Object>> args;
75 DirectHandle<Object> new_target;
76
77 MicrotaskQueue* microtask_queue;
78
80 MaybeDirectHandle<Object>* exception_out;
81
84};
85
86// static
87InvokeParams InvokeParams::SetUpForNew(
88 Isolate* isolate, DirectHandle<Object> constructor,
89 DirectHandle<Object> new_target,
90 base::Vector<const DirectHandle<Object>> args) {
91 InvokeParams params;
92 params.target = constructor;
93 params.receiver = isolate->factory()->undefined_value();
94 DCHECK(!params.IsScript());
95 params.args = args;
96 params.new_target = new_target;
97 params.microtask_queue = nullptr;
98 params.message_handling = Execution::MessageHandling::kReport;
99 params.exception_out = nullptr;
100 params.is_construct = true;
101 params.execution_target = Execution::Target::kCallable;
102 return params;
103}
104
105// static
106InvokeParams InvokeParams::SetUpForCall(
107 Isolate* isolate, DirectHandle<Object> callable,
108 DirectHandle<Object> receiver,
109 base::Vector<const DirectHandle<Object>> args) {
110 InvokeParams params;
111 params.target = callable;
112 params.receiver = NormalizeReceiver(isolate, receiver);
113 // Check for host-defined options argument for scripts.
114 DCHECK_IMPLIES(params.IsScript(), args.size() == 1);
115 DCHECK_IMPLIES(params.IsScript(), IsFixedArray(*args[0]));
116 params.args = args;
117 params.new_target = isolate->factory()->undefined_value();
118 params.microtask_queue = nullptr;
119 params.message_handling = Execution::MessageHandling::kReport;
120 params.exception_out = nullptr;
121 params.is_construct = false;
122 params.execution_target = Execution::Target::kCallable;
123 return params;
124}
125
126// static
127InvokeParams InvokeParams::SetUpForTryCall(
128 Isolate* isolate, DirectHandle<Object> callable,
129 DirectHandle<Object> receiver,
130 base::Vector<const DirectHandle<Object>> args,
132 MaybeDirectHandle<Object>* exception_out) {
133 InvokeParams params;
134 params.target = callable;
135 params.receiver = NormalizeReceiver(isolate, receiver);
136 // Check for host-defined options argument for scripts.
137 DCHECK_IMPLIES(params.IsScript(), args.size() == 1);
138 DCHECK_IMPLIES(params.IsScript(), IsFixedArray(*args[0]));
139 params.args = args;
140 params.new_target = isolate->factory()->undefined_value();
141 params.microtask_queue = nullptr;
142 params.message_handling = message_handling;
143 params.exception_out = exception_out;
144 params.is_construct = false;
145 params.execution_target = Execution::Target::kCallable;
146 return params;
147}
148
149// static
150InvokeParams InvokeParams::SetUpForRunMicrotasks(
151 Isolate* isolate, MicrotaskQueue* microtask_queue) {
152 auto undefined = isolate->factory()->undefined_value();
153 InvokeParams params;
154 params.target = undefined;
155 params.receiver = undefined;
156 params.args = {};
157 params.new_target = undefined;
158 params.microtask_queue = microtask_queue;
159 params.message_handling = Execution::MessageHandling::kReport;
160 params.exception_out = nullptr;
161 params.is_construct = false;
162 params.execution_target = Execution::Target::kRunMicrotasks;
163 return params;
164}
165
166DirectHandle<Code> JSEntry(Isolate* isolate, Execution::Target execution_target,
167 bool is_construct) {
168 if (is_construct) {
170 return BUILTIN_CODE(isolate, JSConstructEntry);
173 return BUILTIN_CODE(isolate, JSEntry);
176 return BUILTIN_CODE(isolate, JSRunMicrotasksEntry);
177 }
178 UNREACHABLE();
179}
180
181MaybeDirectHandle<Context> NewScriptContext(
182 Isolate* isolate, DirectHandle<JSFunction> function,
183 DirectHandle<FixedArray> host_defined_options) {
184 // TODO(cbruni, 1244145): Use passed in host_defined_options.
185 // Creating a script context is a side effect, so abort if that's not
186 // allowed.
187 if (isolate->should_check_side_effects()) {
188 isolate->Throw(*isolate->factory()->NewEvalError(
189 MessageTemplate::kNoSideEffectDebugEvaluate));
190 return MaybeDirectHandle<Context>();
191 }
192 SaveAndSwitchContext save(isolate, function->context());
193 Tagged<SharedFunctionInfo> sfi = function->shared();
194 Handle<Script> script(Cast<Script>(sfi->script()), isolate);
195 DirectHandle<ScopeInfo> scope_info(sfi->scope_info(), isolate);
196 DirectHandle<NativeContext> native_context(
197 Cast<NativeContext>(function->context()), isolate);
198 DirectHandle<JSGlobalObject> global_object(native_context->global_object(),
199 isolate);
200 Handle<ScriptContextTable> script_context(
201 native_context->script_context_table(), isolate);
202
203 // Find name clashes.
204 for (auto name_it : ScopeInfo::IterateLocalNames(scope_info)) {
205 Handle<String> name(name_it->name(), isolate);
206 VariableMode mode = scope_info->ContextLocalMode(name_it->index());
207 VariableLookupResult lookup;
208 if (script_context->Lookup(name, &lookup)) {
209 if (IsLexicalVariableMode(mode) || IsLexicalVariableMode(lookup.mode)) {
210 DirectHandle<Context> context(script_context->get(lookup.context_index),
211 isolate);
212 // If we are trying to redeclare a REPL-mode let as a let, REPL-mode
213 // const as a const, REPL-mode using as a using and REPL-mode await
214 // using as an await using allow it.
215 if (!((mode == lookup.mode && IsLexicalVariableMode(mode)) &&
216 scope_info->IsReplModeScope() &&
217 context->scope_info()->IsReplModeScope())) {
218 // ES#sec-globaldeclarationinstantiation 5.b:
219 // If envRec.HasLexicalDeclaration(name) is true, throw a SyntaxError
220 // exception.
221 MessageLocation location(script, 0, 1);
222 isolate->ThrowAt(isolate->factory()->NewSyntaxError(
223 MessageTemplate::kVarRedeclaration, name),
224 &location);
225 return MaybeDirectHandle<Context>();
226 }
227 }
228 }
229
230 if (IsLexicalVariableMode(mode)) {
231 LookupIterator lookup_it(isolate, global_object, name, global_object,
233 Maybe<PropertyAttributes> maybe =
235 // Can't fail since the we looking up own properties on the global object
236 // skipping interceptors.
237 CHECK(!maybe.IsNothing());
238 if ((maybe.FromJust() & DONT_DELETE) != 0) {
239 // ES#sec-globaldeclarationinstantiation 5.a:
240 // If envRec.HasVarDeclaration(name) is true, throw a SyntaxError
241 // exception.
242 // ES#sec-globaldeclarationinstantiation 5.d:
243 // If hasRestrictedGlobal is true, throw a SyntaxError exception.
244 MessageLocation location(script, 0, 1);
245 isolate->ThrowAt(isolate->factory()->NewSyntaxError(
246 MessageTemplate::kVarRedeclaration, name),
247 &location);
248 return MaybeDirectHandle<Context>();
249 }
250
251 JSGlobalObject::InvalidatePropertyCell(global_object, name);
252 }
253 }
254
255 DirectHandle<Context> result =
256 isolate->factory()->NewScriptContext(native_context, scope_info);
257
258 result->Initialize(isolate);
259 // In REPL mode, we are allowed to add/modify let/const/using/await using
260 // variables. We use the previous defined script context for those.
261 const bool ignore_duplicates = scope_info->IsReplModeScope();
262 DirectHandle<ScriptContextTable> new_script_context_table =
263 ScriptContextTable::Add(isolate, script_context, result,
264 ignore_duplicates);
265 native_context->synchronized_set_script_context_table(
266 *new_script_context_table);
267 return result;
268}
269
270V8_WARN_UNUSED_RESULT MaybeHandle<Object> Invoke(Isolate* isolate,
271 const InvokeParams& params) {
272 RCS_SCOPE(isolate, RuntimeCallCounterId::kInvoke);
273 DCHECK(!IsJSGlobalObject(*params.receiver));
274 DCHECK_LE(params.args.size(), FixedArray::kMaxLength);
275 DCHECK(!isolate->has_exception());
276 // Runtime code must be able to get the "current" isolate from TLS, and this
277 // must equal the isolate we execute in.
279
280#if V8_ENABLE_WEBASSEMBLY
281 // If we have PKU support for Wasm, ensure that code is currently write
282 // protected for this thread.
283 DCHECK_IMPLIES(wasm::GetWasmCodeManager()->HasMemoryProtectionKeySupport(),
284 !wasm::GetWasmCodeManager()->MemoryProtectionKeyWritable());
285#endif // V8_ENABLE_WEBASSEMBLY
286
287#ifdef USE_SIMULATOR
288 // Simulators use separate stacks for C++ and JS. JS stack overflow checks
289 // are performed whenever a JS function is called. However, it can be the case
290 // that the C++ stack grows faster than the JS stack, resulting in an overflow
291 // there. Add a check here to make that less likely.
292 StackLimitCheck check(isolate);
293 if (check.HasOverflowed()) {
294 isolate->StackOverflow();
295 isolate->ReportPendingMessages(params.message_handling ==
297 return MaybeHandle<Object>();
298 }
299#endif
300
301 // api callbacks can be called directly, unless we want to take the detour
302 // through JS to set up a frame for break-at-entry.
303 if (IsJSFunction(*params.target)) {
304 auto function = Cast<JSFunction>(params.target);
305 if ((!params.is_construct || IsConstructor(*function)) &&
306 function->shared()->IsApiFunction() &&
307 !function->shared()->BreakAtEntry(isolate)) {
308 SaveAndSwitchContext save(isolate, function->context());
309 DCHECK(IsJSGlobalObject(function->context()->global_object()));
310
311 DirectHandle<Object> receiver = params.is_construct
312 ? isolate->factory()->the_hole_value()
313 : params.receiver;
314 DirectHandle<FunctionTemplateInfo> fun_data(
315 function->shared()->api_func_data(), isolate);
316 auto value = Builtins::InvokeApiFunction(
317 isolate, params.is_construct, fun_data, receiver, params.args,
318 Cast<HeapObject>(params.new_target));
319 bool has_exception = value.is_null();
320 DCHECK_EQ(has_exception, isolate->has_exception());
321 if (has_exception) {
322 isolate->ReportPendingMessages(params.message_handling ==
324 return MaybeHandle<Object>();
325 } else {
326 isolate->clear_pending_message();
327 }
328 return value;
329 }
330#ifdef DEBUG
331 if (function->shared()->is_script()) {
332 DCHECK(params.IsScript());
333 DCHECK(IsJSGlobalProxy(*params.receiver));
334 DCHECK_EQ(params.args.size(), 1);
335 DCHECK(IsFixedArray(*params.args[0]));
336 } else {
337 DCHECK(!params.IsScript());
338 }
339#endif
340 // Set up a ScriptContext when running scripts that need it.
341 if (function->shared()->needs_script_context()) {
342 DirectHandle<Context> context;
343 DirectHandle<FixedArray> host_defined_options =
344 const_cast<InvokeParams&>(params).GetAndResetHostDefinedOptions();
345 if (!NewScriptContext(isolate, function, host_defined_options)
346 .ToHandle(&context)) {
347 isolate->ReportPendingMessages(params.message_handling ==
349 return MaybeHandle<Object>();
350 }
351
352 // We mutate the context if we allocate a script context. This is
353 // guaranteed to only happen once in a native context since scripts will
354 // always produce name clashes with themselves.
355 function->set_context(*context);
356 }
357 }
358
359 // Entering JavaScript.
360 VMState<JS> state(isolate);
361 if (!AllowJavascriptExecution::IsAllowed(isolate)) {
362 GRACEFUL_FATAL("Invoke in DisallowJavascriptExecutionScope");
363 }
364 if (!ThrowOnJavascriptExecution::IsAllowed(isolate)) {
365 isolate->ThrowIllegalOperation();
366 isolate->ReportPendingMessages(params.message_handling ==
368 return MaybeHandle<Object>();
369 }
370 if (!DumpOnJavascriptExecution::IsAllowed(isolate)) {
372 return isolate->factory()->undefined_value();
373 }
374 isolate->IncrementJavascriptExecutionCounter();
375
376 if (params.execution_target == Execution::Target::kCallable) {
377 DirectHandle<NativeContext> context = isolate->native_context();
378 if (!IsUndefined(context->script_execution_callback(), isolate)) {
382 isolate, context->script_execution_callback());
383 v8::Isolate* api_isolate = reinterpret_cast<v8::Isolate*>(isolate);
384 v8::Local<v8::Context> api_context = v8::Utils::ToLocal(context);
385 callback(api_isolate, api_context);
386 DCHECK(!isolate->has_exception());
387 // Always throw an exception to abort execution, if callback exists.
388 isolate->ThrowIllegalOperation();
389 return MaybeHandle<Object>();
390 }
391 }
392
393 // Placeholder for return value.
395 DirectHandle<Code> code =
396 JSEntry(isolate, params.execution_target, params.is_construct);
397 {
398 // Save and restore context around invocation.
399 SaveContext save(isolate);
400
401 if (v8_flags.clear_exceptions_on_js_entry) isolate->clear_exception();
402
403 if (params.execution_target == Execution::Target::kCallable) {
404 // clang-format off
405 // {new_target}, {target}, {receiver}, return value: tagged pointers
406 // {argv}: pointer to array of tagged pointers
407 using JSEntryFunction = GeneratedCode<Address(
408 Address root_register_value, Address new_target, Address target,
409 Address receiver, intptr_t argc, Address** argv)>;
410 // clang-format on
411 JSEntryFunction stub_entry =
412 JSEntryFunction::FromAddress(isolate, code->instruction_start());
413
414 Address orig_func = (*params.new_target).ptr();
415 Address func = (*params.target).ptr();
416 Address recv = (*params.receiver).ptr();
417
418 int argc = static_cast<int>(params.args.size());
419#ifdef V8_ENABLE_DIRECT_HANDLE
420 // TODO(42203211): Store the arguments to indirect handles because
421 // generated code still expects them in indirect handles. A fresh handle
422 // scope is introduced for these handles, which is then sealed. When this
423 // is eventually removed, sealing can go back together with saving the
424 // context for both branches.
425 HandleScope scope_for_conversion(isolate);
426 std::vector<IndirectHandle<Object>> args(argc);
427 for (int i = 0; i < argc; ++i)
428 args[i] = indirect_handle(params.args[i], isolate);
429 Address** argv = reinterpret_cast<Address**>(args.data());
430#else
431 Address** argv = const_cast<Address**>(
432 reinterpret_cast<Address* const*>(params.args.data()));
433#endif
434
435 // Block the allocation of handles without explicit handle scopes.
436 SealHandleScope shs(isolate);
437
438 RCS_SCOPE(isolate, RuntimeCallCounterId::kJS_Execution);
439 value = Tagged<Object>(
440 stub_entry.Call(isolate->isolate_data()->isolate_root(), orig_func,
441 func, recv, JSParameterCount(argc), argv));
442 } else {
443 DCHECK_EQ(Execution::Target::kRunMicrotasks, params.execution_target);
444
445 // clang-format off
446 // return value: tagged pointers
447 // {microtask_queue}: pointer to a C++ object
448 using JSEntryFunction = GeneratedCode<Address(
449 Address root_register_value, MicrotaskQueue* microtask_queue)>;
450 // clang-format on
451 JSEntryFunction stub_entry =
452 JSEntryFunction::FromAddress(isolate, code->instruction_start());
453
454 // Block the allocation of handles without explicit handle scopes.
455 SealHandleScope shs(isolate);
456
457 RCS_SCOPE(isolate, RuntimeCallCounterId::kJS_Execution);
458 value = Tagged<Object>(stub_entry.Call(
459 isolate->isolate_data()->isolate_root(), params.microtask_queue));
460 }
461 }
462
463#ifdef VERIFY_HEAP
464 if (v8_flags.verify_heap) {
465 Object::ObjectVerify(value, isolate);
466 }
467#endif
468
469 // Update the pending exception flag and return the value.
470 bool has_exception = IsException(value, isolate);
471 DCHECK_EQ(has_exception, isolate->has_exception());
472 if (has_exception) {
473 isolate->ReportPendingMessages(params.message_handling ==
475 return MaybeHandle<Object>();
476 } else {
477 isolate->clear_pending_message();
478 }
479
480 return Handle<Object>(value, isolate);
481}
482
483MaybeDirectHandle<Object> InvokeWithTryCatch(Isolate* isolate,
484 const InvokeParams& params) {
485 DCHECK_IMPLIES(v8_flags.strict_termination_checks,
486 !isolate->is_execution_terminating());
487 MaybeDirectHandle<Object> maybe_result;
488 if (params.exception_out != nullptr) {
489 *params.exception_out = {};
490 }
491
492 // Enter a try-block while executing the JavaScript code. To avoid
493 // duplicate error printing it must be non-verbose. Also, to avoid
494 // creating message objects during stack overflow we shouldn't
495 // capture messages.
496 v8::TryCatch catcher(reinterpret_cast<v8::Isolate*>(isolate));
497 catcher.SetVerbose(false);
498 catcher.SetCaptureMessage(false);
499
500 maybe_result = Invoke(isolate, params);
501
502 if (V8_LIKELY(!maybe_result.is_null())) {
503 DCHECK(!isolate->has_exception());
504 return maybe_result;
505 }
506
507 DCHECK(isolate->has_exception());
508 if (isolate->is_execution_terminating()) {
509 return maybe_result;
510 }
511
512 if (params.exception_out != nullptr) {
513 DCHECK(catcher.HasCaught());
514 *params.exception_out = v8::Utils::OpenDirectHandle(*catcher.Exception());
515 }
516
517 return maybe_result;
518}
519
520} // namespace
521
522// static
524 Isolate* isolate, DirectHandle<Object> callable,
527 // Use Execution::CallScript instead for scripts:
528 DCHECK_IMPLIES(IsJSFunction(*callable),
529 !Cast<JSFunction>(*callable)->shared()->is_script());
530 return Invoke(isolate,
531 InvokeParams::SetUpForCall(isolate, callable, receiver, args));
532}
533
534// static
536 Isolate* isolate, DirectHandle<JSFunction> script_function,
537 DirectHandle<Object> receiver, DirectHandle<Object> host_defined_options) {
538 DCHECK(script_function->shared()->is_script());
539 DCHECK(IsJSGlobalProxy(*receiver) || IsJSGlobalObject(*receiver));
540 return Invoke(isolate,
541 InvokeParams::SetUpForCall(isolate, script_function, receiver,
542 {&host_defined_options, 1}));
543}
544
546 Isolate* isolate, DirectHandle<JSFunction> builtin,
549 DCHECK(builtin->code(isolate)->is_builtin());
550 DisableBreak no_break(isolate->debug());
551 return Invoke(isolate,
552 InvokeParams::SetUpForCall(isolate, builtin, receiver, args));
553}
554
555// static
557 Isolate* isolate, DirectHandle<Object> constructor,
559 return New(isolate, constructor, constructor, args);
560}
561
562// static
564 Isolate* isolate, DirectHandle<Object> constructor,
567 return Cast<JSReceiver>(Invoke(
568 isolate,
569 InvokeParams::SetUpForNew(isolate, constructor, new_target, args)));
570}
571
572// static
574 Isolate* isolate, DirectHandle<JSFunction> script_function,
576 DirectHandle<FixedArray> host_defined_options) {
577 DCHECK(script_function->shared()->is_script());
578 DCHECK(IsJSGlobalProxy(*receiver) || IsJSGlobalObject(*receiver));
579 DirectHandle<Object> argument = host_defined_options;
580 return InvokeWithTryCatch(
581 isolate, InvokeParams::SetUpForTryCall(
582 isolate, script_function, receiver, {&argument, 1},
583 MessageHandling::kKeepPending, nullptr));
584}
585
586// static
588 Isolate* isolate, DirectHandle<Object> callable,
593 // Use Execution::TryCallScript instead for scripts:
594 DCHECK_IMPLIES(IsJSFunction(*callable),
595 !Cast<JSFunction>(*callable)->shared()->is_script());
596 return InvokeWithTryCatch(
597 isolate, InvokeParams::SetUpForTryCall(isolate, callable, receiver, args,
599}
600
601// static
604 return InvokeWithTryCatch(
605 isolate, InvokeParams::SetUpForRunMicrotasks(isolate, microtask_queue));
606}
607
609 Address next;
610 Address padding;
611};
612static_assert(offsetof(StackHandlerMarker, next) ==
614static_assert(offsetof(StackHandlerMarker, padding) ==
616static_assert(sizeof(StackHandlerMarker) == StackHandlerConstants::kSize);
617
618#if V8_ENABLE_WEBASSEMBLY
619void Execution::CallWasm(Isolate* isolate, DirectHandle<Code> wrapper_code,
620 WasmCodePointer wasm_call_target,
621 DirectHandle<Object> object_ref, Address packed_args) {
622 using WasmEntryStub = GeneratedCode<Address(
623 Address target, Address object_ref, Address argv, Address c_entry_fp)>;
624 WasmEntryStub stub_entry =
625 WasmEntryStub::FromAddress(isolate, wrapper_code->instruction_start());
626
627 // Save and restore context around invocation and block the
628 // allocation of handles without explicit handle scopes.
629 SaveContext save(isolate);
630 SealHandleScope shs(isolate);
631
632 Address saved_c_entry_fp = *isolate->c_entry_fp_address();
633 Address saved_js_entry_sp = *isolate->js_entry_sp_address();
634 if (saved_js_entry_sp == kNullAddress) {
635 *isolate->js_entry_sp_address() = GetCurrentStackPosition();
636 }
637 StackHandlerMarker stack_handler;
638 stack_handler.next = isolate->thread_local_top()->handler_;
639#ifdef V8_USE_ADDRESS_SANITIZER
640 stack_handler.padding = GetCurrentStackPosition();
641#else
642 stack_handler.padding = 0;
643#endif
644 isolate->thread_local_top()->handler_ =
645 reinterpret_cast<Address>(&stack_handler);
647
648 {
649 RCS_SCOPE(isolate, RuntimeCallCounterId::kJS_Execution);
655 stub_entry.Call(wasm_call_target.value(), (*object_ref).ptr(),
656 packed_args, saved_c_entry_fp);
657 if (result != kNullAddress) isolate->set_exception(Tagged<Object>(result));
658 }
659
660 // If there was an exception, then the thread-in-wasm flag is cleared
661 // already.
664 }
665 isolate->thread_local_top()->handler_ = stack_handler.next;
666 if (saved_js_entry_sp == kNullAddress) {
667 *isolate->js_entry_sp_address() = saved_js_entry_sp;
668 }
669 *isolate->c_entry_fp_address() = saved_c_entry_fp;
670}
671#endif // V8_ENABLE_WEBASSEMBLY
672
673} // namespace internal
674} // namespace v8
#define BUILTIN_CODE(isolate, name)
Definition builtins.h:45
void(*)(Isolate *isolate, Local< Context > context) AbortScriptExecutionCallback
Definition v8-context.h:363
static Isolate * TryGetCurrent()
Definition api.cc:9954
virtual void DumpWithoutCrashing()
static v8::internal::DirectHandle< To > OpenDirectHandle(v8::Local< From > handle)
Definition api.h:279
static V8_WARN_UNUSED_RESULT MaybeHandle< Object > InvokeApiFunction(Isolate *isolate, bool is_construct, DirectHandle< FunctionTemplateInfo > function, DirectHandle< Object > receiver, base::Vector< const DirectHandle< Object > > args, DirectHandle< HeapObject > new_target)
static V8_EXPORT_PRIVATE MaybeDirectHandle< Object > TryCallScript(Isolate *isolate, DirectHandle< JSFunction > script_function, DirectHandle< Object > receiver, DirectHandle< FixedArray > host_defined_options)
Definition execution.cc:573
static V8_EXPORT_PRIVATE MaybeDirectHandle< Object > TryCall(Isolate *isolate, DirectHandle< Object > callable, DirectHandle< Object > receiver, base::Vector< const DirectHandle< Object > > args, MessageHandling message_handling, MaybeDirectHandle< Object > *exception_out)
Definition execution.cc:587
static MaybeDirectHandle< Object > TryRunMicrotasks(Isolate *isolate, MicrotaskQueue *microtask_queue)
Definition execution.cc:602
V8_EXPORT_PRIVATE static V8_WARN_UNUSED_RESULT MaybeHandle< Object > CallScript(Isolate *isolate, DirectHandle< JSFunction > callable, DirectHandle< Object > receiver, DirectHandle< Object > host_defined_options)
Definition execution.cc:535
V8_EXPORT_PRIVATE static V8_WARN_UNUSED_RESULT MaybeHandle< Object > Call(Isolate *isolate, DirectHandle< Object > callable, DirectHandle< Object > receiver, base::Vector< const DirectHandle< Object > > args)
Definition execution.cc:523
static V8_WARN_UNUSED_RESULT MaybeHandle< Object > CallBuiltin(Isolate *isolate, DirectHandle< JSFunction > builtin, DirectHandle< Object > receiver, base::Vector< const DirectHandle< Object > > args)
Definition execution.cc:545
static V8_WARN_UNUSED_RESULT MaybeDirectHandle< JSReceiver > New(Isolate *isolate, DirectHandle< Object > constructor, base::Vector< const DirectHandle< Object > > args)
Definition execution.cc:556
static constexpr int kMaxLength
static void InvalidatePropertyCell(DirectHandle< JSGlobalObject > object, DirectHandle< Name > name)
static V8_WARN_UNUSED_RESULT Maybe< PropertyAttributes > GetPropertyAttributes(Isolate *isolate, DirectHandle< JSReceiver > object, DirectHandle< Name > name)
static LocalNamesRange< DirectHandle< ScopeInfo > > IterateLocalNames(DirectHandle< ScopeInfo > scope_info)
V8_WARN_UNUSED_RESULT static V8_EXPORT_PRIVATE Handle< ScriptContextTable > Add(Isolate *isolate, Handle< ScriptContextTable > table, DirectHandle< Context > script_context, bool ignore_duplicates)
Definition contexts.cc:76
static const int kPaddingOffset
Definition frames.h:90
static V8_EXPORT_PRIVATE v8::Platform * GetCurrentPlatform()
Definition v8.cc:282
MicrotaskQueue * microtask_queue
Definition execution.cc:77
base::Vector< const DirectHandle< Object > > args
Definition execution.cc:74
DirectHandle< Object > new_target
Definition execution.cc:75
bool is_construct
Definition execution.cc:82
MaybeDirectHandle< Object > * exception_out
Definition execution.cc:80
Execution::Target execution_target
Definition execution.cc:83
Execution::MessageHandling message_handling
Definition execution.cc:79
Isolate * isolate
TNode< Context > context
TNode< Object > receiver
TNode< Object > callback
DirectHandle< JSReceiver > options
ZoneVector< RpoNumber > & result
LiftoffAssembler::CacheState state
V8_BASE_EXPORT int const char va_list args
Definition strings.h:23
TH_DISABLE_ASAN bool IsThreadInWasm()
WasmCodeManager * GetWasmCodeManager()
bool IsLexicalVariableMode(VariableMode mode)
Definition globals.h:2155
Tagged(T object) -> Tagged< T >
V8_INLINE IndirectHandle< T > indirect_handle(DirectHandle< T > handle)
Definition handles.h:757
V8_INLINE DirectHandle< T > direct_handle(Tagged< T > object, Isolate *isolate)
too high values may cause the compiler to set high thresholds for inlining to as much as possible avoid inlined allocation of objects that cannot escape trace load stores from virtual maglev objects use TurboFan fast string builder analyze liveness of environment slots and zap dead values trace TurboFan load elimination emit data about basic block usage in builtins to this enable builtin reordering when run mksnapshot flag for emit warnings when applying builtin profile data verify register allocation in TurboFan randomly schedule instructions to stress dependency tracking enable store store elimination in TurboFan rewrite far to near simulate GC compiler thread race related to allow float parameters to be passed in simulator mode JS Wasm Run additional turbo_optimize_inlined_js_wasm_wrappers enable experimental feedback collection in generic lowering enable Turboshaft s WasmLoadElimination enable Turboshaft s low level load elimination for JS enable Turboshaft s escape analysis for string concatenation use enable Turbolev features that we want to ship in the not too far future trace individual Turboshaft reduction steps trace intermediate Turboshaft reduction steps invocation count threshold for early optimization Enables optimizations which favor memory size over execution speed Enables sampling allocation profiler with X as a sample interval min size of a semi the new space consists of two semi spaces max size of the Collect garbage after Collect garbage after keeps maps alive for< n > old space garbage collections print one detailed trace line in name
Definition flags.cc:2086
uintptr_t GetCurrentStackPosition()
Definition utils.cc:222
@ kApiAbortScriptExecutionCallbackTag
V8_EXPORT_PRIVATE FlagValues v8_flags
constexpr int JSParameterCount(int param_count_without_receiver)
Definition globals.h:2782
return value
Definition map-inl.h:893
static constexpr Address kNullAddress
Definition v8-internal.h:53
kInterpreterTrampolineOffset script
!IsContextMap !IsContextMap native_context
Definition map-inl.h:877
Tagged< To > Cast(Tagged< From > value, const v8::SourceLocation &loc=INIT_SOURCE_LOCATION_IN_DEBUG)
Definition casting.h:150
Local< T > Handle
T ToCData(i::Isolate *isolate, v8::internal::Tagged< v8::internal::Object > obj)
Definition api-inl.h:23
#define RCS_SCOPE(...)
#define GRACEFUL_FATAL(...)
Definition logging.h:41
#define DCHECK_LE(v1, v2)
Definition logging.h:490
#define CHECK(condition)
Definition logging.h:124
#define DCHECK_IMPLIES(v1, v2)
Definition logging.h:493
#define DCHECK(condition)
Definition logging.h:482
#define DCHECK_EQ(v1, v2)
Definition logging.h:485
#define V8_LIKELY(condition)
Definition v8config.h:661
#define V8_WARN_UNUSED_RESULT
Definition v8config.h:671