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

Side by Side Diff: src/objects.h

Issue 9584003: Re-land CL 9466047. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebased. Created 8 years, 9 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/ast.cc ('k') | src/objects.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 2571 matching lines...) Expand 10 before | Expand all | Expand 10 after
2582 2582
2583 // Are two DescriptorArrays equal? 2583 // Are two DescriptorArrays equal?
2584 bool IsEqualTo(DescriptorArray* other); 2584 bool IsEqualTo(DescriptorArray* other);
2585 #endif 2585 #endif
2586 2586
2587 // The maximum number of descriptors we want in a descriptor array (should 2587 // The maximum number of descriptors we want in a descriptor array (should
2588 // fit in a page). 2588 // fit in a page).
2589 static const int kMaxNumberOfDescriptors = 1024 + 512; 2589 static const int kMaxNumberOfDescriptors = 1024 + 512;
2590 2590
2591 private: 2591 private:
2592 // An entry in a DescriptorArray, represented as an (array, index) pair.
2593 class Entry {
2594 public:
2595 inline explicit Entry(DescriptorArray* descs, int index) :
2596 descs_(descs), index_(index) { }
2597
2598 inline PropertyType type() { return descs_->GetType(index_); }
2599 inline Object* GetCallbackObject() { return descs_->GetValue(index_); }
2600
2601 private:
2602 DescriptorArray* descs_;
2603 int index_;
2604 };
2605
2592 // Conversion from descriptor number to array indices. 2606 // Conversion from descriptor number to array indices.
2593 static int ToKeyIndex(int descriptor_number) { 2607 static int ToKeyIndex(int descriptor_number) {
2594 return descriptor_number+kFirstIndex; 2608 return descriptor_number+kFirstIndex;
2595 } 2609 }
2596 2610
2597 static int ToDetailsIndex(int descriptor_number) { 2611 static int ToDetailsIndex(int descriptor_number) {
2598 return (descriptor_number << 1) + 1; 2612 return (descriptor_number << 1) + 1;
2599 } 2613 }
2600 2614
2601 static int ToValueIndex(int descriptor_number) { 2615 static int ToValueIndex(int descriptor_number) {
(...skipping 5313 matching lines...) Expand 10 before | Expand all | Expand 10 after
7915 7929
7916 // TODO(svenpanne) Evil temporary helper, will vanish soon... 7930 // TODO(svenpanne) Evil temporary helper, will vanish soon...
7917 void set(bool modify_getter, Object* value) { 7931 void set(bool modify_getter, Object* value) {
7918 if (modify_getter) { 7932 if (modify_getter) {
7919 set_getter(value); 7933 set_getter(value);
7920 } else { 7934 } else {
7921 set_setter(value); 7935 set_setter(value);
7922 } 7936 }
7923 } 7937 }
7924 7938
7939 bool ContainsAccessor() {
7940 return IsJSAccessor(getter()) || IsJSAccessor(setter());
7941 }
7942
7925 #ifdef OBJECT_PRINT 7943 #ifdef OBJECT_PRINT
7926 void AccessorPairPrint(FILE* out = stdout); 7944 void AccessorPairPrint(FILE* out = stdout);
7927 #endif 7945 #endif
7928 #ifdef DEBUG 7946 #ifdef DEBUG
7929 void AccessorPairVerify(); 7947 void AccessorPairVerify();
7930 #endif 7948 #endif
7931 7949
7932 static const int kGetterOffset = HeapObject::kHeaderSize; 7950 static const int kGetterOffset = HeapObject::kHeaderSize;
7933 static const int kSetterOffset = kGetterOffset + kPointerSize; 7951 static const int kSetterOffset = kGetterOffset + kPointerSize;
7934 static const int kSize = kSetterOffset + kPointerSize; 7952 static const int kSize = kSetterOffset + kPointerSize;
7935 7953
7936 private: 7954 private:
7955 // Strangely enough, in addition to functions and harmony proxies, the spec
7956 // requires us to consider undefined as a kind of accessor, too:
7957 // var obj = {};
7958 // Object.defineProperty(obj, "foo", {get: undefined});
7959 // assertTrue("foo" in obj);
7960 bool IsJSAccessor(Object* obj) {
7961 return obj->IsSpecFunction() || obj->IsUndefined();
7962 }
7963
7937 DISALLOW_IMPLICIT_CONSTRUCTORS(AccessorPair); 7964 DISALLOW_IMPLICIT_CONSTRUCTORS(AccessorPair);
7938 }; 7965 };
7939 7966
7940 7967
7941 class AccessCheckInfo: public Struct { 7968 class AccessCheckInfo: public Struct {
7942 public: 7969 public:
7943 DECL_ACCESSORS(named_callback, Object) 7970 DECL_ACCESSORS(named_callback, Object)
7944 DECL_ACCESSORS(indexed_callback, Object) 7971 DECL_ACCESSORS(indexed_callback, Object)
7945 DECL_ACCESSORS(data, Object) 7972 DECL_ACCESSORS(data, Object)
7946 7973
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
8426 } else { 8453 } else {
8427 value &= ~(1 << bit_position); 8454 value &= ~(1 << bit_position);
8428 } 8455 }
8429 return value; 8456 return value;
8430 } 8457 }
8431 }; 8458 };
8432 8459
8433 } } // namespace v8::internal 8460 } } // namespace v8::internal
8434 8461
8435 #endif // V8_OBJECTS_H_ 8462 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/ast.cc ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698