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

Side by Side Diff: src/deoptimizer.h

Issue 14631016: MIPS: Fix unaligned address of double. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address comments. Created 7 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 20 matching lines...) Expand all
31 #include "v8.h" 31 #include "v8.h"
32 32
33 #include "allocation.h" 33 #include "allocation.h"
34 #include "macro-assembler.h" 34 #include "macro-assembler.h"
35 #include "zone-inl.h" 35 #include "zone-inl.h"
36 36
37 37
38 namespace v8 { 38 namespace v8 {
39 namespace internal { 39 namespace internal {
40 40
41
42 static inline double read_double_value(Address p) {
43 #ifdef V8_HOST_CAN_READ_UNALIGNED
44 return Memory::double_at(p);
45 #else // V8_HOST_CAN_READ_UNALIGNED
46 // Prevent gcc from using load-double (mips ldc1) on (possibly)
47 // non-64-bit aligned address.
48 union conversion {
49 double d;
50 uint32_t u[2];
51 } c;
52 c.u[0] = *reinterpret_cast<uint32_t*>(p);
53 c.u[1] = *reinterpret_cast<uint32_t*>(p + 4);
54 return c.d;
55 #endif // V8_HOST_CAN_READ_UNALIGNED
56 }
57
58
41 class FrameDescription; 59 class FrameDescription;
42 class TranslationIterator; 60 class TranslationIterator;
43 class DeoptimizingCodeListNode; 61 class DeoptimizingCodeListNode;
44 class DeoptimizedFrameInfo; 62 class DeoptimizedFrameInfo;
45 63
46 class HeapNumberMaterializationDescriptor BASE_EMBEDDED { 64 class HeapNumberMaterializationDescriptor BASE_EMBEDDED {
47 public: 65 public:
48 HeapNumberMaterializationDescriptor(Address slot_address, double val) 66 HeapNumberMaterializationDescriptor(Address slot_address, double val)
49 : slot_address_(slot_address), val_(val) { } 67 : slot_address_(slot_address), val_(val) { }
50 68
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 JSFunction* GetFunction() const { return function_; } 503 JSFunction* GetFunction() const { return function_; }
486 504
487 unsigned GetOffsetFromSlotIndex(int slot_index); 505 unsigned GetOffsetFromSlotIndex(int slot_index);
488 506
489 intptr_t GetFrameSlot(unsigned offset) { 507 intptr_t GetFrameSlot(unsigned offset) {
490 return *GetFrameSlotPointer(offset); 508 return *GetFrameSlotPointer(offset);
491 } 509 }
492 510
493 double GetDoubleFrameSlot(unsigned offset) { 511 double GetDoubleFrameSlot(unsigned offset) {
494 intptr_t* ptr = GetFrameSlotPointer(offset); 512 intptr_t* ptr = GetFrameSlotPointer(offset);
495 #if V8_TARGET_ARCH_MIPS 513 return read_double_value(reinterpret_cast<Address>(ptr));
496 // Prevent gcc from using load-double (mips ldc1) on (possibly)
497 // non-64-bit aligned double. Uses two lwc1 instructions.
498 union conversion {
499 double d;
500 uint32_t u[2];
501 } c;
502 c.u[0] = *reinterpret_cast<uint32_t*>(ptr);
503 c.u[1] = *(reinterpret_cast<uint32_t*>(ptr) + 1);
504 return c.d;
505 #else
506 return *reinterpret_cast<double*>(ptr);
507 #endif
508 } 514 }
509 515
510 void SetFrameSlot(unsigned offset, intptr_t value) { 516 void SetFrameSlot(unsigned offset, intptr_t value) {
511 *GetFrameSlotPointer(offset) = value; 517 *GetFrameSlotPointer(offset) = value;
512 } 518 }
513 519
514 intptr_t GetRegister(unsigned n) const { 520 intptr_t GetRegister(unsigned n) const {
515 ASSERT(n < ARRAY_SIZE(registers_)); 521 ASSERT(n < ARRAY_SIZE(registers_));
516 return registers_[n]; 522 return registers_[n];
517 } 523 }
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
793 case UINT32: { 799 case UINT32: {
794 uint32_t value = Memory::uint32_at(addr_); 800 uint32_t value = Memory::uint32_at(addr_);
795 if (value <= static_cast<uint32_t>(Smi::kMaxValue)) { 801 if (value <= static_cast<uint32_t>(Smi::kMaxValue)) {
796 return Handle<Object>(Smi::FromInt(static_cast<int>(value)), isolate); 802 return Handle<Object>(Smi::FromInt(static_cast<int>(value)), isolate);
797 } else { 803 } else {
798 return isolate->factory()->NewNumber(static_cast<double>(value)); 804 return isolate->factory()->NewNumber(static_cast<double>(value));
799 } 805 }
800 } 806 }
801 807
802 case DOUBLE: { 808 case DOUBLE: {
803 double value = Memory::double_at(addr_); 809 double value = read_double_value(addr_);
804 return isolate->factory()->NewNumber(value); 810 return isolate->factory()->NewNumber(value);
805 } 811 }
806 812
807 case LITERAL: 813 case LITERAL:
808 return literal_; 814 return literal_;
809 815
810 default: 816 default:
811 UNREACHABLE(); 817 UNREACHABLE();
812 return Handle<Object>::null(); 818 return Handle<Object>::null();
813 } 819 }
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
917 Object** expression_stack_; 923 Object** expression_stack_;
918 int source_position_; 924 int source_position_;
919 925
920 friend class Deoptimizer; 926 friend class Deoptimizer;
921 }; 927 };
922 #endif 928 #endif
923 929
924 } } // namespace v8::internal 930 } } // namespace v8::internal
925 931
926 #endif // V8_DEOPTIMIZER_H_ 932 #endif // V8_DEOPTIMIZER_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698