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

Side by Side Diff: src/objects.h

Issue 9466047: Handle CALLBACKS correctly in IsProperty functions. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Incorporated review comments. 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 | « no previous file | src/objects-inl.h » ('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 5310 matching lines...) Expand 10 before | Expand all | Expand 10 after
7912 7926
7913 // TODO(svenpanne) Evil temporary helper, will vanish soon... 7927 // TODO(svenpanne) Evil temporary helper, will vanish soon...
7914 void set(bool modify_getter, Object* value) { 7928 void set(bool modify_getter, Object* value) {
7915 if (modify_getter) { 7929 if (modify_getter) {
7916 set_getter(value); 7930 set_getter(value);
7917 } else { 7931 } else {
7918 set_setter(value); 7932 set_setter(value);
7919 } 7933 }
7920 } 7934 }
7921 7935
7936 bool ContainsAccessor() {
7937 return IsJSAccessor(getter()) || IsJSAccessor(setter());
7938 }
7939
7922 #ifdef OBJECT_PRINT 7940 #ifdef OBJECT_PRINT
7923 void AccessorPairPrint(FILE* out = stdout); 7941 void AccessorPairPrint(FILE* out = stdout);
7924 #endif 7942 #endif
7925 #ifdef DEBUG 7943 #ifdef DEBUG
7926 void AccessorPairVerify(); 7944 void AccessorPairVerify();
7927 #endif 7945 #endif
7928 7946
7929 static const int kGetterOffset = HeapObject::kHeaderSize; 7947 static const int kGetterOffset = HeapObject::kHeaderSize;
7930 static const int kSetterOffset = kGetterOffset + kPointerSize; 7948 static const int kSetterOffset = kGetterOffset + kPointerSize;
7931 static const int kSize = kSetterOffset + kPointerSize; 7949 static const int kSize = kSetterOffset + kPointerSize;
7932 7950
7933 private: 7951 private:
7952 // Strangely enough, in addition to functions and harmony proxies, the spec
7953 // requires us to consider undefined as a kind of accessor, too:
7954 // var obj = {};
7955 // Object.defineProperty(obj, "foo", {get: undefined});
7956 // assertTrue("foo" in obj);
7957 bool IsJSAccessor(Object* obj) {
7958 return obj->IsSpecFunction() || obj->IsUndefined();
7959 }
7960
7934 DISALLOW_IMPLICIT_CONSTRUCTORS(AccessorPair); 7961 DISALLOW_IMPLICIT_CONSTRUCTORS(AccessorPair);
7935 }; 7962 };
7936 7963
7937 7964
7938 class AccessCheckInfo: public Struct { 7965 class AccessCheckInfo: public Struct {
7939 public: 7966 public:
7940 DECL_ACCESSORS(named_callback, Object) 7967 DECL_ACCESSORS(named_callback, Object)
7941 DECL_ACCESSORS(indexed_callback, Object) 7968 DECL_ACCESSORS(indexed_callback, Object)
7942 DECL_ACCESSORS(data, Object) 7969 DECL_ACCESSORS(data, Object)
7943 7970
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
8423 } else { 8450 } else {
8424 value &= ~(1 << bit_position); 8451 value &= ~(1 << bit_position);
8425 } 8452 }
8426 return value; 8453 return value;
8427 } 8454 }
8428 }; 8455 };
8429 8456
8430 } } // namespace v8::internal 8457 } } // namespace v8::internal
8431 8458
8432 #endif // V8_OBJECTS_H_ 8459 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « no previous file | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698