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

Side by Side Diff: src/assembler.cc

Issue 2416543002: [wasm] Fix bounds check for zero initial memory. (Closed)
Patch Set: 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
OLDNEW
1 // Copyright (c) 1994-2006 Sun Microsystems Inc. 1 // Copyright (c) 1994-2006 Sun Microsystems Inc.
2 // All Rights Reserved. 2 // All Rights Reserved.
3 // 3 //
4 // Redistribution and use in source and binary forms, with or without 4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are 5 // modification, are permitted provided that the following conditions are
6 // met: 6 // met:
7 // 7 //
8 // - Redistributions of source code must retain the above copyright notice, 8 // - Redistributions of source code must retain the above copyright notice,
9 // this list of conditions and the following disclaimer. 9 // this list of conditions and the following disclaimer.
10 // 10 //
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 // The reference is not checked here but at runtime. Validity of references 348 // The reference is not checked here but at runtime. Validity of references
349 // may change over time. 349 // may change over time.
350 unchecked_update_wasm_memory_reference(updated_reference, 350 unchecked_update_wasm_memory_reference(updated_reference,
351 icache_flush_mode); 351 icache_flush_mode);
352 } else if (IsWasmMemorySizeReference(rmode_)) { 352 } else if (IsWasmMemorySizeReference(rmode_)) {
353 uint32_t current_size_reference = wasm_memory_size_reference(); 353 uint32_t current_size_reference = wasm_memory_size_reference();
354 DCHECK(old_size == 0 || current_size_reference <= old_size); 354 DCHECK(old_size == 0 || current_size_reference <= old_size);
355 uint32_t offset = old_size - current_size_reference; 355 uint32_t offset = old_size - current_size_reference;
356 DCHECK_GE(new_size, offset); 356 DCHECK_GE(new_size, offset);
357 uint32_t updated_size_reference = new_size - offset; 357 uint32_t updated_size_reference = new_size - offset;
358
359 if (old_size == 0) {
360 switch (rmode_) {
361 case RelocInfo::WASM_MEMORY_WORD_SIZE_REFERENCE:
362 updated_size_reference = updated_size_reference - 1;
363 break;
364 case RelocInfo::WASM_MEMORY_DWORD_SIZE_REFERENCE:
365 updated_size_reference = updated_size_reference - 3;
366 break;
367 case RelocInfo::WASM_MEMORY_QWORD_SIZE_REFERENCE:
368 updated_size_reference = updated_size_reference - 7;
369 break;
370 default:
371 DCHECK(rmode_ == RelocInfo::WASM_MEMORY_BYTE_SIZE_REFERENCE);
bradn 2016/10/12 18:50:45 Handle explicit and make default unreachable?
gdeepti 2016/10/13 08:42:59 Got rid of additional RelocInfo modes, code remove
372 }
373 }
358 unchecked_update_wasm_memory_size(updated_size_reference, 374 unchecked_update_wasm_memory_size(updated_size_reference,
359 icache_flush_mode); 375 icache_flush_mode);
360 } else { 376 } else {
361 UNREACHABLE(); 377 UNREACHABLE();
362 } 378 }
363 if (icache_flush_mode != SKIP_ICACHE_FLUSH) { 379 if (icache_flush_mode != SKIP_ICACHE_FLUSH) {
364 Assembler::FlushICache(isolate_, pc_, sizeof(int64_t)); 380 Assembler::FlushICache(isolate_, pc_, sizeof(int64_t));
365 } 381 }
366 } 382 }
367 383
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
779 case DEBUG_BREAK_SLOT_AT_CALL: 795 case DEBUG_BREAK_SLOT_AT_CALL:
780 return "debug break slot at call"; 796 return "debug break slot at call";
781 case DEBUG_BREAK_SLOT_AT_TAIL_CALL: 797 case DEBUG_BREAK_SLOT_AT_TAIL_CALL:
782 return "debug break slot at tail call"; 798 return "debug break slot at tail call";
783 case CODE_AGE_SEQUENCE: 799 case CODE_AGE_SEQUENCE:
784 return "code age sequence"; 800 return "code age sequence";
785 case GENERATOR_CONTINUATION: 801 case GENERATOR_CONTINUATION:
786 return "generator continuation"; 802 return "generator continuation";
787 case WASM_MEMORY_REFERENCE: 803 case WASM_MEMORY_REFERENCE:
788 return "wasm memory reference"; 804 return "wasm memory reference";
789 case WASM_MEMORY_SIZE_REFERENCE: 805 case WASM_MEMORY_BYTE_SIZE_REFERENCE:
790 return "wasm memory size reference"; 806 return "wasm memory size byte reference";
807 case WASM_MEMORY_WORD_SIZE_REFERENCE:
808 return "wasm memory size word reference";
809 case WASM_MEMORY_DWORD_SIZE_REFERENCE:
810 return "wasm memory size dword reference";
811 case WASM_MEMORY_QWORD_SIZE_REFERENCE:
812 return "wasm memory size qword reference";
791 case WASM_GLOBAL_REFERENCE: 813 case WASM_GLOBAL_REFERENCE:
792 return "wasm global value reference"; 814 return "wasm global value reference";
793 case NUMBER_OF_MODES: 815 case NUMBER_OF_MODES:
794 case PC_JUMP: 816 case PC_JUMP:
795 UNREACHABLE(); 817 UNREACHABLE();
796 return "number_of_modes"; 818 return "number_of_modes";
797 } 819 }
798 return "unknown relocation type"; 820 return "unknown relocation type";
799 } 821 }
800 822
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
878 case DEOPT_REASON: 900 case DEOPT_REASON:
879 case DEOPT_ID: 901 case DEOPT_ID:
880 case CONST_POOL: 902 case CONST_POOL:
881 case VENEER_POOL: 903 case VENEER_POOL:
882 case DEBUG_BREAK_SLOT_AT_POSITION: 904 case DEBUG_BREAK_SLOT_AT_POSITION:
883 case DEBUG_BREAK_SLOT_AT_RETURN: 905 case DEBUG_BREAK_SLOT_AT_RETURN:
884 case DEBUG_BREAK_SLOT_AT_CALL: 906 case DEBUG_BREAK_SLOT_AT_CALL:
885 case DEBUG_BREAK_SLOT_AT_TAIL_CALL: 907 case DEBUG_BREAK_SLOT_AT_TAIL_CALL:
886 case GENERATOR_CONTINUATION: 908 case GENERATOR_CONTINUATION:
887 case WASM_MEMORY_REFERENCE: 909 case WASM_MEMORY_REFERENCE:
888 case WASM_MEMORY_SIZE_REFERENCE: 910 case WASM_MEMORY_BYTE_SIZE_REFERENCE:
911 case WASM_MEMORY_WORD_SIZE_REFERENCE:
912 case WASM_MEMORY_DWORD_SIZE_REFERENCE:
913 case WASM_MEMORY_QWORD_SIZE_REFERENCE:
889 case WASM_GLOBAL_REFERENCE: 914 case WASM_GLOBAL_REFERENCE:
890 case NONE32: 915 case NONE32:
891 case NONE64: 916 case NONE64:
892 break; 917 break;
893 case NUMBER_OF_MODES: 918 case NUMBER_OF_MODES:
894 case PC_JUMP: 919 case PC_JUMP:
895 UNREACHABLE(); 920 UNREACHABLE();
896 break; 921 break;
897 case CODE_AGE_SEQUENCE: 922 case CODE_AGE_SEQUENCE:
898 DCHECK(Code::IsYoungSequence(isolate, pc_) || code_age_stub()->IsCode()); 923 DCHECK(Code::IsYoungSequence(isolate, pc_) || code_age_stub()->IsCode());
(...skipping 1040 matching lines...) Expand 10 before | Expand all | Expand 10 after
1939 1964
1940 1965
1941 void Assembler::DataAlign(int m) { 1966 void Assembler::DataAlign(int m) {
1942 DCHECK(m >= 2 && base::bits::IsPowerOfTwo32(m)); 1967 DCHECK(m >= 2 && base::bits::IsPowerOfTwo32(m));
1943 while ((pc_offset() & (m - 1)) != 0) { 1968 while ((pc_offset() & (m - 1)) != 0) {
1944 db(0); 1969 db(0);
1945 } 1970 }
1946 } 1971 }
1947 } // namespace internal 1972 } // namespace internal
1948 } // namespace v8 1973 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698