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

Side by Side Diff: src/hydrogen-instructions.h

Issue 23781006: Add assertion to UniqueValueId constructor. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 3 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 | « src/hydrogen.cc ('k') | src/hydrogen-instructions.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 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 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 int32_t upper_; 302 int32_t upper_;
303 Range* next_; 303 Range* next_;
304 bool can_be_minus_zero_; 304 bool can_be_minus_zero_;
305 }; 305 };
306 306
307 307
308 class UniqueValueId V8_FINAL { 308 class UniqueValueId V8_FINAL {
309 public: 309 public:
310 UniqueValueId() : raw_address_(NULL) { } 310 UniqueValueId() : raw_address_(NULL) { }
311 311
312 explicit UniqueValueId(Object* object) {
313 raw_address_ = reinterpret_cast<Address>(object);
314 ASSERT(IsInitialized());
315 }
316
317 explicit UniqueValueId(Handle<Object> handle) { 312 explicit UniqueValueId(Handle<Object> handle) {
313 ASSERT(!AllowHeapAllocation::IsAllowed());
318 static const Address kEmptyHandleSentinel = reinterpret_cast<Address>(1); 314 static const Address kEmptyHandleSentinel = reinterpret_cast<Address>(1);
319 if (handle.is_null()) { 315 if (handle.is_null()) {
320 raw_address_ = kEmptyHandleSentinel; 316 raw_address_ = kEmptyHandleSentinel;
321 } else { 317 } else {
322 raw_address_ = reinterpret_cast<Address>(*handle); 318 raw_address_ = reinterpret_cast<Address>(*handle);
323 ASSERT_NE(kEmptyHandleSentinel, raw_address_); 319 ASSERT_NE(kEmptyHandleSentinel, raw_address_);
324 } 320 }
325 ASSERT(IsInitialized()); 321 ASSERT(IsInitialized());
326 } 322 }
327 323
328 bool IsInitialized() const { return raw_address_ != NULL; } 324 bool IsInitialized() const { return raw_address_ != NULL; }
329 325
330 bool operator==(const UniqueValueId& other) const { 326 bool operator==(const UniqueValueId& other) const {
331 ASSERT(IsInitialized() && other.IsInitialized()); 327 ASSERT(IsInitialized() && other.IsInitialized());
332 return raw_address_ == other.raw_address_; 328 return raw_address_ == other.raw_address_;
333 } 329 }
334 330
335 bool operator!=(const UniqueValueId& other) const { 331 bool operator!=(const UniqueValueId& other) const {
336 ASSERT(IsInitialized() && other.IsInitialized()); 332 ASSERT(IsInitialized() && other.IsInitialized());
337 return raw_address_ != other.raw_address_; 333 return raw_address_ != other.raw_address_;
338 } 334 }
339 335
340 intptr_t Hashcode() const { 336 intptr_t Hashcode() const {
341 ASSERT(IsInitialized()); 337 ASSERT(IsInitialized());
342 return reinterpret_cast<intptr_t>(raw_address_); 338 return reinterpret_cast<intptr_t>(raw_address_);
343 } 339 }
344 340
341 #define IMMOVABLE_UNIQUE_VALUE_ID(name) \
342 static UniqueValueId name(Heap* heap) { \
343 return UniqueValueId(heap->name()); \
344 }
345
346 IMMOVABLE_UNIQUE_VALUE_ID(free_space_map)
347 IMMOVABLE_UNIQUE_VALUE_ID(minus_zero_value)
348 IMMOVABLE_UNIQUE_VALUE_ID(nan_value)
349 IMMOVABLE_UNIQUE_VALUE_ID(undefined_value)
350 IMMOVABLE_UNIQUE_VALUE_ID(null_value)
351 IMMOVABLE_UNIQUE_VALUE_ID(true_value)
352 IMMOVABLE_UNIQUE_VALUE_ID(false_value)
353 IMMOVABLE_UNIQUE_VALUE_ID(the_hole_value)
354 IMMOVABLE_UNIQUE_VALUE_ID(empty_string)
355
356 #undef IMMOVABLE_UNIQUE_VALUE_ID
357
345 private: 358 private:
346 Address raw_address_; 359 Address raw_address_;
360
361 explicit UniqueValueId(Object* object) {
362 raw_address_ = reinterpret_cast<Address>(object);
363 ASSERT(IsInitialized());
364 }
347 }; 365 };
348 366
349 367
350 class HType V8_FINAL { 368 class HType V8_FINAL {
351 public: 369 public:
352 static HType None() { return HType(kNone); } 370 static HType None() { return HType(kNone); }
353 static HType Tagged() { return HType(kTagged); } 371 static HType Tagged() { return HType(kTagged); }
354 static HType TaggedPrimitive() { return HType(kTaggedPrimitive); } 372 static HType TaggedPrimitive() { return HType(kTaggedPrimitive); }
355 static HType TaggedNumber() { return HType(kTaggedNumber); } 373 static HType TaggedNumber() { return HType(kTaggedNumber); }
356 static HType Smi() { return HType(kSmi); } 374 static HType Smi() { return HType(kSmi); }
(...skipping 2963 matching lines...) Expand 10 before | Expand all | Expand 10 after
3320 return true; 3338 return true;
3321 } 3339 }
3322 return false; 3340 return false;
3323 } 3341 }
3324 if (has_external_reference_value_) { 3342 if (has_external_reference_value_) {
3325 return false; 3343 return false;
3326 } 3344 }
3327 3345
3328 ASSERT(!handle_.is_null()); 3346 ASSERT(!handle_.is_null());
3329 Heap* heap = isolate()->heap(); 3347 Heap* heap = isolate()->heap();
3330 ASSERT(unique_id_ != UniqueValueId(heap->minus_zero_value())); 3348 ASSERT(unique_id_ != UniqueValueId::minus_zero_value(heap));
3331 ASSERT(unique_id_ != UniqueValueId(heap->nan_value())); 3349 ASSERT(unique_id_ != UniqueValueId::nan_value(heap));
3332 return unique_id_ == UniqueValueId(heap->undefined_value()) || 3350 return unique_id_ == UniqueValueId::undefined_value(heap) ||
3333 unique_id_ == UniqueValueId(heap->null_value()) || 3351 unique_id_ == UniqueValueId::null_value(heap) ||
3334 unique_id_ == UniqueValueId(heap->true_value()) || 3352 unique_id_ == UniqueValueId::true_value(heap) ||
3335 unique_id_ == UniqueValueId(heap->false_value()) || 3353 unique_id_ == UniqueValueId::false_value(heap) ||
3336 unique_id_ == UniqueValueId(heap->the_hole_value()) || 3354 unique_id_ == UniqueValueId::the_hole_value(heap) ||
3337 unique_id_ == UniqueValueId(heap->empty_string()); 3355 unique_id_ == UniqueValueId::empty_string(heap);
3338 } 3356 }
3339 3357
3340 bool IsCell() const { 3358 bool IsCell() const {
3341 return is_cell_; 3359 return is_cell_;
3342 } 3360 }
3343 3361
3344 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { 3362 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
3345 return Representation::None(); 3363 return Representation::None();
3346 } 3364 }
3347 3365
(...skipping 3605 matching lines...) Expand 10 before | Expand all | Expand 10 after
6953 virtual bool IsDeletable() const V8_OVERRIDE { return true; } 6971 virtual bool IsDeletable() const V8_OVERRIDE { return true; }
6954 }; 6972 };
6955 6973
6956 6974
6957 #undef DECLARE_INSTRUCTION 6975 #undef DECLARE_INSTRUCTION
6958 #undef DECLARE_CONCRETE_INSTRUCTION 6976 #undef DECLARE_CONCRETE_INSTRUCTION
6959 6977
6960 } } // namespace v8::internal 6978 } } // namespace v8::internal
6961 6979
6962 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ 6980 #endif // V8_HYDROGEN_INSTRUCTIONS_H_
OLDNEW
« no previous file with comments | « src/hydrogen.cc ('k') | src/hydrogen-instructions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698