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

Side by Side Diff: src/runtime.cc

Issue 238973003: Handlify Object::GetPrototype and (most) callers. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Minor Created 6 years, 8 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
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 4881 matching lines...) Expand 10 before | Expand all | Expand 10 after
4892 // Handle [] indexing on String objects 4892 // Handle [] indexing on String objects
4893 if (object->IsStringObjectWithCharacterAt(index)) { 4893 if (object->IsStringObjectWithCharacterAt(index)) {
4894 Handle<JSValue> js_value = Handle<JSValue>::cast(object); 4894 Handle<JSValue> js_value = Handle<JSValue>::cast(object);
4895 Handle<Object> result = 4895 Handle<Object> result =
4896 GetCharAt(Handle<String>(String::cast(js_value->value())), index); 4896 GetCharAt(Handle<String>(String::cast(js_value->value())), index);
4897 if (!result->IsUndefined()) return result; 4897 if (!result->IsUndefined()) return result;
4898 } 4898 }
4899 4899
4900 Handle<Object> result; 4900 Handle<Object> result;
4901 if (object->IsString() || object->IsNumber() || object->IsBoolean()) { 4901 if (object->IsString() || object->IsNumber() || object->IsBoolean()) {
4902 Handle<Object> proto(object->GetPrototype(isolate), isolate); 4902 Handle<Object> proto = Object::GetPrototype(isolate, object);
4903 return Object::GetElement(isolate, proto, index); 4903 return Object::GetElement(isolate, proto, index);
4904 } else { 4904 } else {
4905 return Object::GetElement(isolate, object, index); 4905 return Object::GetElement(isolate, object, index);
4906 } 4906 }
4907 } 4907 }
4908 4908
4909 4909
4910 MUST_USE_RESULT 4910 MUST_USE_RESULT
4911 static MaybeHandle<Name> ToName(Isolate* isolate, Handle<Object> key) { 4911 static MaybeHandle<Name> ToName(Isolate* isolate, Handle<Object> key) {
4912 if (key->IsName()) { 4912 if (key->IsName()) {
(...skipping 5703 matching lines...) Expand 10 before | Expand all | Expand 10 after
10616 // Intervals can span over some keys that are not in the object. 10616 // Intervals can span over some keys that are not in the object.
10617 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetArrayKeys) { 10617 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetArrayKeys) {
10618 HandleScope scope(isolate); 10618 HandleScope scope(isolate);
10619 ASSERT(args.length() == 2); 10619 ASSERT(args.length() == 2);
10620 CONVERT_ARG_HANDLE_CHECKED(JSObject, array, 0); 10620 CONVERT_ARG_HANDLE_CHECKED(JSObject, array, 0);
10621 CONVERT_NUMBER_CHECKED(uint32_t, length, Uint32, args[1]); 10621 CONVERT_NUMBER_CHECKED(uint32_t, length, Uint32, args[1]);
10622 if (array->elements()->IsDictionary()) { 10622 if (array->elements()->IsDictionary()) {
10623 Handle<FixedArray> keys = isolate->factory()->empty_fixed_array(); 10623 Handle<FixedArray> keys = isolate->factory()->empty_fixed_array();
10624 for (Handle<Object> p = array; 10624 for (Handle<Object> p = array;
10625 !p->IsNull(); 10625 !p->IsNull();
10626 p = Handle<Object>(p->GetPrototype(isolate), isolate)) { 10626 p = Object::GetPrototype(isolate, p)) {
10627 if (p->IsJSProxy() || JSObject::cast(*p)->HasIndexedInterceptor()) { 10627 if (p->IsJSProxy() || JSObject::cast(*p)->HasIndexedInterceptor()) {
10628 // Bail out if we find a proxy or interceptor, likely not worth 10628 // Bail out if we find a proxy or interceptor, likely not worth
10629 // collecting keys in that case. 10629 // collecting keys in that case.
10630 return *isolate->factory()->NewNumberFromUint(length); 10630 return *isolate->factory()->NewNumberFromUint(length);
10631 } 10631 }
10632 Handle<JSObject> current = Handle<JSObject>::cast(p); 10632 Handle<JSObject> current = Handle<JSObject>::cast(p);
10633 Handle<FixedArray> current_keys = 10633 Handle<FixedArray> current_keys =
10634 isolate->factory()->NewFixedArray( 10634 isolate->factory()->NewFixedArray(
10635 current->NumberOfLocalElements(NONE)); 10635 current->NumberOfLocalElements(NONE));
10636 current->GetLocalElementKeys(*current_keys, NONE); 10636 current->GetLocalElementKeys(*current_keys, NONE);
(...skipping 2181 matching lines...) Expand 10 before | Expand all | Expand 10 after
12818 RETURN_IF_EMPTY_HANDLE(isolate, eval_fun); 12818 RETURN_IF_EMPTY_HANDLE(isolate, eval_fun);
12819 12819
12820 Handle<Object> result; 12820 Handle<Object> result;
12821 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 12821 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
12822 isolate, result, 12822 isolate, result,
12823 Execution::Call(isolate, eval_fun, receiver, 0, NULL)); 12823 Execution::Call(isolate, eval_fun, receiver, 0, NULL));
12824 12824
12825 // Skip the global proxy as it has no properties and always delegates to the 12825 // Skip the global proxy as it has no properties and always delegates to the
12826 // real global object. 12826 // real global object.
12827 if (result->IsJSGlobalProxy()) { 12827 if (result->IsJSGlobalProxy()) {
12828 result = Handle<JSObject>(JSObject::cast(result->GetPrototype(isolate))); 12828 Handle<Object> proto = Object::GetPrototype(isolate, result);
12829 result = handle(JSObject::cast(*proto));
Yang 2014/04/15 13:10:48 Use Handle<JSObject>::cast here. That will not cre
12829 } 12830 }
12830 12831
12831 // Clear the oneshot breakpoints so that the debugger does not step further. 12832 // Clear the oneshot breakpoints so that the debugger does not step further.
12832 isolate->debug()->ClearStepping(); 12833 isolate->debug()->ClearStepping();
12833 return *result; 12834 return *result;
12834 } 12835 }
12835 12836
12836 12837
12837 // Evaluate a piece of JavaScript in the context of a stack frame for 12838 // Evaluate a piece of JavaScript in the context of a stack frame for
12838 // debugging. Things that need special attention are: 12839 // debugging. Things that need special attention are:
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
12973 } 12974 }
12974 12975
12975 12976
12976 // Helper function used by Runtime_DebugReferencedBy below. 12977 // Helper function used by Runtime_DebugReferencedBy below.
12977 static int DebugReferencedBy(HeapIterator* iterator, 12978 static int DebugReferencedBy(HeapIterator* iterator,
12978 JSObject* target, 12979 JSObject* target,
12979 Object* instance_filter, int max_references, 12980 Object* instance_filter, int max_references,
12980 FixedArray* instances, int instances_size, 12981 FixedArray* instances, int instances_size,
12981 JSFunction* arguments_function) { 12982 JSFunction* arguments_function) {
12982 Isolate* isolate = target->GetIsolate(); 12983 Isolate* isolate = target->GetIsolate();
12983 SealHandleScope shs(isolate); 12984 HandleScope shs(isolate);
12984 DisallowHeapAllocation no_allocation; 12985 DisallowHeapAllocation no_allocation;
12985 12986
12986 // Iterate the heap. 12987 // Iterate the heap.
12987 int count = 0; 12988 int count = 0;
12988 JSObject* last = NULL; 12989 JSObject* last = NULL;
12989 HeapObject* heap_obj = NULL; 12990 HeapObject* heap_obj = NULL;
12990 while (((heap_obj = iterator->next()) != NULL) && 12991 while (((heap_obj = iterator->next()) != NULL) &&
12991 (max_references == 0 || count < max_references)) { 12992 (max_references == 0 || count < max_references)) {
12992 // Only look at all JSObjects. 12993 // Only look at all JSObjects.
12993 if (heap_obj->IsJSObject()) { 12994 if (heap_obj->IsJSObject()) {
12994 // Skip context extension objects and argument arrays as these are 12995 // Skip context extension objects and argument arrays as these are
12995 // checked in the context of functions using them. 12996 // checked in the context of functions using them.
12996 JSObject* obj = JSObject::cast(heap_obj); 12997 JSObject* obj = JSObject::cast(heap_obj);
12997 if (obj->IsJSContextExtensionObject() || 12998 if (obj->IsJSContextExtensionObject() ||
12998 obj->map()->constructor() == arguments_function) { 12999 obj->map()->constructor() == arguments_function) {
12999 continue; 13000 continue;
13000 } 13001 }
13001 13002
13002 // Check if the JS object has a reference to the object looked for. 13003 // Check if the JS object has a reference to the object looked for.
13003 if (obj->ReferencesObject(target)) { 13004 if (obj->ReferencesObject(target)) {
13004 // Check instance filter if supplied. This is normally used to avoid 13005 // Check instance filter if supplied. This is normally used to avoid
13005 // references from mirror objects (see Runtime_IsInPrototypeChain). 13006 // references from mirror objects (see Runtime_IsInPrototypeChain).
13006 if (!instance_filter->IsUndefined()) { 13007 if (!instance_filter->IsUndefined()) {
13007 Object* V = obj; 13008 Object* V = obj;
13008 while (true) { 13009 while (true) {
13009 Object* prototype = V->GetPrototype(isolate); 13010 Object* prototype =
13011 *Object::GetPrototype(isolate, handle(V, isolate));
Yang 2014/04/15 13:10:48 This function is not handlified. Please don't do i
13010 if (prototype->IsNull()) { 13012 if (prototype->IsNull()) {
13011 break; 13013 break;
13012 } 13014 }
13013 if (instance_filter == prototype) { 13015 if (instance_filter == prototype) {
13014 obj = NULL; // Don't add this object. 13016 obj = NULL; // Don't add this object.
13015 break; 13017 break;
13016 } 13018 }
13017 V = prototype; 13019 V = prototype;
13018 } 13020 }
13019 } 13021 }
(...skipping 2088 matching lines...) Expand 10 before | Expand all | Expand 10 after
15108 } 15110 }
15109 } 15111 }
15110 15112
15111 15113
15112 void Runtime::OutOfMemory() { 15114 void Runtime::OutOfMemory() {
15113 Heap::FatalProcessOutOfMemory("CALL_AND_RETRY_LAST", true); 15115 Heap::FatalProcessOutOfMemory("CALL_AND_RETRY_LAST", true);
15114 UNREACHABLE(); 15116 UNREACHABLE();
15115 } 15117 }
15116 15118
15117 } } // namespace v8::internal 15119 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698