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 15 matching lines...) Expand all Loading... |
26 #include "src/field-index.h" | 26 #include "src/field-index.h" |
27 #include "src/full-codegen.h" | 27 #include "src/full-codegen.h" |
28 #include "src/heap/mark-compact.h" | 28 #include "src/heap/mark-compact.h" |
29 #include "src/heap/objects-visiting-inl.h" | 29 #include "src/heap/objects-visiting-inl.h" |
30 #include "src/hydrogen.h" | 30 #include "src/hydrogen.h" |
31 #include "src/ic/ic.h" | 31 #include "src/ic/ic.h" |
32 #include "src/isolate-inl.h" | 32 #include "src/isolate-inl.h" |
33 #include "src/log.h" | 33 #include "src/log.h" |
34 #include "src/lookup.h" | 34 #include "src/lookup.h" |
35 #include "src/macro-assembler.h" | 35 #include "src/macro-assembler.h" |
36 #include "src/messages.h" | |
37 #include "src/objects-inl.h" | 36 #include "src/objects-inl.h" |
38 #include "src/prototype.h" | 37 #include "src/prototype.h" |
39 #include "src/safepoint-table.h" | 38 #include "src/safepoint-table.h" |
40 #include "src/string-search.h" | 39 #include "src/string-search.h" |
41 #include "src/string-stream.h" | 40 #include "src/string-stream.h" |
42 #include "src/utils.h" | 41 #include "src/utils.h" |
43 | 42 |
44 #ifdef ENABLE_DISASSEMBLER | 43 #ifdef ENABLE_DISASSEMBLER |
45 #include "src/disasm.h" | 44 #include "src/disasm.h" |
46 #include "src/disassembler.h" | 45 #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, | 290 MaybeHandle<Object> Object::GetPropertyWithAccessor(Handle<Object> receiver, |
292 Handle<Name> name, | 291 Handle<Name> name, |
293 Handle<JSObject> holder, | 292 Handle<JSObject> holder, |
294 Handle<Object> structure) { | 293 Handle<Object> structure) { |
295 Isolate* isolate = name->GetIsolate(); | 294 Isolate* isolate = name->GetIsolate(); |
296 DCHECK(!structure->IsForeign()); | 295 DCHECK(!structure->IsForeign()); |
297 // api style callbacks. | 296 // api style callbacks. |
298 if (structure->IsAccessorInfo()) { | 297 if (structure->IsAccessorInfo()) { |
299 Handle<AccessorInfo> info = Handle<AccessorInfo>::cast(structure); | 298 Handle<AccessorInfo> info = Handle<AccessorInfo>::cast(structure); |
300 if (!info->IsCompatibleReceiver(*receiver)) { | 299 if (!info->IsCompatibleReceiver(*receiver)) { |
| 300 Handle<Object> args[] = {name, receiver}; |
301 THROW_NEW_ERROR(isolate, | 301 THROW_NEW_ERROR(isolate, |
302 NewTypeError(MessageTemplate::kIncompatibleMethodReceiver, | 302 NewTypeError("incompatible_method_receiver", |
303 name, receiver), | 303 HandleVector(args, arraysize(args))), |
304 Object); | 304 Object); |
305 } | 305 } |
306 | 306 |
307 Handle<ExecutableAccessorInfo> data = | 307 Handle<ExecutableAccessorInfo> data = |
308 Handle<ExecutableAccessorInfo>::cast(structure); | 308 Handle<ExecutableAccessorInfo>::cast(structure); |
309 v8::AccessorNameGetterCallback call_fun = | 309 v8::AccessorNameGetterCallback call_fun = |
310 v8::ToCData<v8::AccessorNameGetterCallback>(data->getter()); | 310 v8::ToCData<v8::AccessorNameGetterCallback>(data->getter()); |
311 if (call_fun == NULL) return isolate->factory()->undefined_value(); | 311 if (call_fun == NULL) return isolate->factory()->undefined_value(); |
312 | 312 |
313 LOG(isolate, ApiNamedPropertyAccess("load", *holder, *name)); | 313 LOG(isolate, ApiNamedPropertyAccess("load", *holder, *name)); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 | 355 |
356 // We should never get here to initialize a const with the hole | 356 // We should never get here to initialize a const with the hole |
357 // value since a const declaration would conflict with the setter. | 357 // value since a const declaration would conflict with the setter. |
358 DCHECK(!structure->IsForeign()); | 358 DCHECK(!structure->IsForeign()); |
359 if (structure->IsExecutableAccessorInfo()) { | 359 if (structure->IsExecutableAccessorInfo()) { |
360 // Don't call executable accessor setters with non-JSObject receivers. | 360 // Don't call executable accessor setters with non-JSObject receivers. |
361 if (!receiver->IsJSObject()) return value; | 361 if (!receiver->IsJSObject()) return value; |
362 // api style callbacks | 362 // api style callbacks |
363 ExecutableAccessorInfo* info = ExecutableAccessorInfo::cast(*structure); | 363 ExecutableAccessorInfo* info = ExecutableAccessorInfo::cast(*structure); |
364 if (!info->IsCompatibleReceiver(*receiver)) { | 364 if (!info->IsCompatibleReceiver(*receiver)) { |
| 365 Handle<Object> args[] = {name, receiver}; |
365 THROW_NEW_ERROR(isolate, | 366 THROW_NEW_ERROR(isolate, |
366 NewTypeError(MessageTemplate::kIncompatibleMethodReceiver, | 367 NewTypeError("incompatible_method_receiver", |
367 name, receiver), | 368 HandleVector(args, arraysize(args))), |
368 Object); | 369 Object); |
369 } | 370 } |
370 Object* call_obj = info->setter(); | 371 Object* call_obj = info->setter(); |
371 v8::AccessorNameSetterCallback call_fun = | 372 v8::AccessorNameSetterCallback call_fun = |
372 v8::ToCData<v8::AccessorNameSetterCallback>(call_obj); | 373 v8::ToCData<v8::AccessorNameSetterCallback>(call_obj); |
373 if (call_fun == NULL) return value; | 374 if (call_fun == NULL) return value; |
374 LOG(isolate, ApiNamedPropertyAccess("store", *holder, *name)); | 375 LOG(isolate, ApiNamedPropertyAccess("store", *holder, *name)); |
375 PropertyCallbackArguments args(isolate, info->data(), *receiver, *holder); | 376 PropertyCallbackArguments args(isolate, info->data(), *receiver, *holder); |
376 args.Call(call_fun, | 377 args.Call(call_fun, |
377 v8::Utils::ToLocal(name), | 378 v8::Utils::ToLocal(name), |
(...skipping 12103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12481 | 12482 |
12482 // Before we can set the prototype we need to be sure | 12483 // Before we can set the prototype we need to be sure |
12483 // prototype cycles are prevented. | 12484 // prototype cycles are prevented. |
12484 // It is sufficient to validate that the receiver is not in the new prototype | 12485 // It is sufficient to validate that the receiver is not in the new prototype |
12485 // chain. | 12486 // chain. |
12486 for (PrototypeIterator iter(isolate, *value, | 12487 for (PrototypeIterator iter(isolate, *value, |
12487 PrototypeIterator::START_AT_RECEIVER); | 12488 PrototypeIterator::START_AT_RECEIVER); |
12488 !iter.IsAtEnd(); iter.Advance()) { | 12489 !iter.IsAtEnd(); iter.Advance()) { |
12489 if (JSReceiver::cast(iter.GetCurrent()) == *object) { | 12490 if (JSReceiver::cast(iter.GetCurrent()) == *object) { |
12490 // Cycle detected. | 12491 // Cycle detected. |
12491 THROW_NEW_ERROR(isolate, NewError(MessageTemplate::kCyclicProto), Object); | 12492 THROW_NEW_ERROR(isolate, |
| 12493 NewError("cyclic_proto", HandleVector<Object>(NULL, 0)), |
| 12494 Object); |
12492 } | 12495 } |
12493 } | 12496 } |
12494 | 12497 |
12495 bool dictionary_elements_in_chain = | 12498 bool dictionary_elements_in_chain = |
12496 object->map()->DictionaryElementsInPrototypeChainOnly(); | 12499 object->map()->DictionaryElementsInPrototypeChainOnly(); |
12497 Handle<JSObject> real_receiver = object; | 12500 Handle<JSObject> real_receiver = object; |
12498 | 12501 |
12499 if (from_javascript) { | 12502 if (from_javascript) { |
12500 // Find the first object in the chain whose prototype object is not | 12503 // Find the first object in the chain whose prototype object is not |
12501 // hidden and set the new prototype on that object. | 12504 // hidden and set the new prototype on that object. |
(...skipping 4641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17143 CompilationInfo* info) { | 17146 CompilationInfo* info) { |
17144 Handle<DependentCode> codes = DependentCode::InsertCompilationInfo( | 17147 Handle<DependentCode> codes = DependentCode::InsertCompilationInfo( |
17145 handle(cell->dependent_code(), info->isolate()), | 17148 handle(cell->dependent_code(), info->isolate()), |
17146 DependentCode::kPropertyCellChangedGroup, info->object_wrapper()); | 17149 DependentCode::kPropertyCellChangedGroup, info->object_wrapper()); |
17147 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes); | 17150 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes); |
17148 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add( | 17151 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add( |
17149 cell, info->zone()); | 17152 cell, info->zone()); |
17150 } | 17153 } |
17151 | 17154 |
17152 } } // namespace v8::internal | 17155 } } // namespace v8::internal |
OLD | NEW |