| 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" |
| 36 #include "src/objects-inl.h" | 37 #include "src/objects-inl.h" |
| 37 #include "src/prototype.h" | 38 #include "src/prototype.h" |
| 38 #include "src/safepoint-table.h" | 39 #include "src/safepoint-table.h" |
| 39 #include "src/string-search.h" | 40 #include "src/string-search.h" |
| 40 #include "src/string-stream.h" | 41 #include "src/string-stream.h" |
| 41 #include "src/utils.h" | 42 #include "src/utils.h" |
| 42 | 43 |
| 43 #ifdef ENABLE_DISASSEMBLER | 44 #ifdef ENABLE_DISASSEMBLER |
| 44 #include "src/disasm.h" | 45 #include "src/disasm.h" |
| 45 #include "src/disassembler.h" | 46 #include "src/disassembler.h" |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 MaybeHandle<Object> Object::GetPropertyWithAccessor(Handle<Object> receiver, | 291 MaybeHandle<Object> Object::GetPropertyWithAccessor(Handle<Object> receiver, |
| 291 Handle<Name> name, | 292 Handle<Name> name, |
| 292 Handle<JSObject> holder, | 293 Handle<JSObject> holder, |
| 293 Handle<Object> structure) { | 294 Handle<Object> structure) { |
| 294 Isolate* isolate = name->GetIsolate(); | 295 Isolate* isolate = name->GetIsolate(); |
| 295 DCHECK(!structure->IsForeign()); | 296 DCHECK(!structure->IsForeign()); |
| 296 // api style callbacks. | 297 // api style callbacks. |
| 297 if (structure->IsAccessorInfo()) { | 298 if (structure->IsAccessorInfo()) { |
| 298 Handle<AccessorInfo> info = Handle<AccessorInfo>::cast(structure); | 299 Handle<AccessorInfo> info = Handle<AccessorInfo>::cast(structure); |
| 299 if (!info->IsCompatibleReceiver(*receiver)) { | 300 if (!info->IsCompatibleReceiver(*receiver)) { |
| 300 Handle<Object> args[] = {name, receiver}; | |
| 301 THROW_NEW_ERROR(isolate, | 301 THROW_NEW_ERROR(isolate, |
| 302 NewTypeError("incompatible_method_receiver", | 302 NewTypeError(MessageTemplate::kIncompatibleMethodReceiver, |
| 303 HandleVector(args, arraysize(args))), | 303 name, receiver), |
| 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}; | |
| 366 THROW_NEW_ERROR(isolate, | 365 THROW_NEW_ERROR(isolate, |
| 367 NewTypeError("incompatible_method_receiver", | 366 NewTypeError(MessageTemplate::kIncompatibleMethodReceiver, |
| 368 HandleVector(args, arraysize(args))), | 367 name, receiver), |
| 369 Object); | 368 Object); |
| 370 } | 369 } |
| 371 Object* call_obj = info->setter(); | 370 Object* call_obj = info->setter(); |
| 372 v8::AccessorNameSetterCallback call_fun = | 371 v8::AccessorNameSetterCallback call_fun = |
| 373 v8::ToCData<v8::AccessorNameSetterCallback>(call_obj); | 372 v8::ToCData<v8::AccessorNameSetterCallback>(call_obj); |
| 374 if (call_fun == NULL) return value; | 373 if (call_fun == NULL) return value; |
| 375 LOG(isolate, ApiNamedPropertyAccess("store", *holder, *name)); | 374 LOG(isolate, ApiNamedPropertyAccess("store", *holder, *name)); |
| 376 PropertyCallbackArguments args(isolate, info->data(), *receiver, *holder); | 375 PropertyCallbackArguments args(isolate, info->data(), *receiver, *holder); |
| 377 args.Call(call_fun, | 376 args.Call(call_fun, |
| 378 v8::Utils::ToLocal(name), | 377 v8::Utils::ToLocal(name), |
| (...skipping 12103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12482 | 12481 |
| 12483 // Before we can set the prototype we need to be sure | 12482 // Before we can set the prototype we need to be sure |
| 12484 // prototype cycles are prevented. | 12483 // prototype cycles are prevented. |
| 12485 // It is sufficient to validate that the receiver is not in the new prototype | 12484 // It is sufficient to validate that the receiver is not in the new prototype |
| 12486 // chain. | 12485 // chain. |
| 12487 for (PrototypeIterator iter(isolate, *value, | 12486 for (PrototypeIterator iter(isolate, *value, |
| 12488 PrototypeIterator::START_AT_RECEIVER); | 12487 PrototypeIterator::START_AT_RECEIVER); |
| 12489 !iter.IsAtEnd(); iter.Advance()) { | 12488 !iter.IsAtEnd(); iter.Advance()) { |
| 12490 if (JSReceiver::cast(iter.GetCurrent()) == *object) { | 12489 if (JSReceiver::cast(iter.GetCurrent()) == *object) { |
| 12491 // Cycle detected. | 12490 // Cycle detected. |
| 12492 THROW_NEW_ERROR(isolate, | 12491 THROW_NEW_ERROR(isolate, NewError(MessageTemplate::kCyclicProto), Object); |
| 12493 NewError("cyclic_proto", HandleVector<Object>(NULL, 0)), | |
| 12494 Object); | |
| 12495 } | 12492 } |
| 12496 } | 12493 } |
| 12497 | 12494 |
| 12498 bool dictionary_elements_in_chain = | 12495 bool dictionary_elements_in_chain = |
| 12499 object->map()->DictionaryElementsInPrototypeChainOnly(); | 12496 object->map()->DictionaryElementsInPrototypeChainOnly(); |
| 12500 Handle<JSObject> real_receiver = object; | 12497 Handle<JSObject> real_receiver = object; |
| 12501 | 12498 |
| 12502 if (from_javascript) { | 12499 if (from_javascript) { |
| 12503 // Find the first object in the chain whose prototype object is not | 12500 // Find the first object in the chain whose prototype object is not |
| 12504 // hidden and set the new prototype on that object. | 12501 // hidden and set the new prototype on that object. |
| (...skipping 4641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 17146 CompilationInfo* info) { | 17143 CompilationInfo* info) { |
| 17147 Handle<DependentCode> codes = DependentCode::InsertCompilationInfo( | 17144 Handle<DependentCode> codes = DependentCode::InsertCompilationInfo( |
| 17148 handle(cell->dependent_code(), info->isolate()), | 17145 handle(cell->dependent_code(), info->isolate()), |
| 17149 DependentCode::kPropertyCellChangedGroup, info->object_wrapper()); | 17146 DependentCode::kPropertyCellChangedGroup, info->object_wrapper()); |
| 17150 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes); | 17147 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes); |
| 17151 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add( | 17148 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add( |
| 17152 cell, info->zone()); | 17149 cell, info->zone()); |
| 17153 } | 17150 } |
| 17154 | 17151 |
| 17155 } } // namespace v8::internal | 17152 } } // namespace v8::internal |
| OLD | NEW |