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

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

Issue 235083002: Reland "Handlify GetProperty." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: fix Created 6 years, 8 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/objects.cc ('k') | src/runtime.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 1063 matching lines...) Expand 10 before | Expand all | Expand 10 after
1074 } 1074 }
1075 return Failure::Exception(); 1075 return Failure::Exception();
1076 } 1076 }
1077 1077
1078 1078
1079 bool Object::HasSpecificClassOf(String* name) { 1079 bool Object::HasSpecificClassOf(String* name) {
1080 return this->IsJSObject() && (JSObject::cast(this)->class_name() == name); 1080 return this->IsJSObject() && (JSObject::cast(this)->class_name() == name);
1081 } 1081 }
1082 1082
1083 1083
1084 MaybeHandle<Object> Object::GetProperty(Handle<Object> object,
1085 Handle<Name> name) {
1086 PropertyAttributes attributes;
1087 return GetPropertyWithReceiver(object, object, name, &attributes);
1088 }
1089
1090
1084 MaybeHandle<Object> Object::GetElement(Isolate* isolate, 1091 MaybeHandle<Object> Object::GetElement(Isolate* isolate,
1085 Handle<Object> object, 1092 Handle<Object> object,
1086 uint32_t index) { 1093 uint32_t index) {
1087 // GetElement can trigger a getter which can cause allocation. 1094 // GetElement can trigger a getter which can cause allocation.
1088 // This was not always the case. This ASSERT is here to catch 1095 // This was not always the case. This ASSERT is here to catch
1089 // leftover incorrect uses. 1096 // leftover incorrect uses.
1090 ASSERT(AllowHeapAllocation::IsAllowed()); 1097 ASSERT(AllowHeapAllocation::IsAllowed());
1091 return Object::GetElementWithReceiver(isolate, object, object, index); 1098 return Object::GetElementWithReceiver(isolate, object, object, index);
1092 } 1099 }
1093 1100
1094 1101
1095 Handle<Object> Object::GetElementNoExceptionThrown(Isolate* isolate, 1102 MaybeHandle<Object> Object::GetPropertyOrElement(Handle<Object> object,
1096 Handle<Object> object, 1103 Handle<Name> name) {
1097 uint32_t index) { 1104 uint32_t index;
1098 Handle<Object> result = 1105 Isolate* isolate = name->GetIsolate();
1099 Object::GetElementWithReceiver( 1106 if (name->AsArrayIndex(&index)) return GetElement(isolate, object, index);
1100 isolate, object, object, index).ToHandleChecked(); 1107 return GetProperty(object, name);
1101 return result;
1102 } 1108 }
1103 1109
1104 1110
1105 MaybeObject* Object::GetProperty(Name* key) { 1111 MaybeHandle<Object> JSProxy::GetElementWithHandler(Handle<JSProxy> proxy,
1106 PropertyAttributes attributes; 1112 Handle<Object> receiver,
1107 return GetPropertyWithReceiver(this, key, &attributes); 1113 uint32_t index) {
1114 return GetPropertyWithHandler(
1115 proxy, receiver, proxy->GetIsolate()->factory()->Uint32ToString(index));
1108 } 1116 }
1109 1117
1110 1118
1119 MaybeHandle<Object> JSProxy::SetElementWithHandler(Handle<JSProxy> proxy,
1120 Handle<JSReceiver> receiver,
1121 uint32_t index,
1122 Handle<Object> value,
1123 StrictMode strict_mode) {
1124 Isolate* isolate = proxy->GetIsolate();
1125 Handle<String> name = isolate->factory()->Uint32ToString(index);
1126 return SetPropertyWithHandler(
1127 proxy, receiver, name, value, NONE, strict_mode);
1128 }
1129
1130
1131 bool JSProxy::HasElementWithHandler(Handle<JSProxy> proxy, uint32_t index) {
1132 Isolate* isolate = proxy->GetIsolate();
1133 Handle<String> name = isolate->factory()->Uint32ToString(index);
1134 return HasPropertyWithHandler(proxy, name);
1135 }
1136
1137
1111 #define FIELD_ADDR(p, offset) \ 1138 #define FIELD_ADDR(p, offset) \
1112 (reinterpret_cast<byte*>(p) + offset - kHeapObjectTag) 1139 (reinterpret_cast<byte*>(p) + offset - kHeapObjectTag)
1113 1140
1114 #define READ_FIELD(p, offset) \ 1141 #define READ_FIELD(p, offset) \
1115 (*reinterpret_cast<Object**>(FIELD_ADDR(p, offset))) 1142 (*reinterpret_cast<Object**>(FIELD_ADDR(p, offset)))
1116 1143
1117 #define ACQUIRE_READ_FIELD(p, offset) \ 1144 #define ACQUIRE_READ_FIELD(p, offset) \
1118 reinterpret_cast<Object*>( \ 1145 reinterpret_cast<Object*>( \
1119 Acquire_Load(reinterpret_cast<AtomicWord*>(FIELD_ADDR(p, offset)))) 1146 Acquire_Load(reinterpret_cast<AtomicWord*>(FIELD_ADDR(p, offset))))
1120 1147
(...skipping 1896 matching lines...) Expand 10 before | Expand all | Expand 10 after
3017 3044
3018 3045
3019 void Name::set_hash_field(uint32_t value) { 3046 void Name::set_hash_field(uint32_t value) {
3020 WRITE_UINT32_FIELD(this, kHashFieldOffset, value); 3047 WRITE_UINT32_FIELD(this, kHashFieldOffset, value);
3021 #if V8_HOST_ARCH_64_BIT 3048 #if V8_HOST_ARCH_64_BIT
3022 WRITE_UINT32_FIELD(this, kHashFieldOffset + kIntSize, 0); 3049 WRITE_UINT32_FIELD(this, kHashFieldOffset + kIntSize, 0);
3023 #endif 3050 #endif
3024 } 3051 }
3025 3052
3026 3053
3027 Handle<Object> GlobalObject::GetPropertyNoExceptionThrown(
3028 Handle<GlobalObject> global,
3029 Handle<Name> name) {
3030 Handle<Object> result = Object::GetProperty(global, name);
3031 CHECK_NOT_EMPTY_HANDLE(name->GetIsolate(), result);
3032 return result;
3033 }
3034
3035
3036 bool Name::Equals(Name* other) { 3054 bool Name::Equals(Name* other) {
3037 if (other == this) return true; 3055 if (other == this) return true;
3038 if ((this->IsInternalizedString() && other->IsInternalizedString()) || 3056 if ((this->IsInternalizedString() && other->IsInternalizedString()) ||
3039 this->IsSymbol() || other->IsSymbol()) { 3057 this->IsSymbol() || other->IsSymbol()) {
3040 return false; 3058 return false;
3041 } 3059 }
3042 return String::cast(this)->SlowEquals(String::cast(other)); 3060 return String::cast(this)->SlowEquals(String::cast(other));
3043 } 3061 }
3044 3062
3045 3063
(...skipping 4042 matching lines...) Expand 10 before | Expand all | Expand 10 after
7088 #undef READ_SHORT_FIELD 7106 #undef READ_SHORT_FIELD
7089 #undef WRITE_SHORT_FIELD 7107 #undef WRITE_SHORT_FIELD
7090 #undef READ_BYTE_FIELD 7108 #undef READ_BYTE_FIELD
7091 #undef WRITE_BYTE_FIELD 7109 #undef WRITE_BYTE_FIELD
7092 #undef NOBARRIER_READ_BYTE_FIELD 7110 #undef NOBARRIER_READ_BYTE_FIELD
7093 #undef NOBARRIER_WRITE_BYTE_FIELD 7111 #undef NOBARRIER_WRITE_BYTE_FIELD
7094 7112
7095 } } // namespace v8::internal 7113 } } // namespace v8::internal
7096 7114
7097 #endif // V8_OBJECTS_INL_H_ 7115 #endif // V8_OBJECTS_INL_H_
OLDNEW
« no previous file with comments | « src/objects.cc ('k') | src/runtime.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698