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

Side by Side Diff: src/string-stream.h

Issue 109021: Add a temporary hack to FmtElm to truncate 64-bit pointers to 32-bits. (Closed)
Patch Set: Merge Created 11 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
« 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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 char* allocate(unsigned bytes) { return space_; } 65 char* allocate(unsigned bytes) { return space_; }
66 char* grow(unsigned* bytes); 66 char* grow(unsigned* bytes);
67 private: 67 private:
68 unsigned size_; 68 unsigned size_;
69 char* space_; 69 char* space_;
70 }; 70 };
71 71
72 72
73 class FmtElm { 73 class FmtElm {
74 public: 74 public:
75 FmtElm(int value) : type_(INT) { data_.u_int_ = value; } // NOLINT 75 FmtElm(int value) : type_(INT) { // NOLINT
76 explicit FmtElm(double value) : type_(DOUBLE) { data_.u_double_ = value; } // NOLINT 76 data_.u_int_ = value;
77 FmtElm(const char* value) : type_(C_STR) { data_.u_c_str_ = value; } // NOLIN T 77 }
78 FmtElm(const Vector<const uc16>& value) : type_(LC_STR) { data_.u_lc_str_ = &v alue; } // NOLINT 78 explicit FmtElm(double value) : type_(DOUBLE) {
79 FmtElm(Object* value) : type_(OBJ) { data_.u_obj_ = value; } // NOLINT 79 data_.u_double_ = value;
80 FmtElm(Handle<Object> value) : type_(HANDLE) { data_.u_handle_ = value.locatio n(); } // NOLINT 80 }
81 FmtElm(void* value) : type_(INT) { data_.u_int_ = reinterpret_cast<int>(value) ; } // NOLINT 81 FmtElm(const char* value) : type_(C_STR) { // NOLINT
82 data_.u_c_str_ = value;
83 }
84 FmtElm(const Vector<const uc16>& value) : type_(LC_STR) { // NOLINT
85 data_.u_lc_str_ = &value;
86 }
87 FmtElm(Object* value) : type_(OBJ) { // NOLINT
88 data_.u_obj_ = value;
89 }
90 FmtElm(Handle<Object> value) : type_(HANDLE) { // NOLINT
91 data_.u_handle_ = value.location();
92 }
93 FmtElm(void* value) : type_(INT) { // NOLINT
94 #if V8_HOST_ARCH_64_BIT
95 // TODO(x64): FmtElm needs to treat pointers as pointers, and not as
96 // ints. This will require adding a pointer type, etc. For now just
97 // hack it and truncate the pointer.
98 // http://code.google.com/p/v8/issues/detail?id=335
99 data_.u_int_ = 0;
100 UNIMPLEMENTED();
101 #else
102 data_.u_int_ = reinterpret_cast<int>(value);
103 #endif
104 }
82 private: 105 private:
83 friend class StringStream; 106 friend class StringStream;
84 enum Type { INT, DOUBLE, C_STR, LC_STR, OBJ, HANDLE }; 107 enum Type { INT, DOUBLE, C_STR, LC_STR, OBJ, HANDLE };
85 Type type_; 108 Type type_;
86 union { 109 union {
87 int u_int_; 110 int u_int_;
88 double u_double_; 111 double u_double_;
89 const char* u_c_str_; 112 const char* u_c_str_;
90 const Vector<const uc16>* u_lc_str_; 113 const Vector<const uc16>* u_lc_str_;
91 Object* u_obj_; 114 Object* u_obj_;
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 bool full() const { return (capacity_ - length_) == 1; } 188 bool full() const { return (capacity_ - length_) == 1; }
166 int space() const { return capacity_ - length_; } 189 int space() const { return capacity_ - length_; }
167 190
168 DISALLOW_IMPLICIT_CONSTRUCTORS(StringStream); 191 DISALLOW_IMPLICIT_CONSTRUCTORS(StringStream);
169 }; 192 };
170 193
171 194
172 } } // namespace v8::internal 195 } } // namespace v8::internal
173 196
174 #endif // V8_STRING_STREAM_H_ 197 #endif // V8_STRING_STREAM_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