Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Side by Side Diff: src/wasm/wasm-module.h

Issue 2394663008: [wasm] Extend wasm object validation to WasmCompiledModule (Closed)
Patch Set: Remove debug code Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/wasm/wasm-module.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_WASM_MODULE_H_ 5 #ifndef V8_WASM_MODULE_H_
6 #define V8_WASM_MODULE_H_ 6 #define V8_WASM_MODULE_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "src/api.h" 10 #include "src/api.h"
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 std::ostream& operator<<(std::ostream& os, const WasmFunctionName& name); 340 std::ostream& operator<<(std::ostream& os, const WasmFunctionName& name);
341 341
342 typedef Result<const WasmModule*> ModuleResult; 342 typedef Result<const WasmModule*> ModuleResult;
343 typedef Result<WasmFunction*> FunctionResult; 343 typedef Result<WasmFunction*> FunctionResult;
344 typedef std::vector<std::pair<int, int>> FunctionOffsets; 344 typedef std::vector<std::pair<int, int>> FunctionOffsets;
345 typedef Result<FunctionOffsets> FunctionOffsetsResult; 345 typedef Result<FunctionOffsets> FunctionOffsetsResult;
346 346
347 class WasmCompiledModule : public FixedArray { 347 class WasmCompiledModule : public FixedArray {
348 public: 348 public:
349 static WasmCompiledModule* cast(Object* fixed_array) { 349 static WasmCompiledModule* cast(Object* fixed_array) {
350 SLOW_DCHECK(IsWasmCompiledModule(fixed_array));
350 return reinterpret_cast<WasmCompiledModule*>(fixed_array); 351 return reinterpret_cast<WasmCompiledModule*>(fixed_array);
351 } 352 }
352 353
353 #define WCM_OBJECT_OR_WEAK(TYPE, NAME, ID) \ 354 #define WCM_OBJECT_OR_WEAK(TYPE, NAME, ID) \
354 Handle<TYPE> NAME() const { return handle(ptr_to_##NAME()); } \ 355 Handle<TYPE> NAME() const { return handle(ptr_to_##NAME()); } \
355 \ 356 \
356 MaybeHandle<TYPE> maybe_##NAME() const { \ 357 MaybeHandle<TYPE> maybe_##NAME() const { \
357 if (has_##NAME()) return NAME(); \ 358 if (has_##NAME()) return NAME(); \
358 return MaybeHandle<TYPE>(); \ 359 return MaybeHandle<TYPE>(); \
359 } \ 360 } \
(...skipping 26 matching lines...) Expand all
386 return handle(TYPE::cast(weak_##NAME()->value())); \ 387 return handle(TYPE::cast(weak_##NAME()->value())); \
387 } 388 }
388 389
389 #define CORE_WCM_PROPERTY_TABLE(MACRO) \ 390 #define CORE_WCM_PROPERTY_TABLE(MACRO) \
390 MACRO(OBJECT, FixedArray, code_table) \ 391 MACRO(OBJECT, FixedArray, code_table) \
391 MACRO(OBJECT, FixedArray, imports) \ 392 MACRO(OBJECT, FixedArray, imports) \
392 MACRO(OBJECT, FixedArray, exports) \ 393 MACRO(OBJECT, FixedArray, exports) \
393 MACRO(OBJECT, FixedArray, inits) \ 394 MACRO(OBJECT, FixedArray, inits) \
394 MACRO(OBJECT, FixedArray, startup_function) \ 395 MACRO(OBJECT, FixedArray, startup_function) \
395 MACRO(OBJECT, FixedArray, indirect_function_tables) \ 396 MACRO(OBJECT, FixedArray, indirect_function_tables) \
396 MACRO(OBJECT, String, module_bytes) \ 397 MACRO(OBJECT, SeqOneByteString, module_bytes) \
397 MACRO(OBJECT, ByteArray, function_names) \ 398 MACRO(OBJECT, ByteArray, function_names) \
398 MACRO(SMALL_NUMBER, uint32_t, min_memory_pages) \ 399 MACRO(SMALL_NUMBER, uint32_t, min_memory_pages) \
399 MACRO(OBJECT, FixedArray, data_segments_info) \ 400 MACRO(OBJECT, FixedArray, data_segments_info) \
400 MACRO(OBJECT, ByteArray, data_segments) \ 401 MACRO(OBJECT, ByteArray, data_segments) \
401 MACRO(SMALL_NUMBER, uint32_t, globals_size) \ 402 MACRO(SMALL_NUMBER, uint32_t, globals_size) \
402 MACRO(OBJECT, JSArrayBuffer, heap) \ 403 MACRO(OBJECT, JSArrayBuffer, heap) \
403 MACRO(SMALL_NUMBER, ModuleOrigin, origin) \ 404 MACRO(SMALL_NUMBER, ModuleOrigin, origin) \
404 MACRO(WEAK_LINK, WasmCompiledModule, next_instance) \ 405 MACRO(WEAK_LINK, WasmCompiledModule, next_instance) \
405 MACRO(WEAK_LINK, WasmCompiledModule, prev_instance) \ 406 MACRO(WEAK_LINK, WasmCompiledModule, prev_instance) \
406 MACRO(WEAK_LINK, JSObject, owning_instance) \ 407 MACRO(WEAK_LINK, JSObject, owning_instance) \
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 } 448 }
448 449
449 uint32_t default_mem_size() const { 450 uint32_t default_mem_size() const {
450 return min_memory_pages() * WasmModule::kPageSize; 451 return min_memory_pages() * WasmModule::kPageSize;
451 } 452 }
452 453
453 #define DECLARATION(KIND, TYPE, NAME) WCM_##KIND(TYPE, NAME) 454 #define DECLARATION(KIND, TYPE, NAME) WCM_##KIND(TYPE, NAME)
454 WCM_PROPERTY_TABLE(DECLARATION) 455 WCM_PROPERTY_TABLE(DECLARATION)
455 #undef DECLARATION 456 #undef DECLARATION
456 457
458 static bool IsWasmCompiledModule(Object* obj);
459
457 void PrintInstancesChain(); 460 void PrintInstancesChain();
458 461
459 private: 462 private:
460 void Init(); 463 void Init();
461 464
462 DISALLOW_IMPLICIT_CONSTRUCTORS(WasmCompiledModule); 465 DISALLOW_IMPLICIT_CONSTRUCTORS(WasmCompiledModule);
463 }; 466 };
464 467
465 // Extract a function name from the given wasm object. 468 // Extract a function name from the given wasm object.
466 // Returns "<WASM UNNAMED>" if the function is unnamed or the name is not a 469 // Returns "<WASM UNNAMED>" if the function is unnamed or the name is not a
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 int instance_count); 548 int instance_count);
546 void ValidateModuleState(Isolate* isolate, Handle<JSObject> module_obj); 549 void ValidateModuleState(Isolate* isolate, Handle<JSObject> module_obj);
547 void ValidateOrphanedInstance(Isolate* isolate, Handle<JSObject> instance); 550 void ValidateOrphanedInstance(Isolate* isolate, Handle<JSObject> instance);
548 551
549 } // namespace testing 552 } // namespace testing
550 } // namespace wasm 553 } // namespace wasm
551 } // namespace internal 554 } // namespace internal
552 } // namespace v8 555 } // namespace v8
553 556
554 #endif // V8_WASM_MODULE_H_ 557 #endif // V8_WASM_MODULE_H_
OLDNEW
« no previous file with comments | « no previous file | src/wasm/wasm-module.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698