| OLD | NEW |
| 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 4241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4252 MaybeObject* Runtime::GetObjectPropertyOrFail( | 4252 MaybeObject* Runtime::GetObjectPropertyOrFail( |
| 4253 Isolate* isolate, | 4253 Isolate* isolate, |
| 4254 Handle<Object> object, | 4254 Handle<Object> object, |
| 4255 Handle<Object> key) { | 4255 Handle<Object> key) { |
| 4256 CALL_HEAP_FUNCTION_PASS_EXCEPTION(isolate, | 4256 CALL_HEAP_FUNCTION_PASS_EXCEPTION(isolate, |
| 4257 GetObjectProperty(isolate, object, key)); | 4257 GetObjectProperty(isolate, object, key)); |
| 4258 } | 4258 } |
| 4259 | 4259 |
| 4260 MaybeObject* Runtime::GetObjectProperty(Isolate* isolate, | 4260 MaybeObject* Runtime::GetObjectProperty(Isolate* isolate, |
| 4261 Handle<Object> object, | 4261 Handle<Object> object, |
| 4262 Handle<Object> key) { | 4262 Handle<Object> key, |
| 4263 LookupCache* cache) { |
| 4263 HandleScope scope(isolate); | 4264 HandleScope scope(isolate); |
| 4264 | 4265 |
| 4265 if (object->IsUndefined() || object->IsNull()) { | 4266 if (object->IsUndefined() || object->IsNull()) { |
| 4266 Handle<Object> args[2] = { key, object }; | 4267 Handle<Object> args[2] = { key, object }; |
| 4267 Handle<Object> error = | 4268 Handle<Object> error = |
| 4268 isolate->factory()->NewTypeError("non_object_property_load", | 4269 isolate->factory()->NewTypeError("non_object_property_load", |
| 4269 HandleVector(args, 2)); | 4270 HandleVector(args, 2)); |
| 4270 return isolate->Throw(*error); | 4271 return isolate->Throw(*error); |
| 4271 } | 4272 } |
| 4272 | 4273 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 4285 Handle<Object> converted = | 4286 Handle<Object> converted = |
| 4286 Execution::ToString(key, &has_pending_exception); | 4287 Execution::ToString(key, &has_pending_exception); |
| 4287 if (has_pending_exception) return Failure::Exception(); | 4288 if (has_pending_exception) return Failure::Exception(); |
| 4288 name = Handle<Name>::cast(converted); | 4289 name = Handle<Name>::cast(converted); |
| 4289 } | 4290 } |
| 4290 | 4291 |
| 4291 // Check if the name is trivially convertible to an index and get | 4292 // Check if the name is trivially convertible to an index and get |
| 4292 // the element if so. | 4293 // the element if so. |
| 4293 if (name->AsArrayIndex(&index)) { | 4294 if (name->AsArrayIndex(&index)) { |
| 4294 return GetElementOrCharAt(isolate, object, index); | 4295 return GetElementOrCharAt(isolate, object, index); |
| 4296 } else if (cache == NULL) { |
| 4297 return object->GetProperty(*name); |
| 4295 } else { | 4298 } else { |
| 4296 return object->GetProperty(*name); | 4299 return cache->GetProperty(object, name); |
| 4297 } | 4300 } |
| 4298 } | 4301 } |
| 4299 | 4302 |
| 4300 | 4303 |
| 4301 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetProperty) { | 4304 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetProperty) { |
| 4302 NoHandleAllocation ha(isolate); | 4305 NoHandleAllocation ha(isolate); |
| 4303 ASSERT(args.length() == 2); | 4306 ASSERT(args.length() == 2); |
| 4304 | 4307 |
| 4305 Handle<Object> object = args.at<Object>(0); | 4308 Handle<Object> object = args.at<Object>(0); |
| 4306 Handle<Object> key = args.at<Object>(1); | 4309 Handle<Object> key = args.at<Object>(1); |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4550 CALL_HEAP_FUNCTION_PASS_EXCEPTION(isolate, | 4553 CALL_HEAP_FUNCTION_PASS_EXCEPTION(isolate, |
| 4551 SetObjectProperty(isolate, object, key, value, attr, strict_mode)); | 4554 SetObjectProperty(isolate, object, key, value, attr, strict_mode)); |
| 4552 } | 4555 } |
| 4553 | 4556 |
| 4554 | 4557 |
| 4555 MaybeObject* Runtime::SetObjectProperty(Isolate* isolate, | 4558 MaybeObject* Runtime::SetObjectProperty(Isolate* isolate, |
| 4556 Handle<Object> object, | 4559 Handle<Object> object, |
| 4557 Handle<Object> key, | 4560 Handle<Object> key, |
| 4558 Handle<Object> value, | 4561 Handle<Object> value, |
| 4559 PropertyAttributes attr, | 4562 PropertyAttributes attr, |
| 4560 StrictModeFlag strict_mode) { | 4563 StrictModeFlag strict_mode, |
| 4564 LookupCache* cache) { |
| 4561 SetPropertyMode set_mode = attr == NONE ? SET_PROPERTY : DEFINE_PROPERTY; | 4565 SetPropertyMode set_mode = attr == NONE ? SET_PROPERTY : DEFINE_PROPERTY; |
| 4562 HandleScope scope(isolate); | 4566 HandleScope scope(isolate); |
| 4563 | 4567 |
| 4564 if (object->IsUndefined() || object->IsNull()) { | 4568 if (object->IsUndefined() || object->IsNull()) { |
| 4565 Handle<Object> args[2] = { key, object }; | 4569 Handle<Object> args[2] = { key, object }; |
| 4566 Handle<Object> error = | 4570 Handle<Object> error = |
| 4567 isolate->factory()->NewTypeError("non_object_property_store", | 4571 isolate->factory()->NewTypeError("non_object_property_store", |
| 4568 HandleVector(args, 2)); | 4572 HandleVector(args, 2)); |
| 4569 return isolate->Throw(*error); | 4573 return isolate->Throw(*error); |
| 4570 } | 4574 } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4606 } | 4610 } |
| 4607 | 4611 |
| 4608 if (key->IsName()) { | 4612 if (key->IsName()) { |
| 4609 Handle<Object> result; | 4613 Handle<Object> result; |
| 4610 Handle<Name> name = Handle<Name>::cast(key); | 4614 Handle<Name> name = Handle<Name>::cast(key); |
| 4611 if (name->AsArrayIndex(&index)) { | 4615 if (name->AsArrayIndex(&index)) { |
| 4612 result = JSObject::SetElement( | 4616 result = JSObject::SetElement( |
| 4613 js_object, index, value, attr, strict_mode, set_mode); | 4617 js_object, index, value, attr, strict_mode, set_mode); |
| 4614 } else { | 4618 } else { |
| 4615 if (name->IsString()) Handle<String>::cast(name)->TryFlatten(); | 4619 if (name->IsString()) Handle<String>::cast(name)->TryFlatten(); |
| 4616 result = JSReceiver::SetProperty( | 4620 if (cache == NULL || attr != NONE || strict_mode != kNonStrictMode) { |
| 4617 js_object, name, value, attr, strict_mode); | 4621 result = JSReceiver::SetProperty( |
| 4622 js_object, name, value, attr, strict_mode); |
| 4623 } else { |
| 4624 return cache->SetProperty(js_object, name, value); |
| 4625 } |
| 4618 } | 4626 } |
| 4619 if (result.is_null()) return Failure::Exception(); | 4627 if (result.is_null()) return Failure::Exception(); |
| 4620 return *value; | 4628 return *value; |
| 4621 } | 4629 } |
| 4622 | 4630 |
| 4623 // Call-back into JavaScript to convert the key to a string. | 4631 // Call-back into JavaScript to convert the key to a string. |
| 4624 bool has_pending_exception = false; | 4632 bool has_pending_exception = false; |
| 4625 Handle<Object> converted = Execution::ToString(key, &has_pending_exception); | 4633 Handle<Object> converted = Execution::ToString(key, &has_pending_exception); |
| 4626 if (has_pending_exception) return Failure::Exception(); | 4634 if (has_pending_exception) return Failure::Exception(); |
| 4627 Handle<String> name = Handle<String>::cast(converted); | 4635 Handle<String> name = Handle<String>::cast(converted); |
| (...skipping 8741 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13369 // Handle last resort GC and make sure to allow future allocations | 13377 // Handle last resort GC and make sure to allow future allocations |
| 13370 // to grow the heap without causing GCs (if possible). | 13378 // to grow the heap without causing GCs (if possible). |
| 13371 isolate->counters()->gc_last_resort_from_js()->Increment(); | 13379 isolate->counters()->gc_last_resort_from_js()->Increment(); |
| 13372 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 13380 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
| 13373 "Runtime::PerformGC"); | 13381 "Runtime::PerformGC"); |
| 13374 } | 13382 } |
| 13375 } | 13383 } |
| 13376 | 13384 |
| 13377 | 13385 |
| 13378 } } // namespace v8::internal | 13386 } } // namespace v8::internal |
| OLD | NEW |