Chromium Code Reviews

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

Issue 1417063011: [runtime] support new Proxy() instead of Proxy.create and install getPrototypeOf trap (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: using one friend less Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 // Review notes: 5 // Review notes:
6 // 6 //
7 // - The use of macros in these inline functions may seem superfluous 7 // - The use of macros in these inline functions may seem superfluous
8 // but it is absolutely needed to make sure gcc generates optimal 8 // but it is absolutely needed to make sure gcc generates optimal
9 // code. gcc is not happy when attempting to inline too deep. 9 // code. gcc is not happy when attempting to inline too deep.
10 // 10 //
(...skipping 1176 matching lines...)
1187 MaybeHandle<Object> Object::SetElement(Isolate* isolate, Handle<Object> object, 1187 MaybeHandle<Object> Object::SetElement(Isolate* isolate, Handle<Object> object,
1188 uint32_t index, Handle<Object> value, 1188 uint32_t index, Handle<Object> value,
1189 LanguageMode language_mode) { 1189 LanguageMode language_mode) {
1190 LookupIterator it(isolate, object, index); 1190 LookupIterator it(isolate, object, index);
1191 MAYBE_RETURN_NULL( 1191 MAYBE_RETURN_NULL(
1192 SetProperty(&it, value, language_mode, MAY_BE_STORE_FROM_KEYED)); 1192 SetProperty(&it, value, language_mode, MAY_BE_STORE_FROM_KEYED));
1193 return value; 1193 return value;
1194 } 1194 }
1195 1195
1196 1196
1197 Handle<Object> Object::GetPrototype(Isolate* isolate, Handle<Object> obj) { 1197 MaybeHandle<Object> Object::GetPrototype(Isolate* isolate,
1198 Handle<Object> receiver) {
1198 // We don't expect access checks to be needed on JSProxy objects. 1199 // We don't expect access checks to be needed on JSProxy objects.
1199 DCHECK(!obj->IsAccessCheckNeeded() || obj->IsJSObject()); 1200 DCHECK(!receiver->IsAccessCheckNeeded() || receiver->IsJSObject());
1200 Handle<Context> context(isolate->context()); 1201 Handle<Context> context(isolate->context());
1201 if (obj->IsAccessCheckNeeded() && 1202 if (receiver->IsAccessCheckNeeded() &&
1202 !isolate->MayAccess(context, Handle<JSObject>::cast(obj))) { 1203 !isolate->MayAccess(context, Handle<JSObject>::cast(receiver))) {
1203 return isolate->factory()->null_value(); 1204 return isolate->factory()->null_value();
1204 } 1205 }
1205 1206 if (receiver->IsJSProxy()) {
1206 PrototypeIterator iter(isolate, obj, PrototypeIterator::START_AT_RECEIVER); 1207 return JSProxy::GetPrototype(Handle<JSProxy>::cast(receiver));
1208 }
1209 PrototypeIterator iter(isolate, receiver,
1210 PrototypeIterator::START_AT_RECEIVER);
1207 do { 1211 do {
1208 iter.AdvanceIgnoringProxies(); 1212 iter.AdvanceIgnoringProxies();
1209 if (PrototypeIterator::GetCurrent(iter)->IsJSProxy()) { 1213 if (PrototypeIterator::GetCurrent(iter)->IsJSProxy()) {
1210 return PrototypeIterator::GetCurrent(iter); 1214 return PrototypeIterator::GetCurrent(iter);
1211 } 1215 }
1212 } while (!iter.IsAtEnd(PrototypeIterator::END_AT_NON_HIDDEN)); 1216 } while (!iter.IsAtEnd(PrototypeIterator::END_AT_NON_HIDDEN));
1213 return PrototypeIterator::GetCurrent(iter); 1217 return PrototypeIterator::GetCurrent(iter);
1214 } 1218 }
1215 1219
1216 1220
(...skipping 5180 matching lines...)
6397 6401
6398 6402
6399 int JSFunction::NumberOfLiterals() { 6403 int JSFunction::NumberOfLiterals() {
6400 DCHECK(!shared()->bound()); 6404 DCHECK(!shared()->bound());
6401 return literals()->length(); 6405 return literals()->length();
6402 } 6406 }
6403 6407
6404 6408
6405 ACCESSORS(JSProxy, handler, Object, kHandlerOffset) 6409 ACCESSORS(JSProxy, handler, Object, kHandlerOffset)
6406 ACCESSORS(JSProxy, hash, Object, kHashOffset) 6410 ACCESSORS(JSProxy, hash, Object, kHashOffset)
6411 // TODO(@neis): transform this into a real object field.
6412 Object* JSProxy::target() const { return map()->prototype(); }
6413 void JSProxy::set_target(Object* value, WriteBarrierMode mode) {
6414 map()->set_prototype(value, mode);
6415 }
6416
6407 ACCESSORS(JSFunctionProxy, call_trap, JSReceiver, kCallTrapOffset) 6417 ACCESSORS(JSFunctionProxy, call_trap, JSReceiver, kCallTrapOffset)
6408 ACCESSORS(JSFunctionProxy, construct_trap, Object, kConstructTrapOffset) 6418 ACCESSORS(JSFunctionProxy, construct_trap, Object, kConstructTrapOffset)
6409 6419
6410 6420
6411 void JSProxy::InitializeBody(int object_size, Object* value) { 6421 void JSProxy::InitializeBody(int object_size, Object* value) {
6412 DCHECK(!value->IsHeapObject() || !GetHeap()->InNewSpace(value)); 6422 DCHECK(!value->IsHeapObject() || !GetHeap()->InNewSpace(value));
6413 for (int offset = kHeaderSize; offset < object_size; offset += kPointerSize) { 6423 for (int offset = kHeaderSize; offset < object_size; offset += kPointerSize) {
6414 WRITE_FIELD(this, offset, value); 6424 WRITE_FIELD(this, offset, value);
6415 } 6425 }
6416 } 6426 }
(...skipping 1734 matching lines...)
8151 #undef WRITE_INT64_FIELD 8161 #undef WRITE_INT64_FIELD
8152 #undef READ_BYTE_FIELD 8162 #undef READ_BYTE_FIELD
8153 #undef WRITE_BYTE_FIELD 8163 #undef WRITE_BYTE_FIELD
8154 #undef NOBARRIER_READ_BYTE_FIELD 8164 #undef NOBARRIER_READ_BYTE_FIELD
8155 #undef NOBARRIER_WRITE_BYTE_FIELD 8165 #undef NOBARRIER_WRITE_BYTE_FIELD
8156 8166
8157 } // namespace internal 8167 } // namespace internal
8158 } // namespace v8 8168 } // namespace v8
8159 8169
8160 #endif // V8_OBJECTS_INL_H_ 8170 #endif // V8_OBJECTS_INL_H_
OLDNEW
« src/objects.cc ('K') | « src/objects.cc ('k') | src/objects-printer.cc » ('j') | no next file with comments »

Powered by Google App Engine