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

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: 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 19 matching lines...) Expand all
30 30
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
Jakob Kummerow 2013/05/10 10:06:28 nit: two empty newlines between top-level things,
palfia 2013/05/17 17:24:32 Done.
41 // Prevent gcc from using load-double (mips ldc1) on (possibly)
42 // non-64-bit aligned address.
43 static inline double read_double_value(Address p) {
44 #ifndef V8_TARGET_ARCH_MIPS
danno 2013/05/10 10:15:55 I think it's better to use the platform independen
palfia 2013/05/17 17:24:32 Done.
45 return Memory::double_at(p)
46 #else // V8_TARGET_ARCH_MIPS
47 union conversion {
48 double d;
49 uint32_t u[2];
50 } c;
danno 2013/05/10 10:15:55 And if you do that, you will need to make sure tha
51 c.u[0] = (*reinterpret_cast<uint32_t*>(p));
Jakob Kummerow 2013/05/10 10:06:28 nit: don't need the outer parentheses.
palfia 2013/05/17 17:24:32 Done.
52 c.u[1] = (*reinterpret_cast<uint32_t*>(p + 4));
53 return c.d;
54 #endif // V8_TARGET_ARCH_MIPS
55 }
56
41 class FrameDescription; 57 class FrameDescription;
42 class TranslationIterator; 58 class TranslationIterator;
43 class DeoptimizingCodeListNode; 59 class DeoptimizingCodeListNode;
44 class DeoptimizedFrameInfo; 60 class DeoptimizedFrameInfo;
45 61
46 class HeapNumberMaterializationDescriptor BASE_EMBEDDED { 62 class HeapNumberMaterializationDescriptor BASE_EMBEDDED {
47 public: 63 public:
48 HeapNumberMaterializationDescriptor(Address slot_address, double val) 64 HeapNumberMaterializationDescriptor(Address slot_address, double val)
49 : slot_address_(slot_address), val_(val) { } 65 : slot_address_(slot_address), val_(val) { }
50 66
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 JSFunction* GetFunction() const { return function_; } 501 JSFunction* GetFunction() const { return function_; }
486 502
487 unsigned GetOffsetFromSlotIndex(int slot_index); 503 unsigned GetOffsetFromSlotIndex(int slot_index);
488 504
489 intptr_t GetFrameSlot(unsigned offset) { 505 intptr_t GetFrameSlot(unsigned offset) {
490 return *GetFrameSlotPointer(offset); 506 return *GetFrameSlotPointer(offset);
491 } 507 }
492 508
493 double GetDoubleFrameSlot(unsigned offset) { 509 double GetDoubleFrameSlot(unsigned offset) {
494 intptr_t* ptr = GetFrameSlotPointer(offset); 510 intptr_t* ptr = GetFrameSlotPointer(offset);
495 #if V8_TARGET_ARCH_MIPS 511 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 } 512 }
509 513
510 void SetFrameSlot(unsigned offset, intptr_t value) { 514 void SetFrameSlot(unsigned offset, intptr_t value) {
511 *GetFrameSlotPointer(offset) = value; 515 *GetFrameSlotPointer(offset) = value;
512 } 516 }
513 517
514 intptr_t GetRegister(unsigned n) const { 518 intptr_t GetRegister(unsigned n) const {
515 ASSERT(n < ARRAY_SIZE(registers_)); 519 ASSERT(n < ARRAY_SIZE(registers_));
516 return registers_[n]; 520 return registers_[n];
517 } 521 }
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
793 case UINT32: { 797 case UINT32: {
794 uint32_t value = Memory::uint32_at(addr_); 798 uint32_t value = Memory::uint32_at(addr_);
795 if (value <= static_cast<uint32_t>(Smi::kMaxValue)) { 799 if (value <= static_cast<uint32_t>(Smi::kMaxValue)) {
796 return Handle<Object>(Smi::FromInt(static_cast<int>(value)), isolate); 800 return Handle<Object>(Smi::FromInt(static_cast<int>(value)), isolate);
797 } else { 801 } else {
798 return isolate->factory()->NewNumber(static_cast<double>(value)); 802 return isolate->factory()->NewNumber(static_cast<double>(value));
799 } 803 }
800 } 804 }
801 805
802 case DOUBLE: { 806 case DOUBLE: {
803 double value = Memory::double_at(addr_); 807 double value = read_double_value(addr_);
804 return isolate->factory()->NewNumber(value); 808 return isolate->factory()->NewNumber(value);
805 } 809 }
806 810
807 case LITERAL: 811 case LITERAL:
808 return literal_; 812 return literal_;
809 813
810 default: 814 default:
811 UNREACHABLE(); 815 UNREACHABLE();
812 return Handle<Object>::null(); 816 return Handle<Object>::null();
813 } 817 }
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
917 Object** expression_stack_; 921 Object** expression_stack_;
918 int source_position_; 922 int source_position_;
919 923
920 friend class Deoptimizer; 924 friend class Deoptimizer;
921 }; 925 };
922 #endif 926 #endif
923 927
924 } } // namespace v8::internal 928 } } // namespace v8::internal
925 929
926 #endif // V8_DEOPTIMIZER_H_ 930 #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