Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 299 bool MulAndCheckOverflow(const Representation& r, Range* other); | 299 bool MulAndCheckOverflow(const Representation& r, Range* other); |
| 300 | 300 |
| 301 private: | 301 private: |
| 302 int32_t lower_; | 302 int32_t lower_; |
| 303 int32_t upper_; | 303 int32_t upper_; |
| 304 Range* next_; | 304 Range* next_; |
| 305 bool can_be_minus_zero_; | 305 bool can_be_minus_zero_; |
| 306 }; | 306 }; |
| 307 | 307 |
| 308 | 308 |
| 309 class UniqueValueId V8_FINAL { | |
| 310 public: | |
| 311 UniqueValueId() : raw_address_(NULL) { } | |
| 312 | |
| 313 explicit UniqueValueId(Handle<Object> handle) { | |
| 314 ASSERT(!AllowHeapAllocation::IsAllowed()); | |
| 315 static const Address kEmptyHandleSentinel = reinterpret_cast<Address>(1); | |
| 316 if (handle.is_null()) { | |
| 317 raw_address_ = kEmptyHandleSentinel; | |
| 318 } else { | |
| 319 raw_address_ = reinterpret_cast<Address>(*handle); | |
| 320 ASSERT_NE(kEmptyHandleSentinel, raw_address_); | |
| 321 } | |
| 322 ASSERT(IsInitialized()); | |
| 323 } | |
| 324 | |
| 325 bool IsInitialized() const { return raw_address_ != NULL; } | |
| 326 | |
| 327 bool operator==(const UniqueValueId& other) const { | |
| 328 ASSERT(IsInitialized() && other.IsInitialized()); | |
| 329 return raw_address_ == other.raw_address_; | |
| 330 } | |
| 331 | |
| 332 bool operator!=(const UniqueValueId& other) const { | |
| 333 ASSERT(IsInitialized() && other.IsInitialized()); | |
| 334 return raw_address_ != other.raw_address_; | |
| 335 } | |
| 336 | |
| 337 intptr_t Hashcode() const { | |
| 338 ASSERT(IsInitialized()); | |
| 339 return reinterpret_cast<intptr_t>(raw_address_); | |
| 340 } | |
| 341 | |
| 342 #define IMMOVABLE_UNIQUE_VALUE_ID(name) \ | |
| 343 static UniqueValueId name(Heap* heap) { return UniqueValueId(heap->name()); } | |
| 344 | |
| 345 IMMOVABLE_UNIQUE_VALUE_ID(free_space_map) | |
| 346 IMMOVABLE_UNIQUE_VALUE_ID(minus_zero_value) | |
| 347 IMMOVABLE_UNIQUE_VALUE_ID(nan_value) | |
| 348 IMMOVABLE_UNIQUE_VALUE_ID(undefined_value) | |
| 349 IMMOVABLE_UNIQUE_VALUE_ID(null_value) | |
| 350 IMMOVABLE_UNIQUE_VALUE_ID(true_value) | |
| 351 IMMOVABLE_UNIQUE_VALUE_ID(false_value) | |
| 352 IMMOVABLE_UNIQUE_VALUE_ID(the_hole_value) | |
| 353 IMMOVABLE_UNIQUE_VALUE_ID(empty_string) | |
| 354 IMMOVABLE_UNIQUE_VALUE_ID(empty_fixed_array) | |
| 355 | |
| 356 #undef IMMOVABLE_UNIQUE_VALUE_ID | |
| 357 | |
| 358 private: | |
| 359 Address raw_address_; | |
| 360 | |
| 361 explicit UniqueValueId(Object* object) { | |
| 362 raw_address_ = reinterpret_cast<Address>(object); | |
| 363 ASSERT(IsInitialized()); | |
| 364 } | |
| 365 }; | |
| 366 | |
| 367 | |
| 368 class HType V8_FINAL { | 309 class HType V8_FINAL { |
| 369 public: | 310 public: |
| 370 static HType None() { return HType(kNone); } | 311 static HType None() { return HType(kNone); } |
| 371 static HType Tagged() { return HType(kTagged); } | 312 static HType Tagged() { return HType(kTagged); } |
| 372 static HType TaggedPrimitive() { return HType(kTaggedPrimitive); } | 313 static HType TaggedPrimitive() { return HType(kTaggedPrimitive); } |
| 373 static HType TaggedNumber() { return HType(kTaggedNumber); } | 314 static HType TaggedNumber() { return HType(kTaggedNumber); } |
| 374 static HType Smi() { return HType(kSmi); } | 315 static HType Smi() { return HType(kSmi); } |
| 375 static HType HeapNumber() { return HType(kHeapNumber); } | 316 static HType HeapNumber() { return HType(kHeapNumber); } |
| 376 static HType String() { return HType(kString); } | 317 static HType String() { return HType(kString); } |
| 377 static HType Boolean() { return HType(kBoolean); } | 318 static HType Boolean() { return HType(kBoolean); } |
| (...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 897 // This gives the instruction an opportunity to replace itself with an | 838 // This gives the instruction an opportunity to replace itself with an |
| 898 // instruction that does the same in some better way. To replace an | 839 // instruction that does the same in some better way. To replace an |
| 899 // instruction with a new one, first add the new instruction to the graph, | 840 // instruction with a new one, first add the new instruction to the graph, |
| 900 // then return it. Return NULL to have the instruction deleted. | 841 // then return it. Return NULL to have the instruction deleted. |
| 901 virtual HValue* Canonicalize() { return this; } | 842 virtual HValue* Canonicalize() { return this; } |
| 902 | 843 |
| 903 bool Equals(HValue* other); | 844 bool Equals(HValue* other); |
| 904 virtual intptr_t Hashcode(); | 845 virtual intptr_t Hashcode(); |
| 905 | 846 |
| 906 // Compute unique ids upfront that is safe wrt GC and concurrent compilation. | 847 // Compute unique ids upfront that is safe wrt GC and concurrent compilation. |
| 907 virtual void FinalizeUniqueValueId() { } | 848 virtual void FinalizeUniqueness() { } |
| 908 | 849 |
| 909 // Printing support. | 850 // Printing support. |
| 910 virtual void PrintTo(StringStream* stream) = 0; | 851 virtual void PrintTo(StringStream* stream) = 0; |
| 911 void PrintNameTo(StringStream* stream); | 852 void PrintNameTo(StringStream* stream); |
| 912 void PrintTypeTo(StringStream* stream); | 853 void PrintTypeTo(StringStream* stream); |
| 913 void PrintRangeTo(StringStream* stream); | 854 void PrintRangeTo(StringStream* stream); |
| 914 void PrintChangesTo(StringStream* stream); | 855 void PrintChangesTo(StringStream* stream); |
| 915 | 856 |
| 916 const char* Mnemonic() const; | 857 const char* Mnemonic() const; |
| 917 | 858 |
| (...skipping 1766 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2684 Unique<JSFunction> target = Unique<JSFunction>::CreateUninitialized(func); | 2625 Unique<JSFunction> target = Unique<JSFunction>::CreateUninitialized(func); |
| 2685 HCheckValue* check = new(zone) HCheckValue(value, target, in_new_space); | 2626 HCheckValue* check = new(zone) HCheckValue(value, target, in_new_space); |
| 2686 return check; | 2627 return check; |
| 2687 } | 2628 } |
| 2688 static HCheckValue* New(Zone* zone, HValue* context, | 2629 static HCheckValue* New(Zone* zone, HValue* context, |
| 2689 HValue* value, Unique<HeapObject> target, | 2630 HValue* value, Unique<HeapObject> target, |
| 2690 bool object_in_new_space) { | 2631 bool object_in_new_space) { |
| 2691 return new(zone) HCheckValue(value, target, object_in_new_space); | 2632 return new(zone) HCheckValue(value, target, object_in_new_space); |
| 2692 } | 2633 } |
| 2693 | 2634 |
| 2694 virtual void FinalizeUniqueValueId() V8_OVERRIDE { | 2635 virtual void FinalizeUniqueness() V8_OVERRIDE { |
| 2695 object_ = Unique<HeapObject>(object_.handle()); | 2636 object_ = Unique<HeapObject>(object_.handle()); |
| 2696 } | 2637 } |
| 2697 | 2638 |
| 2698 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { | 2639 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { |
| 2699 return Representation::Tagged(); | 2640 return Representation::Tagged(); |
| 2700 } | 2641 } |
| 2701 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE; | 2642 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE; |
| 2702 | 2643 |
| 2703 virtual HValue* Canonicalize() V8_OVERRIDE; | 2644 virtual HValue* Canonicalize() V8_OVERRIDE; |
| 2704 | 2645 |
| (...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3290 int capture_id_; | 3231 int capture_id_; |
| 3291 }; | 3232 }; |
| 3292 | 3233 |
| 3293 | 3234 |
| 3294 class HConstant V8_FINAL : public HTemplateInstruction<0> { | 3235 class HConstant V8_FINAL : public HTemplateInstruction<0> { |
| 3295 public: | 3236 public: |
| 3296 DECLARE_INSTRUCTION_FACTORY_P1(HConstant, int32_t); | 3237 DECLARE_INSTRUCTION_FACTORY_P1(HConstant, int32_t); |
| 3297 DECLARE_INSTRUCTION_FACTORY_P2(HConstant, int32_t, Representation); | 3238 DECLARE_INSTRUCTION_FACTORY_P2(HConstant, int32_t, Representation); |
| 3298 DECLARE_INSTRUCTION_FACTORY_P1(HConstant, double); | 3239 DECLARE_INSTRUCTION_FACTORY_P1(HConstant, double); |
| 3299 DECLARE_INSTRUCTION_FACTORY_P1(HConstant, Handle<Object>); | 3240 DECLARE_INSTRUCTION_FACTORY_P1(HConstant, Handle<Object>); |
| 3300 DECLARE_INSTRUCTION_FACTORY_P2(HConstant, Handle<Map>, UniqueValueId); | |
| 3301 DECLARE_INSTRUCTION_FACTORY_P1(HConstant, ExternalReference); | 3241 DECLARE_INSTRUCTION_FACTORY_P1(HConstant, ExternalReference); |
| 3302 | 3242 |
| 3303 static HConstant* CreateAndInsertAfter(Zone* zone, | 3243 static HConstant* CreateAndInsertAfter(Zone* zone, |
| 3304 HValue* context, | 3244 HValue* context, |
| 3305 int32_t value, | 3245 int32_t value, |
| 3306 Representation representation, | 3246 Representation representation, |
| 3307 HInstruction* instruction) { | 3247 HInstruction* instruction) { |
| 3308 HConstant* new_constant = | 3248 HConstant* new_constant = |
| 3309 HConstant::New(zone, context, value, representation); | 3249 HConstant::New(zone, context, value, representation); |
| 3310 new_constant->InsertAfter(instruction); | 3250 new_constant->InsertAfter(instruction); |
| 3311 return new_constant; | 3251 return new_constant; |
| 3312 } | 3252 } |
| 3313 | 3253 |
| 3314 static HConstant* CreateAndInsertBefore(Zone* zone, | 3254 static HConstant* CreateAndInsertBefore(Zone* zone, |
| 3315 HValue* context, | 3255 HValue* context, |
| 3316 int32_t value, | 3256 int32_t value, |
| 3317 Representation representation, | 3257 Representation representation, |
| 3318 HInstruction* instruction) { | 3258 HInstruction* instruction) { |
| 3319 HConstant* new_constant = | 3259 HConstant* new_constant = |
| 3320 HConstant::New(zone, context, value, representation); | 3260 HConstant::New(zone, context, value, representation); |
| 3321 new_constant->InsertBefore(instruction); | 3261 new_constant->InsertBefore(instruction); |
| 3322 return new_constant; | 3262 return new_constant; |
| 3323 } | 3263 } |
| 3324 | 3264 |
| 3325 Handle<Object> handle(Isolate* isolate) { | 3265 Handle<Object> handle(Isolate* isolate) { |
| 3326 if (handle_.is_null()) { | 3266 if (object_.handle().is_null()) { |
| 3327 Factory* factory = isolate->factory(); | |
| 3328 // Default arguments to is_not_in_new_space depend on this heap number | 3267 // Default arguments to is_not_in_new_space depend on this heap number |
| 3329 // to be tenured so that it's guaranteed not be be located in new space. | 3268 // to be tenured so that it's guaranteed not to be located in new space. |
| 3330 handle_ = factory->NewNumber(double_value_, TENURED); | 3269 object_ = Unique<Object>::CreateUninitialized( |
| 3270 isolate->factory()->NewNumber(double_value_, TENURED)); | |
| 3331 } | 3271 } |
| 3332 AllowDeferredHandleDereference smi_check; | 3272 AllowDeferredHandleDereference smi_check; |
| 3333 ASSERT(has_int32_value_ || !handle_->IsSmi()); | 3273 ASSERT(has_int32_value_ || !object_.handle()->IsSmi()); |
| 3334 return handle_; | 3274 return object_.handle(); |
| 3335 } | 3275 } |
| 3336 | 3276 |
| 3337 bool HasMap(Handle<Map> map) { | 3277 bool HasMap(Handle<Map> map) { |
| 3338 Handle<Object> constant_object = handle(map->GetIsolate()); | 3278 Handle<Object> constant_object = handle(map->GetIsolate()); |
| 3339 return constant_object->IsHeapObject() && | 3279 return constant_object->IsHeapObject() && |
| 3340 Handle<HeapObject>::cast(constant_object)->map() == *map; | 3280 Handle<HeapObject>::cast(constant_object)->map() == *map; |
| 3341 } | 3281 } |
| 3342 | 3282 |
| 3343 bool IsSpecialDouble() const { | 3283 bool IsSpecialDouble() const { |
| 3344 return has_double_value_ && | 3284 return has_double_value_ && |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 3358 if (has_double_value_) { | 3298 if (has_double_value_) { |
| 3359 if (IsSpecialDouble()) { | 3299 if (IsSpecialDouble()) { |
| 3360 return true; | 3300 return true; |
| 3361 } | 3301 } |
| 3362 return false; | 3302 return false; |
| 3363 } | 3303 } |
| 3364 if (has_external_reference_value_) { | 3304 if (has_external_reference_value_) { |
| 3365 return false; | 3305 return false; |
| 3366 } | 3306 } |
| 3367 | 3307 |
| 3368 ASSERT(!handle_.is_null()); | 3308 ASSERT(!object_.handle().is_null()); |
| 3369 Heap* heap = isolate()->heap(); | 3309 Heap* heap = isolate()->heap(); |
| 3370 ASSERT(unique_id_ != UniqueValueId::minus_zero_value(heap)); | 3310 ASSERT(!object_.IsKnownGlobal(heap->minus_zero_value())); |
| 3371 ASSERT(unique_id_ != UniqueValueId::nan_value(heap)); | 3311 ASSERT(!object_.IsKnownGlobal(heap->nan_value())); |
| 3372 return unique_id_ == UniqueValueId::undefined_value(heap) || | 3312 return |
| 3373 unique_id_ == UniqueValueId::null_value(heap) || | 3313 object_.IsKnownGlobal(heap->undefined_value()) || |
| 3374 unique_id_ == UniqueValueId::true_value(heap) || | 3314 object_.IsKnownGlobal(heap->null_value()) || |
| 3375 unique_id_ == UniqueValueId::false_value(heap) || | 3315 object_.IsKnownGlobal(heap->true_value()) || |
| 3376 unique_id_ == UniqueValueId::the_hole_value(heap) || | 3316 object_.IsKnownGlobal(heap->false_value()) || |
| 3377 unique_id_ == UniqueValueId::empty_string(heap) || | 3317 object_.IsKnownGlobal(heap->the_hole_value()) || |
| 3378 unique_id_ == UniqueValueId::empty_fixed_array(heap); | 3318 object_.IsKnownGlobal(heap->empty_string()) || |
| 3319 object_.IsKnownGlobal(heap->empty_fixed_array()); | |
| 3379 } | 3320 } |
| 3380 | 3321 |
| 3381 bool IsCell() const { | 3322 bool IsCell() const { |
| 3382 return is_cell_; | 3323 return is_cell_; |
| 3383 } | 3324 } |
| 3384 | 3325 |
| 3385 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { | 3326 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { |
| 3386 return Representation::None(); | 3327 return Representation::None(); |
| 3387 } | 3328 } |
| 3388 | 3329 |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 3407 bool HasSmiValue() const { return has_smi_value_; } | 3348 bool HasSmiValue() const { return has_smi_value_; } |
| 3408 bool HasDoubleValue() const { return has_double_value_; } | 3349 bool HasDoubleValue() const { return has_double_value_; } |
| 3409 double DoubleValue() const { | 3350 double DoubleValue() const { |
| 3410 ASSERT(HasDoubleValue()); | 3351 ASSERT(HasDoubleValue()); |
| 3411 return double_value_; | 3352 return double_value_; |
| 3412 } | 3353 } |
| 3413 bool IsTheHole() const { | 3354 bool IsTheHole() const { |
| 3414 if (HasDoubleValue() && FixedDoubleArray::is_the_hole_nan(double_value_)) { | 3355 if (HasDoubleValue() && FixedDoubleArray::is_the_hole_nan(double_value_)) { |
| 3415 return true; | 3356 return true; |
| 3416 } | 3357 } |
| 3417 Heap* heap = isolate()->heap(); | 3358 return object_.IsKnownGlobal(isolate()->heap()->the_hole_value()); |
| 3418 if (!handle_.is_null() && *handle_ == heap->the_hole_value()) { | |
| 3419 return true; | |
| 3420 } | |
| 3421 return false; | |
| 3422 } | 3359 } |
| 3423 bool HasNumberValue() const { return has_double_value_; } | 3360 bool HasNumberValue() const { return has_double_value_; } |
| 3424 int32_t NumberValueAsInteger32() const { | 3361 int32_t NumberValueAsInteger32() const { |
| 3425 ASSERT(HasNumberValue()); | 3362 ASSERT(HasNumberValue()); |
| 3426 // Irrespective of whether a numeric HConstant can be safely | 3363 // Irrespective of whether a numeric HConstant can be safely |
| 3427 // represented as an int32, we store the (in some cases lossy) | 3364 // represented as an int32, we store the (in some cases lossy) |
| 3428 // representation of the number in int32_value_. | 3365 // representation of the number in int32_value_. |
| 3429 return int32_value_; | 3366 return int32_value_; |
| 3430 } | 3367 } |
| 3431 bool HasStringValue() const { | 3368 bool HasStringValue() const { |
| 3432 if (has_double_value_ || has_int32_value_) return false; | 3369 if (has_double_value_ || has_int32_value_) return false; |
| 3433 ASSERT(!handle_.is_null()); | 3370 ASSERT(!object_.handle().is_null()); |
| 3434 return type_.IsString(); | 3371 return type_.IsString(); |
| 3435 } | 3372 } |
| 3436 Handle<String> StringValue() const { | 3373 Handle<String> StringValue() const { |
| 3437 ASSERT(HasStringValue()); | 3374 ASSERT(HasStringValue()); |
| 3438 return Handle<String>::cast(handle_); | 3375 return Handle<String>::cast(object_.handle()); |
| 3439 } | 3376 } |
| 3440 bool HasInternalizedStringValue() const { | 3377 bool HasInternalizedStringValue() const { |
| 3441 return HasStringValue() && is_internalized_string_; | 3378 return HasStringValue() && is_internalized_string_; |
| 3442 } | 3379 } |
| 3443 | 3380 |
| 3444 bool HasExternalReferenceValue() const { | 3381 bool HasExternalReferenceValue() const { |
| 3445 return has_external_reference_value_; | 3382 return has_external_reference_value_; |
| 3446 } | 3383 } |
| 3447 ExternalReference ExternalReferenceValue() const { | 3384 ExternalReference ExternalReferenceValue() const { |
| 3448 return external_reference_value_; | 3385 return external_reference_value_; |
| 3449 } | 3386 } |
| 3450 | 3387 |
| 3451 bool HasBooleanValue() const { return type_.IsBoolean(); } | 3388 bool HasBooleanValue() const { return type_.IsBoolean(); } |
| 3452 bool BooleanValue() const { return boolean_value_; } | 3389 bool BooleanValue() const { return boolean_value_; } |
| 3453 | 3390 |
| 3454 virtual intptr_t Hashcode() V8_OVERRIDE { | 3391 virtual intptr_t Hashcode() V8_OVERRIDE { |
| 3455 if (has_int32_value_) { | 3392 if (has_int32_value_) { |
| 3456 return static_cast<intptr_t>(int32_value_); | 3393 return static_cast<intptr_t>(int32_value_); |
| 3457 } else if (has_double_value_) { | 3394 } else if (has_double_value_) { |
| 3458 return static_cast<intptr_t>(BitCast<int64_t>(double_value_)); | 3395 return static_cast<intptr_t>(BitCast<int64_t>(double_value_)); |
| 3459 } else if (has_external_reference_value_) { | 3396 } else if (has_external_reference_value_) { |
| 3460 return reinterpret_cast<intptr_t>(external_reference_value_.address()); | 3397 return reinterpret_cast<intptr_t>(external_reference_value_.address()); |
| 3461 } else { | 3398 } else { |
| 3462 ASSERT(!handle_.is_null()); | 3399 ASSERT(!object_.handle().is_null()); |
| 3463 return unique_id_.Hashcode(); | 3400 return object_.Hashcode(); |
| 3464 } | 3401 } |
| 3465 } | 3402 } |
| 3466 | 3403 |
| 3467 virtual void FinalizeUniqueValueId() V8_OVERRIDE { | 3404 virtual void FinalizeUniqueness() V8_OVERRIDE { |
| 3468 if (!has_double_value_ && !has_external_reference_value_) { | 3405 if (!has_double_value_ && !has_external_reference_value_) { |
| 3469 ASSERT(!handle_.is_null()); | 3406 ASSERT(!object_.handle().is_null()); |
| 3470 unique_id_ = UniqueValueId(handle_); | 3407 object_ = Unique<Object>(object_.handle()); |
| 3471 } | 3408 } |
| 3472 } | 3409 } |
| 3473 | 3410 |
| 3474 bool UniqueValueIdsMatch(UniqueValueId other) { | |
| 3475 return !has_double_value_ && !has_external_reference_value_ && | |
| 3476 unique_id_ == other; | |
| 3477 } | |
| 3478 | |
| 3479 Unique<Object> GetUnique() const { | 3411 Unique<Object> GetUnique() const { |
| 3480 // TODO(titzer): store a Unique<HeapObject> inside the HConstant. | 3412 return object_; |
| 3481 Address raw_address = reinterpret_cast<Address>(unique_id_.Hashcode()); | |
| 3482 return Unique<Object>(raw_address, handle_); | |
| 3483 } | 3413 } |
| 3484 | 3414 |
| 3485 #ifdef DEBUG | 3415 #ifdef DEBUG |
| 3486 virtual void Verify() V8_OVERRIDE { } | 3416 virtual void Verify() V8_OVERRIDE { } |
| 3487 #endif | 3417 #endif |
| 3488 | 3418 |
| 3489 DECLARE_CONCRETE_INSTRUCTION(Constant) | 3419 DECLARE_CONCRETE_INSTRUCTION(Constant) |
| 3490 | 3420 |
| 3491 protected: | 3421 protected: |
| 3492 virtual Range* InferRange(Zone* zone) V8_OVERRIDE; | 3422 virtual Range* InferRange(Zone* zone) V8_OVERRIDE; |
| 3493 | 3423 |
| 3494 virtual bool DataEquals(HValue* other) V8_OVERRIDE { | 3424 virtual bool DataEquals(HValue* other) V8_OVERRIDE { |
| 3495 HConstant* other_constant = HConstant::cast(other); | 3425 HConstant* other_constant = HConstant::cast(other); |
| 3496 if (has_int32_value_) { | 3426 if (has_int32_value_) { |
| 3497 return other_constant->has_int32_value_ && | 3427 return other_constant->has_int32_value_ && |
| 3498 int32_value_ == other_constant->int32_value_; | 3428 int32_value_ == other_constant->int32_value_; |
| 3499 } else if (has_double_value_) { | 3429 } else if (has_double_value_) { |
| 3500 return other_constant->has_double_value_ && | 3430 return other_constant->has_double_value_ && |
| 3501 BitCast<int64_t>(double_value_) == | 3431 BitCast<int64_t>(double_value_) == |
| 3502 BitCast<int64_t>(other_constant->double_value_); | 3432 BitCast<int64_t>(other_constant->double_value_); |
| 3503 } else if (has_external_reference_value_) { | 3433 } else if (has_external_reference_value_) { |
| 3504 return other_constant->has_external_reference_value_ && | 3434 return other_constant->has_external_reference_value_ && |
| 3505 external_reference_value_ == | 3435 external_reference_value_ == |
| 3506 other_constant->external_reference_value_; | 3436 other_constant->external_reference_value_; |
| 3507 } else { | 3437 } else { |
| 3508 ASSERT(!handle_.is_null()); | 3438 ASSERT(!object_.handle().is_null()); |
| 3509 return !other_constant->handle_.is_null() && | 3439 return other_constant->object_ == object_; |
| 3510 unique_id_ == other_constant->unique_id_; | |
| 3511 } | 3440 } |
| 3512 } | 3441 } |
| 3513 | 3442 |
| 3514 private: | 3443 private: |
| 3515 friend class HGraph; | 3444 friend class HGraph; |
| 3516 HConstant(Handle<Object> handle, Representation r = Representation::None()); | 3445 HConstant(Handle<Object> handle, Representation r = Representation::None()); |
| 3517 HConstant(int32_t value, | 3446 HConstant(int32_t value, |
| 3518 Representation r = Representation::None(), | 3447 Representation r = Representation::None(), |
| 3519 bool is_not_in_new_space = true, | 3448 bool is_not_in_new_space = true, |
| 3520 Handle<Object> optional_handle = Handle<Object>::null()); | 3449 Unique<Object> optional = Unique<Object>(Handle<Object>::null())); |
| 3521 HConstant(double value, | 3450 HConstant(double value, |
| 3522 Representation r = Representation::None(), | 3451 Representation r = Representation::None(), |
| 3523 bool is_not_in_new_space = true, | 3452 bool is_not_in_new_space = true, |
| 3524 Handle<Object> optional_handle = Handle<Object>::null()); | 3453 Unique<Object> optional = Unique<Object>(Handle<Object>::null())); |
| 3525 HConstant(Handle<Object> handle, | 3454 HConstant(Unique<Object> unique, |
| 3526 UniqueValueId unique_id, | |
| 3527 Representation r, | 3455 Representation r, |
| 3528 HType type, | 3456 HType type, |
| 3529 bool is_internalized_string, | 3457 bool is_internalized_string, |
| 3530 bool is_not_in_new_space, | 3458 bool is_not_in_new_space, |
| 3531 bool is_cell, | 3459 bool is_cell, |
| 3532 bool boolean_value); | 3460 bool boolean_value); |
| 3533 HConstant(Handle<Map> handle, | 3461 |
| 3534 UniqueValueId unique_id); | |
| 3535 explicit HConstant(ExternalReference reference); | 3462 explicit HConstant(ExternalReference reference); |
| 3536 | 3463 |
| 3537 void Initialize(Representation r); | 3464 void Initialize(Representation r); |
| 3538 | 3465 |
| 3539 virtual bool IsDeletable() const V8_OVERRIDE { return true; } | 3466 virtual bool IsDeletable() const V8_OVERRIDE { return true; } |
| 3540 | 3467 |
| 3541 // If this is a numerical constant, handle_ either points to to the | 3468 // If this is a numerical constant, object_ either points to to the |
|
Toon Verwaest
2013/09/24 09:17:54
points to to the -> points to the
| |
| 3542 // HeapObject the constant originated from or is null. If the | 3469 // HeapObject the constant originated from or is null. If the |
| 3543 // constant is non-numeric, handle_ always points to a valid | 3470 // constant is non-numeric, object_ always points to a valid |
| 3544 // constant HeapObject. | 3471 // constant HeapObject. |
| 3545 Handle<Object> handle_; | 3472 Unique<Object> object_; |
| 3546 UniqueValueId unique_id_; | |
| 3547 | 3473 |
| 3548 // We store the HConstant in the most specific form safely possible. | 3474 // We store the HConstant in the most specific form safely possible. |
| 3549 // The two flags, has_int32_value_ and has_double_value_ tell us if | 3475 // The two flags, has_int32_value_ and has_double_value_ tell us if |
| 3550 // int32_value_ and double_value_ hold valid, safe representations | 3476 // int32_value_ and double_value_ hold valid, safe representations |
| 3551 // of the constant. has_int32_value_ implies has_double_value_ but | 3477 // of the constant. has_int32_value_ implies has_double_value_ but |
| 3552 // not the converse. | 3478 // not the converse. |
| 3553 bool has_smi_value_ : 1; | 3479 bool has_smi_value_ : 1; |
| 3554 bool has_int32_value_ : 1; | 3480 bool has_int32_value_ : 1; |
| 3555 bool has_double_value_ : 1; | 3481 bool has_double_value_ : 1; |
| 3556 bool has_external_reference_value_ : 1; | 3482 bool has_external_reference_value_ : 1; |
| (...skipping 1573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5130 | 5056 |
| 5131 Unique<Cell> cell() const { return cell_; } | 5057 Unique<Cell> cell() const { return cell_; } |
| 5132 bool RequiresHoleCheck() const; | 5058 bool RequiresHoleCheck() const; |
| 5133 | 5059 |
| 5134 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE; | 5060 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE; |
| 5135 | 5061 |
| 5136 virtual intptr_t Hashcode() V8_OVERRIDE { | 5062 virtual intptr_t Hashcode() V8_OVERRIDE { |
| 5137 return cell_.Hashcode(); | 5063 return cell_.Hashcode(); |
| 5138 } | 5064 } |
| 5139 | 5065 |
| 5140 virtual void FinalizeUniqueValueId() V8_OVERRIDE { | 5066 virtual void FinalizeUniqueness() V8_OVERRIDE { |
| 5141 cell_ = Unique<Cell>(cell_.handle()); | 5067 cell_ = Unique<Cell>(cell_.handle()); |
| 5142 } | 5068 } |
| 5143 | 5069 |
| 5144 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { | 5070 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { |
| 5145 return Representation::None(); | 5071 return Representation::None(); |
| 5146 } | 5072 } |
| 5147 | 5073 |
| 5148 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell) | 5074 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell) |
| 5149 | 5075 |
| 5150 protected: | 5076 protected: |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5428 Handle<PropertyCell>, PropertyDetails); | 5354 Handle<PropertyCell>, PropertyDetails); |
| 5429 | 5355 |
| 5430 Unique<PropertyCell> cell() const { return cell_; } | 5356 Unique<PropertyCell> cell() const { return cell_; } |
| 5431 bool RequiresHoleCheck() { | 5357 bool RequiresHoleCheck() { |
| 5432 return !details_.IsDontDelete() || details_.IsReadOnly(); | 5358 return !details_.IsDontDelete() || details_.IsReadOnly(); |
| 5433 } | 5359 } |
| 5434 bool NeedsWriteBarrier() { | 5360 bool NeedsWriteBarrier() { |
| 5435 return StoringValueNeedsWriteBarrier(value()); | 5361 return StoringValueNeedsWriteBarrier(value()); |
| 5436 } | 5362 } |
| 5437 | 5363 |
| 5438 virtual void FinalizeUniqueValueId() V8_OVERRIDE { | 5364 virtual void FinalizeUniqueness() V8_OVERRIDE { |
| 5439 cell_ = Unique<PropertyCell>(cell_.handle()); | 5365 cell_ = Unique<PropertyCell>(cell_.handle()); |
| 5440 } | 5366 } |
| 5441 | 5367 |
| 5442 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { | 5368 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { |
| 5443 return Representation::Tagged(); | 5369 return Representation::Tagged(); |
| 5444 } | 5370 } |
| 5445 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE; | 5371 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE; |
| 5446 | 5372 |
| 5447 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell) | 5373 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell) |
| 5448 | 5374 |
| (...skipping 1615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7064 virtual bool IsDeletable() const V8_OVERRIDE { return true; } | 6990 virtual bool IsDeletable() const V8_OVERRIDE { return true; } |
| 7065 }; | 6991 }; |
| 7066 | 6992 |
| 7067 | 6993 |
| 7068 #undef DECLARE_INSTRUCTION | 6994 #undef DECLARE_INSTRUCTION |
| 7069 #undef DECLARE_CONCRETE_INSTRUCTION | 6995 #undef DECLARE_CONCRETE_INSTRUCTION |
| 7070 | 6996 |
| 7071 } } // namespace v8::internal | 6997 } } // namespace v8::internal |
| 7072 | 6998 |
| 7073 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ | 6999 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ |
| OLD | NEW |