OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 #include <iomanip> | 5 #include <iomanip> |
6 #include <sstream> | 6 #include <sstream> |
7 | 7 |
8 #include "src/v8.h" | 8 #include "src/v8.h" |
9 | 9 |
10 #include "src/accessors.h" | 10 #include "src/accessors.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 #include "src/field-index.h" | 27 #include "src/field-index.h" |
28 #include "src/full-codegen.h" | 28 #include "src/full-codegen.h" |
29 #include "src/heap/mark-compact.h" | 29 #include "src/heap/mark-compact.h" |
30 #include "src/heap/objects-visiting-inl.h" | 30 #include "src/heap/objects-visiting-inl.h" |
31 #include "src/hydrogen.h" | 31 #include "src/hydrogen.h" |
32 #include "src/ic/ic.h" | 32 #include "src/ic/ic.h" |
33 #include "src/isolate-inl.h" | 33 #include "src/isolate-inl.h" |
34 #include "src/log.h" | 34 #include "src/log.h" |
35 #include "src/lookup.h" | 35 #include "src/lookup.h" |
36 #include "src/macro-assembler.h" | 36 #include "src/macro-assembler.h" |
| 37 #include "src/messages.h" |
37 #include "src/objects-inl.h" | 38 #include "src/objects-inl.h" |
38 #include "src/prototype.h" | 39 #include "src/prototype.h" |
39 #include "src/safepoint-table.h" | 40 #include "src/safepoint-table.h" |
40 #include "src/string-search.h" | 41 #include "src/string-search.h" |
41 #include "src/string-stream.h" | 42 #include "src/string-stream.h" |
42 #include "src/utils.h" | 43 #include "src/utils.h" |
43 | 44 |
44 #ifdef ENABLE_DISASSEMBLER | 45 #ifdef ENABLE_DISASSEMBLER |
45 #include "src/disasm.h" | 46 #include "src/disasm.h" |
46 #include "src/disassembler.h" | 47 #include "src/disassembler.h" |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 MaybeHandle<Object> Object::GetPropertyWithAccessor(Handle<Object> receiver, | 292 MaybeHandle<Object> Object::GetPropertyWithAccessor(Handle<Object> receiver, |
292 Handle<Name> name, | 293 Handle<Name> name, |
293 Handle<JSObject> holder, | 294 Handle<JSObject> holder, |
294 Handle<Object> structure) { | 295 Handle<Object> structure) { |
295 Isolate* isolate = name->GetIsolate(); | 296 Isolate* isolate = name->GetIsolate(); |
296 DCHECK(!structure->IsForeign()); | 297 DCHECK(!structure->IsForeign()); |
297 // api style callbacks. | 298 // api style callbacks. |
298 if (structure->IsAccessorInfo()) { | 299 if (structure->IsAccessorInfo()) { |
299 Handle<AccessorInfo> info = Handle<AccessorInfo>::cast(structure); | 300 Handle<AccessorInfo> info = Handle<AccessorInfo>::cast(structure); |
300 if (!info->IsCompatibleReceiver(*receiver)) { | 301 if (!info->IsCompatibleReceiver(*receiver)) { |
301 Handle<Object> args[] = {name, receiver}; | |
302 THROW_NEW_ERROR(isolate, | 302 THROW_NEW_ERROR(isolate, |
303 NewTypeError("incompatible_method_receiver", | 303 NewTypeError(MessageTemplate::kIncompatibleMethodReceiver, |
304 HandleVector(args, arraysize(args))), | 304 name, receiver), |
305 Object); | 305 Object); |
306 } | 306 } |
307 | 307 |
308 Handle<ExecutableAccessorInfo> data = | 308 Handle<ExecutableAccessorInfo> data = |
309 Handle<ExecutableAccessorInfo>::cast(structure); | 309 Handle<ExecutableAccessorInfo>::cast(structure); |
310 v8::AccessorNameGetterCallback call_fun = | 310 v8::AccessorNameGetterCallback call_fun = |
311 v8::ToCData<v8::AccessorNameGetterCallback>(data->getter()); | 311 v8::ToCData<v8::AccessorNameGetterCallback>(data->getter()); |
312 if (call_fun == NULL) return isolate->factory()->undefined_value(); | 312 if (call_fun == NULL) return isolate->factory()->undefined_value(); |
313 | 313 |
314 LOG(isolate, ApiNamedPropertyAccess("load", *holder, *name)); | 314 LOG(isolate, ApiNamedPropertyAccess("load", *holder, *name)); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 | 356 |
357 // We should never get here to initialize a const with the hole | 357 // We should never get here to initialize a const with the hole |
358 // value since a const declaration would conflict with the setter. | 358 // value since a const declaration would conflict with the setter. |
359 DCHECK(!structure->IsForeign()); | 359 DCHECK(!structure->IsForeign()); |
360 if (structure->IsExecutableAccessorInfo()) { | 360 if (structure->IsExecutableAccessorInfo()) { |
361 // Don't call executable accessor setters with non-JSObject receivers. | 361 // Don't call executable accessor setters with non-JSObject receivers. |
362 if (!receiver->IsJSObject()) return value; | 362 if (!receiver->IsJSObject()) return value; |
363 // api style callbacks | 363 // api style callbacks |
364 ExecutableAccessorInfo* info = ExecutableAccessorInfo::cast(*structure); | 364 ExecutableAccessorInfo* info = ExecutableAccessorInfo::cast(*structure); |
365 if (!info->IsCompatibleReceiver(*receiver)) { | 365 if (!info->IsCompatibleReceiver(*receiver)) { |
366 Handle<Object> args[] = {name, receiver}; | |
367 THROW_NEW_ERROR(isolate, | 366 THROW_NEW_ERROR(isolate, |
368 NewTypeError("incompatible_method_receiver", | 367 NewTypeError(MessageTemplate::kIncompatibleMethodReceiver, |
369 HandleVector(args, arraysize(args))), | 368 name, receiver), |
370 Object); | 369 Object); |
371 } | 370 } |
372 Object* call_obj = info->setter(); | 371 Object* call_obj = info->setter(); |
373 v8::AccessorNameSetterCallback call_fun = | 372 v8::AccessorNameSetterCallback call_fun = |
374 v8::ToCData<v8::AccessorNameSetterCallback>(call_obj); | 373 v8::ToCData<v8::AccessorNameSetterCallback>(call_obj); |
375 if (call_fun == NULL) return value; | 374 if (call_fun == NULL) return value; |
376 LOG(isolate, ApiNamedPropertyAccess("store", *holder, *name)); | 375 LOG(isolate, ApiNamedPropertyAccess("store", *holder, *name)); |
377 PropertyCallbackArguments args(isolate, info->data(), *receiver, *holder); | 376 PropertyCallbackArguments args(isolate, info->data(), *receiver, *holder); |
378 args.Call(call_fun, | 377 args.Call(call_fun, |
379 v8::Utils::ToLocal(name), | 378 v8::Utils::ToLocal(name), |
(...skipping 12079 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12459 | 12458 |
12460 // Before we can set the prototype we need to be sure | 12459 // Before we can set the prototype we need to be sure |
12461 // prototype cycles are prevented. | 12460 // prototype cycles are prevented. |
12462 // It is sufficient to validate that the receiver is not in the new prototype | 12461 // It is sufficient to validate that the receiver is not in the new prototype |
12463 // chain. | 12462 // chain. |
12464 for (PrototypeIterator iter(isolate, *value, | 12463 for (PrototypeIterator iter(isolate, *value, |
12465 PrototypeIterator::START_AT_RECEIVER); | 12464 PrototypeIterator::START_AT_RECEIVER); |
12466 !iter.IsAtEnd(); iter.Advance()) { | 12465 !iter.IsAtEnd(); iter.Advance()) { |
12467 if (JSReceiver::cast(iter.GetCurrent()) == *object) { | 12466 if (JSReceiver::cast(iter.GetCurrent()) == *object) { |
12468 // Cycle detected. | 12467 // Cycle detected. |
12469 THROW_NEW_ERROR(isolate, | 12468 THROW_NEW_ERROR(isolate, NewError(MessageTemplate::kCyclicProto), Object); |
12470 NewError("cyclic_proto", HandleVector<Object>(NULL, 0)), | |
12471 Object); | |
12472 } | 12469 } |
12473 } | 12470 } |
12474 | 12471 |
12475 bool dictionary_elements_in_chain = | 12472 bool dictionary_elements_in_chain = |
12476 object->map()->DictionaryElementsInPrototypeChainOnly(); | 12473 object->map()->DictionaryElementsInPrototypeChainOnly(); |
12477 Handle<JSObject> real_receiver = object; | 12474 Handle<JSObject> real_receiver = object; |
12478 | 12475 |
12479 if (from_javascript) { | 12476 if (from_javascript) { |
12480 // Find the first object in the chain whose prototype object is not | 12477 // Find the first object in the chain whose prototype object is not |
12481 // hidden and set the new prototype on that object. | 12478 // hidden and set the new prototype on that object. |
(...skipping 4594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17076 if (!invalidate && old_type == PropertyCellType::kConstant && | 17073 if (!invalidate && old_type == PropertyCellType::kConstant && |
17077 new_type != PropertyCellType::kConstant) { | 17074 new_type != PropertyCellType::kConstant) { |
17078 auto isolate = dictionary->GetIsolate(); | 17075 auto isolate = dictionary->GetIsolate(); |
17079 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 17076 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
17080 isolate, DependentCode::kPropertyCellChangedGroup); | 17077 isolate, DependentCode::kPropertyCellChangedGroup); |
17081 } | 17078 } |
17082 return value; | 17079 return value; |
17083 } | 17080 } |
17084 | 17081 |
17085 } } // namespace v8::internal | 17082 } } // namespace v8::internal |
OLD | NEW |