Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1014)

Side by Side Diff: src/runtime.cc

Issue 27518002: Handlify JSObject::HasReal*Property. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/objects.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 5564 matching lines...) Expand 10 before | Expand all | Expand 10 after
5575 return HasLocalPropertyImplementation(isolate, 5575 return HasLocalPropertyImplementation(isolate,
5576 Handle<JSObject>::cast(proto), 5576 Handle<JSObject>::cast(proto),
5577 key); 5577 key);
5578 } 5578 }
5579 RETURN_IF_SCHEDULED_EXCEPTION(isolate); 5579 RETURN_IF_SCHEDULED_EXCEPTION(isolate);
5580 return isolate->heap()->false_value(); 5580 return isolate->heap()->false_value();
5581 } 5581 }
5582 5582
5583 5583
5584 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasLocalProperty) { 5584 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasLocalProperty) {
5585 SealHandleScope shs(isolate); 5585 HandleScope scope(isolate);
5586 ASSERT(args.length() == 2); 5586 ASSERT(args.length() == 2);
5587 CONVERT_ARG_CHECKED(Name, key, 1); 5587 CONVERT_ARG_HANDLE_CHECKED(Name, key, 1);
5588 Handle<Object> object = args.at<Object>(0);
5588 5589
5589 uint32_t index; 5590 uint32_t index;
5590 const bool key_is_array_index = key->AsArrayIndex(&index); 5591 const bool key_is_array_index = key->AsArrayIndex(&index);
5591 5592
5592 Object* obj = args[0];
5593 // Only JS objects can have properties. 5593 // Only JS objects can have properties.
5594 if (obj->IsJSObject()) { 5594 if (object->IsJSObject()) {
5595 JSObject* object = JSObject::cast(obj); 5595 Handle<JSObject> js_obj = Handle<JSObject>::cast(object);
5596 // Fast case: either the key is a real named property or it is not 5596 // Fast case: either the key is a real named property or it is not
5597 // an array index and there are no interceptors or hidden 5597 // an array index and there are no interceptors or hidden
5598 // prototypes. 5598 // prototypes.
5599 if (object->HasRealNamedProperty(isolate, key)) { 5599 if (JSObject::HasRealNamedProperty(js_obj, key)) {
5600 ASSERT(!isolate->has_scheduled_exception()); 5600 ASSERT(!isolate->has_scheduled_exception());
5601 return isolate->heap()->true_value(); 5601 return isolate->heap()->true_value();
5602 } else { 5602 } else {
5603 RETURN_IF_SCHEDULED_EXCEPTION(isolate); 5603 RETURN_IF_SCHEDULED_EXCEPTION(isolate);
5604 } 5604 }
5605 Map* map = object->map(); 5605 Map* map = js_obj->map();
5606 if (!key_is_array_index && 5606 if (!key_is_array_index &&
5607 !map->has_named_interceptor() && 5607 !map->has_named_interceptor() &&
5608 !HeapObject::cast(map->prototype())->map()->is_hidden_prototype()) { 5608 !HeapObject::cast(map->prototype())->map()->is_hidden_prototype()) {
5609 return isolate->heap()->false_value(); 5609 return isolate->heap()->false_value();
5610 } 5610 }
5611 // Slow case. 5611 // Slow case.
5612 HandleScope scope(isolate);
5613 return HasLocalPropertyImplementation(isolate, 5612 return HasLocalPropertyImplementation(isolate,
5614 Handle<JSObject>(object), 5613 Handle<JSObject>(object),
5615 Handle<Name>(key)); 5614 Handle<Name>(key));
5616 } else if (obj->IsString() && key_is_array_index) { 5615 } else if (object->IsString() && key_is_array_index) {
5617 // Well, there is one exception: Handle [] on strings. 5616 // Well, there is one exception: Handle [] on strings.
5618 String* string = String::cast(obj); 5617 Handle<String> string = Handle<String>::cast(object);
5619 if (index < static_cast<uint32_t>(string->length())) { 5618 if (index < static_cast<uint32_t>(string->length())) {
5620 return isolate->heap()->true_value(); 5619 return isolate->heap()->true_value();
5621 } 5620 }
5622 } 5621 }
5623 return isolate->heap()->false_value(); 5622 return isolate->heap()->false_value();
5624 } 5623 }
5625 5624
5626 5625
5627 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasProperty) { 5626 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasProperty) {
5628 HandleScope scope(isolate); 5627 HandleScope scope(isolate);
(...skipping 9238 matching lines...) Expand 10 before | Expand all | Expand 10 after
14867 // Handle last resort GC and make sure to allow future allocations 14866 // Handle last resort GC and make sure to allow future allocations
14868 // to grow the heap without causing GCs (if possible). 14867 // to grow the heap without causing GCs (if possible).
14869 isolate->counters()->gc_last_resort_from_js()->Increment(); 14868 isolate->counters()->gc_last_resort_from_js()->Increment();
14870 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, 14869 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags,
14871 "Runtime::PerformGC"); 14870 "Runtime::PerformGC");
14872 } 14871 }
14873 } 14872 }
14874 14873
14875 14874
14876 } } // namespace v8::internal 14875 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698