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

Side by Side Diff: src/types.h

Issue 437393005: Extend some operations to range types. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 4 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 | src/types.cc » ('j') | src/types.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_TYPES_H_ 5 #ifndef V8_TYPES_H_
6 #define V8_TYPES_H_ 6 #define V8_TYPES_H_
7 7
8 #include "src/factory.h" 8 #include "src/factory.h"
9 #include "src/handles.h" 9 #include "src/handles.h"
10 #include "src/ostreams.h" 10 #include "src/ostreams.h"
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 static TypeHandle type(Region* region) { \ 279 static TypeHandle type(Region* region) { \
280 return BitsetType::New(BitsetType::k##type, region); \ 280 return BitsetType::New(BitsetType::k##type, region); \
281 } 281 }
282 BITSET_TYPE_LIST(DEFINE_TYPE_CONSTRUCTOR) 282 BITSET_TYPE_LIST(DEFINE_TYPE_CONSTRUCTOR)
283 #undef DEFINE_TYPE_CONSTRUCTOR 283 #undef DEFINE_TYPE_CONSTRUCTOR
284 284
285 static TypeHandle Class(i::Handle<i::Map> map, Region* region) { 285 static TypeHandle Class(i::Handle<i::Map> map, Region* region) {
286 return ClassType::New(map, region); 286 return ClassType::New(map, region);
287 } 287 }
288 static TypeHandle Constant(i::Handle<i::Object> value, Region* region) { 288 static TypeHandle Constant(i::Handle<i::Object> value, Region* region) {
289 // TODO(neis): return RangeType for numerical values 289 // TODO(neis): Return RangeType for numerical values.
290 return ConstantType::New(value, region); 290 return ConstantType::New(value, region);
291 } 291 }
292 static TypeHandle Range(double min, double max, Region* region) { 292 static TypeHandle Range(double min, double max, Region* region) {
293 return RangeType::New(min, max, region); 293 return RangeType::New(min, max, region);
294 } 294 }
295 static TypeHandle Context(TypeHandle outer, Region* region) { 295 static TypeHandle Context(TypeHandle outer, Region* region) {
296 return ContextType::New(outer, region); 296 return ContextType::New(outer, region);
297 } 297 }
298 static TypeHandle Array(TypeHandle element, Region* region) { 298 static TypeHandle Array(TypeHandle element, Region* region) {
299 return ArrayType::New(element, region); 299 return ArrayType::New(element, region);
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 return (bitset1 | bitset2) == bitset2; 508 return (bitset1 | bitset2) == bitset2;
509 } 509 }
510 510
511 static int Glb(TypeImpl* type); // greatest lower bound that's a bitset 511 static int Glb(TypeImpl* type); // greatest lower bound that's a bitset
512 static int Lub(TypeImpl* type); // least upper bound that's a bitset 512 static int Lub(TypeImpl* type); // least upper bound that's a bitset
513 static int Lub(i::Object* value); 513 static int Lub(i::Object* value);
514 static int Lub(double value); 514 static int Lub(double value);
515 static int Lub(int32_t value); 515 static int Lub(int32_t value);
516 static int Lub(uint32_t value); 516 static int Lub(uint32_t value);
517 static int Lub(i::Map* map); 517 static int Lub(i::Map* map);
518 static int Lub(double min, double max);
518 static int InherentLub(TypeImpl* type); 519 static int InherentLub(TypeImpl* type);
519 520
520 static const char* Name(int bitset); 521 static const char* Name(int bitset);
521 static void Print(OStream& os, int bitset); // NOLINT 522 static void Print(OStream& os, int bitset); // NOLINT
522 using TypeImpl::PrintTo; 523 using TypeImpl::PrintTo;
523 }; 524 };
524 525
525 526
526 // ----------------------------------------------------------------------------- 527 // -----------------------------------------------------------------------------
527 // Superclass for non-bitset types (internal). 528 // Superclass for non-bitset types (internal).
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 681
681 template<class Config> 682 template<class Config>
682 class TypeImpl<Config>::RangeType : public StructuralType { 683 class TypeImpl<Config>::RangeType : public StructuralType {
683 public: 684 public:
684 TypeHandle Bound() { return this->Get(0); } 685 TypeHandle Bound() { return this->Get(0); }
685 double Min() { return this->template GetValue<i::HeapNumber>(1)->value(); } 686 double Min() { return this->template GetValue<i::HeapNumber>(1)->value(); }
686 double Max() { return this->template GetValue<i::HeapNumber>(2)->value(); } 687 double Max() { return this->template GetValue<i::HeapNumber>(2)->value(); }
687 688
688 static RangeHandle New( 689 static RangeHandle New(
689 double min, double max, TypeHandle bound, Region* region) { 690 double min, double max, TypeHandle bound, Region* region) {
690 DCHECK(BitsetType::Is(bound->AsBitset(), BitsetType::kNumber)); 691 DCHECK(BitsetType::Is(bound->AsBitset(), BitsetType::Lub(min, max)));
691 DCHECK(!std::isnan(min) && !std::isnan(max) && min <= max);
692 RangeHandle type = Config::template cast<RangeType>( 692 RangeHandle type = Config::template cast<RangeType>(
693 StructuralType::New(StructuralType::kRangeTag, 3, region)); 693 StructuralType::New(StructuralType::kRangeTag, 3, region));
694 type->Set(0, bound); 694 type->Set(0, bound);
695 Factory* factory = Config::isolate(region)->factory(); 695 Factory* factory = Config::isolate(region)->factory();
696 Handle<HeapNumber> minV = factory->NewHeapNumber(min); 696 Handle<HeapNumber> minV = factory->NewHeapNumber(min);
697 Handle<HeapNumber> maxV = factory->NewHeapNumber(max); 697 Handle<HeapNumber> maxV = factory->NewHeapNumber(max);
698 type->SetValue(1, minV); 698 type->SetValue(1, minV);
699 type->SetValue(2, maxV); 699 type->SetValue(2, maxV);
700 return type; 700 return type;
701 } 701 }
702 702
703 static RangeHandle New(double min, double max, Region* region) { 703 static RangeHandle New(double min, double max, Region* region) {
704 TypeHandle bound = BitsetType::New(BitsetType::kNumber, region); 704 TypeHandle bound = BitsetType::New(BitsetType::Lub(min, max), region);
705 return New(min, max, bound, region); 705 return New(min, max, bound, region);
706 } 706 }
707 707
708 static RangeType* cast(TypeImpl* type) { 708 static RangeType* cast(TypeImpl* type) {
709 DCHECK(type->IsRange()); 709 DCHECK(type->IsRange());
710 return static_cast<RangeType*>(type); 710 return static_cast<RangeType*>(type);
711 } 711 }
712 }; 712 };
713 713
714 714
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
992 bool Narrows(BoundsImpl that) { 992 bool Narrows(BoundsImpl that) {
993 return that.lower->Is(this->lower) && this->upper->Is(that.upper); 993 return that.lower->Is(this->lower) && this->upper->Is(that.upper);
994 } 994 }
995 }; 995 };
996 996
997 typedef BoundsImpl<ZoneTypeConfig> Bounds; 997 typedef BoundsImpl<ZoneTypeConfig> Bounds;
998 998
999 } } // namespace v8::internal 999 } } // namespace v8::internal
1000 1000
1001 #endif // V8_TYPES_H_ 1001 #endif // V8_TYPES_H_
OLDNEW
« no previous file with comments | « no previous file | src/types.cc » ('j') | src/types.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698