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

Side by Side Diff: src/objects-inl.h

Issue 11365175: Minor cleanup and optimisation of element methods. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 1 month 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/objects.cc ('k') | no next file » | 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 5028 matching lines...) Expand 10 before | Expand all | Expand 10 after
5039 return GetLocalPropertyAttribute(name) != ABSENT; 5039 return GetLocalPropertyAttribute(name) != ABSENT;
5040 } 5040 }
5041 5041
5042 5042
5043 PropertyAttributes JSReceiver::GetPropertyAttribute(String* key) { 5043 PropertyAttributes JSReceiver::GetPropertyAttribute(String* key) {
5044 return GetPropertyAttributeWithReceiver(this, key); 5044 return GetPropertyAttributeWithReceiver(this, key);
5045 } 5045 }
5046 5046
5047 5047
5048 PropertyAttributes JSReceiver::GetElementAttribute(uint32_t index) { 5048 PropertyAttributes JSReceiver::GetElementAttribute(uint32_t index) {
5049 return GetElementAttributeWithReceiver(this, index, true); 5049 if (IsJSProxy()) {
5050 return JSProxy::cast(this)->GetElementAttributeWithHandler(this, index);
5051 }
5052 return JSObject::cast(this)->GetElementAttributeWithReceiver(
5053 this, index, true);
5050 } 5054 }
5051 5055
5052 5056
5053 // TODO(504): this may be useful in other places too where JSGlobalProxy 5057 // TODO(504): this may be useful in other places too where JSGlobalProxy
5054 // is used. 5058 // is used.
5055 Object* JSObject::BypassGlobalProxy() { 5059 Object* JSObject::BypassGlobalProxy() {
5056 if (IsJSGlobalProxy()) { 5060 if (IsJSGlobalProxy()) {
5057 Object* proto = GetPrototype(); 5061 Object* proto = GetPrototype();
5058 if (proto->IsNull()) return GetHeap()->undefined_value(); 5062 if (proto->IsNull()) return GetHeap()->undefined_value();
5059 ASSERT(proto->IsJSGlobalObject()); 5063 ASSERT(proto->IsJSGlobalObject());
5060 return proto; 5064 return proto;
5061 } 5065 }
5062 return this; 5066 return this;
5063 } 5067 }
5064 5068
5065 5069
5066 MaybeObject* JSReceiver::GetIdentityHash(CreationFlag flag) { 5070 MaybeObject* JSReceiver::GetIdentityHash(CreationFlag flag) {
5067 return IsJSProxy() 5071 return IsJSProxy()
5068 ? JSProxy::cast(this)->GetIdentityHash(flag) 5072 ? JSProxy::cast(this)->GetIdentityHash(flag)
5069 : JSObject::cast(this)->GetIdentityHash(flag); 5073 : JSObject::cast(this)->GetIdentityHash(flag);
5070 } 5074 }
5071 5075
5072 5076
5073 bool JSReceiver::HasElement(uint32_t index) { 5077 bool JSReceiver::HasElement(uint32_t index) {
5074 if (IsJSProxy()) { 5078 if (IsJSProxy()) {
5075 return JSProxy::cast(this)->HasElementWithHandler(index); 5079 return JSProxy::cast(this)->HasElementWithHandler(index);
5076 } 5080 }
5077 return JSObject::cast(this)->GetElementAttribute(index) != ABSENT; 5081 return JSObject::cast(this)->GetElementAttributeWithReceiver(
5082 this, index, true) != ABSENT;
5078 } 5083 }
5079 5084
5080 5085
5081 bool JSReceiver::HasLocalElement(uint32_t index) { 5086 bool JSReceiver::HasLocalElement(uint32_t index) {
5082 if (IsJSProxy()) { 5087 if (IsJSProxy()) {
5083 return JSProxy::cast(this)->HasElementWithHandler(index); 5088 return JSProxy::cast(this)->HasElementWithHandler(index);
5084 } 5089 }
5085 return JSObject::cast(this)->GetLocalElementAttribute(index) != ABSENT; 5090 return JSObject::cast(this)->GetElementAttributeWithReceiver(
5091 this, index, false) != ABSENT;
5086 } 5092 }
5087 5093
5088 5094
5089 PropertyAttributes JSReceiver::GetElementAttributeWithReceiver(
5090 JSReceiver* receiver, uint32_t index, bool continue_search) {
5091 if (IsJSProxy()) {
5092 return JSProxy::cast(this)->GetElementAttributeWithHandler(receiver, index);
5093 }
5094 return JSObject::cast(this)->GetElementAttributeWithReceiver(
5095 receiver, index, continue_search);
5096 }
5097
5098
5099 PropertyAttributes JSReceiver::GetLocalElementAttribute(uint32_t index) { 5095 PropertyAttributes JSReceiver::GetLocalElementAttribute(uint32_t index) {
5100 if (IsJSProxy()) { 5096 if (IsJSProxy()) {
5101 return JSProxy::cast(this)->GetElementAttributeWithHandler(this, index); 5097 return JSProxy::cast(this)->GetElementAttributeWithHandler(this, index);
5102 } 5098 }
5103 return JSObject::cast(this)->GetElementAttributeWithReceiver( 5099 return JSObject::cast(this)->GetElementAttributeWithReceiver(
5104 this, index, false); 5100 this, index, false);
5105 } 5101 }
5106 5102
5107 5103
5108 bool AccessorInfo::all_can_read() { 5104 bool AccessorInfo::all_can_read() {
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
5553 #undef WRITE_UINT32_FIELD 5549 #undef WRITE_UINT32_FIELD
5554 #undef READ_SHORT_FIELD 5550 #undef READ_SHORT_FIELD
5555 #undef WRITE_SHORT_FIELD 5551 #undef WRITE_SHORT_FIELD
5556 #undef READ_BYTE_FIELD 5552 #undef READ_BYTE_FIELD
5557 #undef WRITE_BYTE_FIELD 5553 #undef WRITE_BYTE_FIELD
5558 5554
5559 5555
5560 } } // namespace v8::internal 5556 } } // namespace v8::internal
5561 5557
5562 #endif // V8_OBJECTS_INL_H_ 5558 #endif // V8_OBJECTS_INL_H_
OLDNEW
« no previous file with comments | « src/objects.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698