5 #ifndef V8_WASM_WASM_OBJECTS_H_ 6 #define V8_WASM_WASM_OBJECTS_H_ 8 #include "src/base/bits.h" 9 #include "src/debug/debug.h" 10 #include "src/debug/interface-types.h" 11 #include "src/heap/heap.h" 12 #include "src/objects.h" 13 #include "src/objects/script.h" 14 #include "src/signature.h" 15 #include "src/wasm/value-type.h" 18 #include "src/objects/object-macros.h" 23 struct CompilationEnv;
24 class InterpretedFrame;
25 struct InterpretedFrameDeleter;
30 class WasmInterpreter;
37 class SeqOneByteString;
39 class WasmInstanceObject;
40 class WasmModuleObject;
42 template <
class CppType>
45 #define DECL_OPTIONAL_ACCESSORS(name, type) \ 46 V8_INLINE bool has_##name(); \ 47 DECL_ACCESSORS(name, type) 49 #define DECL_OPTIONAL_ACCESSORS2(name, type) \ 50 V8_INLINE bool has_##name(); \ 51 DECL_ACCESSORS2(name, type) 66 int target_func_index);
115 DECL_ACCESSORS(script,
Script)
117 DECL_OPTIONAL_ACCESSORS2(asm_js_offset_table,
ByteArray)
118 DECL_OPTIONAL_ACCESSORS2(breakpoint_infos,
FixedArray)
121 inline void reset_breakpoint_infos();
128 #define WASM_MODULE_OBJECT_FIELDS(V) \ 129 V(kNativeModuleOffset, kPointerSize) \ 130 V(kExportWrappersOffset, kPointerSize) \ 131 V(kScriptOffset, kPointerSize) \ 132 V(kWeakInstanceListOffset, kPointerSize) \ 133 V(kAsmJsOffsetTableOffset, kPointerSize) \ 134 V(kBreakPointInfosOffset, kPointerSize) \ 137 DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize,
138 WASM_MODULE_OBJECT_FIELDS)
139 #undef WASM_MODULE_OBJECT_FIELDS 144 std::shared_ptr<const wasm::WasmModule> module,
151 Isolate* isolate, std::shared_ptr<wasm::NativeModule> native_module,
154 Isolate* isolate, std::shared_ptr<wasm::NativeModule> native_module,
156 size_t code_size_estimate);
168 inline bool is_asm_js();
202 int GetFunctionOffset(
uint32_t func_index);
207 int GetContainingFunction(
uint32_t byte_offset);
218 bool is_at_number_conversion);
239 std::vector<debug::BreakLocation>* locations);
255 DECL_ACCESSORS(maximum_length,
Object)
259 #define WASM_TABLE_OBJECT_FIELDS(V) \ 260 V(kFunctionsOffset, kPointerSize) \ 261 V(kMaximumLengthOffset, kPointerSize) \ 262 V(kDispatchTablesOffset, kPointerSize) \ 265 DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize, WASM_TABLE_OBJECT_FIELDS)
266 #undef WASM_TABLE_OBJECT_FIELDS 281 static void UpdateDispatchTables(
Isolate* isolate,
285 int target_func_index);
287 static void ClearDispatchTables(
Isolate* isolate,
297 DECL_INT_ACCESSORS(maximum_pages)
301 #define WASM_MEMORY_OBJECT_FIELDS(V) \ 302 V(kArrayBufferOffset, kPointerSize) \ 303 V(kMaximumPagesOffset, kPointerSize) \ 304 V(kInstancesOffset, kPointerSize) \ 307 DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize,
308 WASM_MEMORY_OBJECT_FIELDS)
309 #undef WASM_MEMORY_OBJECT_FIELDS 318 inline bool has_maximum_pages();
322 bool has_full_guard_region(
Isolate* isolate);
336 DECL_INT32_ACCESSORS(offset)
337 DECL_INT_ACCESSORS(flags)
338 DECL_PRIMITIVE_ACCESSORS(
type, wasm::ValueType)
339 DECL_BOOLEAN_ACCESSORS(is_mutable)
341 #define WASM_GLOBAL_OBJECT_FLAGS_BIT_FIELDS(V, _) \ 342 V(TypeBits, wasm::ValueType, 8, _) \ 343 V(IsMutableBit, bool, 1, _) 345 DEFINE_BIT_FIELDS(WASM_GLOBAL_OBJECT_FLAGS_BIT_FIELDS)
347 #undef WASM_GLOBAL_OBJECT_FLAGS_BIT_FIELDS 350 #define WASM_GLOBAL_OBJECT_FIELDS(V) \ 351 V(kArrayBufferOffset, kPointerSize) \ 352 V(kOffsetOffset, kPointerSize) \ 353 V(kFlagsOffset, kPointerSize) \ 356 DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize,
357 WASM_GLOBAL_OBJECT_FIELDS)
358 #undef WASM_GLOBAL_OBJECT_FIELDS 362 int32_t offset,
bool is_mutable);
364 inline int type_size()
const;
366 inline int32_t GetI32();
368 inline float GetF32();
369 inline double GetF64();
371 inline void SetI32(int32_t value);
372 inline void SetI64(
int64_t value);
373 inline void SetF32(
float value);
374 inline void SetF64(
double value);
380 inline Address address()
const;
389 DECL_ACCESSORS(exports_object,
JSObject)
390 DECL_ACCESSORS2(native_context,
Context)
393 DECL_OPTIONAL_ACCESSORS2(imported_mutable_globals_buffers,
FixedArray)
396 DECL_ACCESSORS2(imported_function_refs,
FixedArray)
397 DECL_OPTIONAL_ACCESSORS2(indirect_function_table_refs,
FixedArray)
398 DECL_OPTIONAL_ACCESSORS(managed_native_allocations,
Foreign)
399 DECL_OPTIONAL_ACCESSORS2(exceptions_table,
FixedArray)
400 DECL_ACCESSORS(undefined_value,
Oddball)
401 DECL_ACCESSORS(null_value,
Oddball)
402 DECL_ACCESSORS2(centry_stub,
Code)
403 DECL_PRIMITIVE_ACCESSORS(memory_start, byte*)
404 DECL_PRIMITIVE_ACCESSORS(memory_size,
size_t)
405 DECL_PRIMITIVE_ACCESSORS(memory_mask,
size_t)
406 DECL_PRIMITIVE_ACCESSORS(isolate_root,
Address)
407 DECL_PRIMITIVE_ACCESSORS(stack_limit_address,
Address)
408 DECL_PRIMITIVE_ACCESSORS(real_stack_limit_address,
Address)
409 DECL_PRIMITIVE_ACCESSORS(imported_function_targets,
Address*)
410 DECL_PRIMITIVE_ACCESSORS(globals_start, byte*)
411 DECL_PRIMITIVE_ACCESSORS(imported_mutable_globals,
Address*)
412 DECL_PRIMITIVE_ACCESSORS(indirect_function_table_size,
uint32_t)
413 DECL_PRIMITIVE_ACCESSORS(indirect_function_table_sig_ids,
uint32_t*)
414 DECL_PRIMITIVE_ACCESSORS(indirect_function_table_targets,
Address*)
415 DECL_PRIMITIVE_ACCESSORS(jump_table_start,
Address)
422 #define WASM_INSTANCE_OBJECT_FIELDS(V) \ 423 V(kModuleObjectOffset, kPointerSize) \ 424 V(kExportsObjectOffset, kPointerSize) \ 425 V(kNativeContextOffset, kPointerSize) \ 426 V(kMemoryObjectOffset, kPointerSize) \ 427 V(kGlobalsBufferOffset, kPointerSize) \ 428 V(kImportedMutableGlobalsBuffersOffset, kPointerSize) \ 429 V(kDebugInfoOffset, kPointerSize) \ 430 V(kTableObjectOffset, kPointerSize) \ 431 V(kImportedFunctionRefsOffset, kPointerSize) \ 432 V(kIndirectFunctionTableRefsOffset, kPointerSize) \ 433 V(kManagedNativeAllocationsOffset, kPointerSize) \ 434 V(kExceptionsTableOffset, kPointerSize) \ 435 V(kUndefinedValueOffset, kPointerSize) \ 436 V(kNullValueOffset, kPointerSize) \ 437 V(kCEntryStubOffset, kPointerSize) \ 438 V(kFirstUntaggedOffset, 0) \ 439 V(kMemoryStartOffset, kPointerSize) \ 440 V(kMemorySizeOffset, kSizetSize) \ 441 V(kMemoryMaskOffset, kSizetSize) \ 442 V(kIsolateRootOffset, kPointerSize) \ 443 V(kStackLimitAddressOffset, kPointerSize) \ 444 V(kRealStackLimitAddressOffset, kPointerSize) \ 445 V(kImportedFunctionTargetsOffset, kPointerSize) \ 446 V(kGlobalsStartOffset, kPointerSize) \ 447 V(kImportedMutableGlobalsOffset, kPointerSize) \ 448 V(kIndirectFunctionTableSigIdsOffset, kPointerSize) \ 449 V(kIndirectFunctionTableTargetsOffset, kPointerSize) \ 450 V(kJumpTableStartOffset, kPointerSize) \ 451 V(kIndirectFunctionTableSizeOffset, kUInt32Size) \ 452 V(k64BitArchPaddingOffset, kPointerSize - kUInt32Size) \ 455 DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize,
456 WASM_INSTANCE_OBJECT_FIELDS)
457 #undef WASM_INSTANCE_OBJECT_FIELDS 461 static bool EnsureIndirectFunctionTableWithMinimumSize(
464 bool has_indirect_function_table();
466 void SetRawMemory(byte* mem_start,
size_t mem_size);
489 #define WASM_EXCEPTION_OBJECT_FIELDS(V) \ 490 V(kSerializedSignatureOffset, kPointerSize) \ 491 V(kExceptionTagOffset, kPointerSize) \ 494 DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize,
495 WASM_EXCEPTION_OBJECT_FIELDS)
496 #undef WASM_EXCEPTION_OBJECT_FIELDS 511 V8_EXPORT_PRIVATE
int function_index();
514 static bool IsWasmExportedFunction(
Object*
object);
519 int func_index,
int arity,
532 DECL_ACCESSORS2(wrapper_code,
Code);
534 DECL_INT_ACCESSORS(jump_table_offset);
535 DECL_INT_ACCESSORS(function_index);
544 #define WASM_EXPORTED_FUNCTION_DATA_FIELDS(V) \ 545 V(kWrapperCodeOffset, kPointerSize) \ 546 V(kInstanceOffset, kPointerSize) \ 547 V(kJumpTableOffsetOffset, kPointerSize) \ 548 V(kFunctionIndexOffset, kPointerSize) \ 551 DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize,
552 WASM_EXPORTED_FUNCTION_DATA_FIELDS)
553 #undef WASM_EXPORTED_FUNCTION_DATA_FIELDS 559 DECL_ACCESSORS(interpreter_handle,
Object);
560 DECL_ACCESSORS2(interpreted_functions,
FixedArray);
561 DECL_OPTIONAL_ACCESSORS2(locals_names,
FixedArray)
562 DECL_OPTIONAL_ACCESSORS2(c_wasm_entries,
FixedArray)
572 #define WASM_DEBUG_INFO_FIELDS(V) \ 573 V(kInstanceOffset, kPointerSize) \ 574 V(kInterpreterHandleOffset, kPointerSize) \ 575 V(kInterpretedFunctionsOffset, kPointerSize) \ 576 V(kLocalsNamesOffset, kPointerSize) \ 577 V(kCWasmEntriesOffset, kPointerSize) \ 578 V(kCWasmEntryMapOffset, kPointerSize) \ 581 DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize, WASM_DEBUG_INFO_FIELDS)
582 #undef WASM_DEBUG_INFO_FIELDS 603 void PrepareStep(StepAction);
612 Address frame_pointer,
int func_index,
617 std::vector<std::pair<uint32_t, int>> GetInterpretedStack(
620 std::unique_ptr<wasm::InterpretedFrame, wasm::InterpretedFrameDeleter>
621 GetInterpretedFrame(
Address frame_pointer,
int frame_index);
625 void Unwind(
Address frame_pointer);
628 uint64_t NumInterpretedCalls();
654 Isolate* isolate, std::shared_ptr<wasm::NativeModule> native_module,
660 DECL_ACCESSORS2(asm_js_offset_table,
ByteArray)
668 #define ASM_WASM_DATA_FIELDS(V) \ 669 V(kManagedNativeModuleOffset, kPointerSize) \ 670 V(kExportWrappersOffset, kPointerSize) \ 671 V(kAsmJsOffsetTableOffset, kPointerSize) \ 672 V(kUsesBitsetOffset, kPointerSize) \ 676 DEFINE_FIELD_OFFSET_CONSTANTS(Struct::kHeaderSize, ASM_WASM_DATA_FIELDS)
677 #undef ASM_WASM_DATA_FIELDS 680 #undef DECL_OPTIONAL_ACCESSORS 685 #include "src/objects/object-macros-undef.h" 687 #endif // V8_WASM_WASM_OBJECTS_H_