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

Side by Side Diff: src/runtime.cc

Issue 12319144: Avoid TLS accesses in Object::Lookup and Object::GetPrototype. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Simplified Object::GetPrototype a bit Created 7 years, 9 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/property.h ('k') | src/string-stream.cc » ('j') | 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 941 matching lines...) Expand 10 before | Expand all | Expand 10 after
952 // We don't expect access checks to be needed on JSProxy objects. 952 // We don't expect access checks to be needed on JSProxy objects.
953 ASSERT(!obj->IsAccessCheckNeeded() || obj->IsJSObject()); 953 ASSERT(!obj->IsAccessCheckNeeded() || obj->IsJSObject());
954 do { 954 do {
955 if (obj->IsAccessCheckNeeded() && 955 if (obj->IsAccessCheckNeeded() &&
956 !isolate->MayNamedAccess(JSObject::cast(obj), 956 !isolate->MayNamedAccess(JSObject::cast(obj),
957 isolate->heap()->Proto_symbol(), 957 isolate->heap()->Proto_symbol(),
958 v8::ACCESS_GET)) { 958 v8::ACCESS_GET)) {
959 isolate->ReportFailedAccessCheck(JSObject::cast(obj), v8::ACCESS_GET); 959 isolate->ReportFailedAccessCheck(JSObject::cast(obj), v8::ACCESS_GET);
960 return isolate->heap()->undefined_value(); 960 return isolate->heap()->undefined_value();
961 } 961 }
962 obj = obj->GetPrototype(); 962 obj = obj->GetPrototype(isolate);
963 } while (obj->IsJSObject() && 963 } while (obj->IsJSObject() &&
964 JSObject::cast(obj)->map()->is_hidden_prototype()); 964 JSObject::cast(obj)->map()->is_hidden_prototype());
965 return obj; 965 return obj;
966 } 966 }
967 967
968 968
969 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsInPrototypeChain) { 969 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsInPrototypeChain) {
970 NoHandleAllocation ha(isolate); 970 NoHandleAllocation ha(isolate);
971 ASSERT(args.length() == 2); 971 ASSERT(args.length() == 2);
972 // See ECMA-262, section 15.3.5.3, page 88 (steps 5 - 8). 972 // See ECMA-262, section 15.3.5.3, page 88 (steps 5 - 8).
973 Object* O = args[0]; 973 Object* O = args[0];
974 Object* V = args[1]; 974 Object* V = args[1];
975 while (true) { 975 while (true) {
976 Object* prototype = V->GetPrototype(); 976 Object* prototype = V->GetPrototype(isolate);
977 if (prototype->IsNull()) return isolate->heap()->false_value(); 977 if (prototype->IsNull()) return isolate->heap()->false_value();
978 if (O == prototype) return isolate->heap()->true_value(); 978 if (O == prototype) return isolate->heap()->true_value();
979 V = prototype; 979 V = prototype;
980 } 980 }
981 } 981 }
982 982
983 983
984 static bool CheckAccessException(Object* callback, 984 static bool CheckAccessException(Object* callback,
985 v8::AccessType access_type) { 985 v8::AccessType access_type) {
986 if (callback->IsAccessorInfo()) { 986 if (callback->IsAccessorInfo()) {
(...skipping 2905 matching lines...) Expand 10 before | Expand all | Expand 10 after
3892 3892
3893 // Handle [] indexing on String objects 3893 // Handle [] indexing on String objects
3894 if (object->IsStringObjectWithCharacterAt(index)) { 3894 if (object->IsStringObjectWithCharacterAt(index)) {
3895 Handle<JSValue> js_value = Handle<JSValue>::cast(object); 3895 Handle<JSValue> js_value = Handle<JSValue>::cast(object);
3896 Handle<Object> result = 3896 Handle<Object> result =
3897 GetCharAt(Handle<String>(String::cast(js_value->value())), index); 3897 GetCharAt(Handle<String>(String::cast(js_value->value())), index);
3898 if (!result->IsUndefined()) return *result; 3898 if (!result->IsUndefined()) return *result;
3899 } 3899 }
3900 3900
3901 if (object->IsString() || object->IsNumber() || object->IsBoolean()) { 3901 if (object->IsString() || object->IsNumber() || object->IsBoolean()) {
3902 return object->GetPrototype()->GetElement(index); 3902 return object->GetPrototype(isolate)->GetElement(index);
3903 } 3903 }
3904 3904
3905 return object->GetElement(index); 3905 return object->GetElement(index);
3906 } 3906 }
3907 3907
3908 3908
3909 MaybeObject* Runtime::GetObjectProperty(Isolate* isolate, 3909 MaybeObject* Runtime::GetObjectProperty(Isolate* isolate,
3910 Handle<Object> object, 3910 Handle<Object> object,
3911 Handle<Object> key) { 3911 Handle<Object> key) {
3912 HandleScope scope(isolate); 3912 HandleScope scope(isolate);
(...skipping 8119 matching lines...) Expand 10 before | Expand all | Expand 10 after
12032 &has_pending_exception); 12032 &has_pending_exception);
12033 if (eval_disabled) { 12033 if (eval_disabled) {
12034 native_context->set_allow_code_gen_from_strings( 12034 native_context->set_allow_code_gen_from_strings(
12035 isolate->heap()->false_value()); 12035 isolate->heap()->false_value());
12036 } 12036 }
12037 if (has_pending_exception) return Failure::Exception(); 12037 if (has_pending_exception) return Failure::Exception();
12038 12038
12039 // Skip the global proxy as it has no properties and always delegates to the 12039 // Skip the global proxy as it has no properties and always delegates to the
12040 // real global object. 12040 // real global object.
12041 if (result->IsJSGlobalProxy()) { 12041 if (result->IsJSGlobalProxy()) {
12042 result = Handle<JSObject>(JSObject::cast(result->GetPrototype())); 12042 result = Handle<JSObject>(JSObject::cast(result->GetPrototype(isolate)));
12043 } 12043 }
12044 12044
12045 return *result; 12045 return *result;
12046 } 12046 }
12047 12047
12048 12048
12049 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugEvaluateGlobal) { 12049 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugEvaluateGlobal) {
12050 HandleScope scope(isolate); 12050 HandleScope scope(isolate);
12051 12051
12052 // Check the execution state and decode arguments frame and source to be 12052 // Check the execution state and decode arguments frame and source to be
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
12146 return *result; 12146 return *result;
12147 } 12147 }
12148 12148
12149 12149
12150 // Helper function used by Runtime_DebugReferencedBy below. 12150 // Helper function used by Runtime_DebugReferencedBy below.
12151 static int DebugReferencedBy(HeapIterator* iterator, 12151 static int DebugReferencedBy(HeapIterator* iterator,
12152 JSObject* target, 12152 JSObject* target,
12153 Object* instance_filter, int max_references, 12153 Object* instance_filter, int max_references,
12154 FixedArray* instances, int instances_size, 12154 FixedArray* instances, int instances_size,
12155 JSFunction* arguments_function) { 12155 JSFunction* arguments_function) {
12156 NoHandleAllocation ha(target->GetIsolate()); 12156 Isolate* isolate = target->GetIsolate();
12157 NoHandleAllocation ha(isolate);
12157 AssertNoAllocation no_alloc; 12158 AssertNoAllocation no_alloc;
12158 12159
12159 // Iterate the heap. 12160 // Iterate the heap.
12160 int count = 0; 12161 int count = 0;
12161 JSObject* last = NULL; 12162 JSObject* last = NULL;
12162 HeapObject* heap_obj = NULL; 12163 HeapObject* heap_obj = NULL;
12163 while (((heap_obj = iterator->next()) != NULL) && 12164 while (((heap_obj = iterator->next()) != NULL) &&
12164 (max_references == 0 || count < max_references)) { 12165 (max_references == 0 || count < max_references)) {
12165 // Only look at all JSObjects. 12166 // Only look at all JSObjects.
12166 if (heap_obj->IsJSObject()) { 12167 if (heap_obj->IsJSObject()) {
12167 // Skip context extension objects and argument arrays as these are 12168 // Skip context extension objects and argument arrays as these are
12168 // checked in the context of functions using them. 12169 // checked in the context of functions using them.
12169 JSObject* obj = JSObject::cast(heap_obj); 12170 JSObject* obj = JSObject::cast(heap_obj);
12170 if (obj->IsJSContextExtensionObject() || 12171 if (obj->IsJSContextExtensionObject() ||
12171 obj->map()->constructor() == arguments_function) { 12172 obj->map()->constructor() == arguments_function) {
12172 continue; 12173 continue;
12173 } 12174 }
12174 12175
12175 // Check if the JS object has a reference to the object looked for. 12176 // Check if the JS object has a reference to the object looked for.
12176 if (obj->ReferencesObject(target)) { 12177 if (obj->ReferencesObject(target)) {
12177 // Check instance filter if supplied. This is normally used to avoid 12178 // Check instance filter if supplied. This is normally used to avoid
12178 // references from mirror objects (see Runtime_IsInPrototypeChain). 12179 // references from mirror objects (see Runtime_IsInPrototypeChain).
12179 if (!instance_filter->IsUndefined()) { 12180 if (!instance_filter->IsUndefined()) {
12180 Object* V = obj; 12181 Object* V = obj;
12181 while (true) { 12182 while (true) {
12182 Object* prototype = V->GetPrototype(); 12183 Object* prototype = V->GetPrototype(isolate);
12183 if (prototype->IsNull()) { 12184 if (prototype->IsNull()) {
12184 break; 12185 break;
12185 } 12186 }
12186 if (instance_filter == prototype) { 12187 if (instance_filter == prototype) {
12187 obj = NULL; // Don't add this object. 12188 obj = NULL; // Don't add this object.
12188 break; 12189 break;
12189 } 12190 }
12190 V = prototype; 12191 V = prototype;
12191 } 12192 }
12192 } 12193 }
(...skipping 1049 matching lines...) Expand 10 before | Expand all | Expand 10 after
13242 Handle<JSWeakMap> weakmap = 13243 Handle<JSWeakMap> weakmap =
13243 Handle<JSWeakMap>::cast(isolate->factory()->NewJSObjectFromMap(map)); 13244 Handle<JSWeakMap>::cast(isolate->factory()->NewJSObjectFromMap(map));
13244 return WeakMapInitialize(isolate, weakmap); 13245 return WeakMapInitialize(isolate, weakmap);
13245 } 13246 }
13246 13247
13247 13248
13248 RUNTIME_FUNCTION(MaybeObject*, Runtime_UnwrapGlobalProxy) { 13249 RUNTIME_FUNCTION(MaybeObject*, Runtime_UnwrapGlobalProxy) {
13249 ASSERT(args.length() == 1); 13250 ASSERT(args.length() == 1);
13250 Object* object = args[0]; 13251 Object* object = args[0];
13251 if (object->IsJSGlobalProxy()) { 13252 if (object->IsJSGlobalProxy()) {
13252 object = object->GetPrototype(); 13253 object = object->GetPrototype(isolate);
13253 if (object->IsNull()) return isolate->heap()->undefined_value(); 13254 if (object->IsNull()) return isolate->heap()->undefined_value();
13254 } 13255 }
13255 return object; 13256 return object;
13256 } 13257 }
13257 13258
13258 13259
13259 // ---------------------------------------------------------------------------- 13260 // ----------------------------------------------------------------------------
13260 // Implementation of Runtime 13261 // Implementation of Runtime
13261 13262
13262 #define F(name, number_of_args, result_size) \ 13263 #define F(name, number_of_args, result_size) \
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
13335 // Handle last resort GC and make sure to allow future allocations 13336 // Handle last resort GC and make sure to allow future allocations
13336 // to grow the heap without causing GCs (if possible). 13337 // to grow the heap without causing GCs (if possible).
13337 isolate->counters()->gc_last_resort_from_js()->Increment(); 13338 isolate->counters()->gc_last_resort_from_js()->Increment();
13338 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, 13339 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags,
13339 "Runtime::PerformGC"); 13340 "Runtime::PerformGC");
13340 } 13341 }
13341 } 13342 }
13342 13343
13343 13344
13344 } } // namespace v8::internal 13345 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/property.h ('k') | src/string-stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698