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

Side by Side Diff: src/runtime.cc

Issue 6538089: [Isolates] Speed up Context::Lookup by avoiding implicit TLS reads. (Closed)
Patch Set: Created 9 years, 10 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
« no previous file with comments | « src/contexts.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 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 5426 matching lines...) Expand 10 before | Expand all | Expand 10 after
5437 s->TryFlatten(); 5437 s->TryFlatten();
5438 const int length = static_cast<int>(Min<uint32_t>(s->length(), limit)); 5438 const int length = static_cast<int>(Min<uint32_t>(s->length(), limit));
5439 5439
5440 Handle<FixedArray> elements; 5440 Handle<FixedArray> elements;
5441 if (s->IsFlat() && s->IsAsciiRepresentation()) { 5441 if (s->IsFlat() && s->IsAsciiRepresentation()) {
5442 Object* obj; 5442 Object* obj;
5443 { MaybeObject* maybe_obj = 5443 { MaybeObject* maybe_obj =
5444 isolate->heap()->AllocateUninitializedFixedArray(length); 5444 isolate->heap()->AllocateUninitializedFixedArray(length);
5445 if (!maybe_obj->ToObject(&obj)) return maybe_obj; 5445 if (!maybe_obj->ToObject(&obj)) return maybe_obj;
5446 } 5446 }
5447 elements = Handle<FixedArray>(FixedArray::cast(obj)); 5447 elements = Handle<FixedArray>(FixedArray::cast(obj), isolate);
5448 5448
5449 Vector<const char> chars = s->ToAsciiVector(); 5449 Vector<const char> chars = s->ToAsciiVector();
5450 // Note, this will initialize all elements (not only the prefix) 5450 // Note, this will initialize all elements (not only the prefix)
5451 // to prevent GC from seeing partially initialized array. 5451 // to prevent GC from seeing partially initialized array.
5452 int num_copied_from_cache = CopyCachedAsciiCharsToArray(isolate->heap(), 5452 int num_copied_from_cache = CopyCachedAsciiCharsToArray(isolate->heap(),
5453 chars.start(), 5453 chars.start(),
5454 *elements, 5454 *elements,
5455 length); 5455 length);
5456 5456
5457 for (int i = num_copied_from_cache; i < length; ++i) { 5457 for (int i = num_copied_from_cache; i < length; ++i) {
(...skipping 2428 matching lines...) Expand 10 before | Expand all | Expand 10 after
7886 ASSERT(args.length() == 3); 7886 ASSERT(args.length() == 3);
7887 if (!args[0]->IsJSFunction()) { 7887 if (!args[0]->IsJSFunction()) {
7888 return MakePair(isolate->ThrowIllegalOperation(), NULL); 7888 return MakePair(isolate->ThrowIllegalOperation(), NULL);
7889 } 7889 }
7890 7890
7891 HandleScope scope(isolate); 7891 HandleScope scope(isolate);
7892 Handle<JSFunction> callee = args.at<JSFunction>(0); 7892 Handle<JSFunction> callee = args.at<JSFunction>(0);
7893 Handle<Object> receiver; // Will be overwritten. 7893 Handle<Object> receiver; // Will be overwritten.
7894 7894
7895 // Compute the calling context. 7895 // Compute the calling context.
7896 Handle<Context> context = Handle<Context>(isolate->context()); 7896 Handle<Context> context = Handle<Context>(isolate->context(), isolate);
7897 #ifdef DEBUG 7897 #ifdef DEBUG
7898 // Make sure Isolate::context() agrees with the old code that traversed 7898 // Make sure Isolate::context() agrees with the old code that traversed
7899 // the stack frames to compute the context. 7899 // the stack frames to compute the context.
7900 StackFrameLocator locator; 7900 StackFrameLocator locator;
7901 JavaScriptFrame* frame = locator.FindJavaScriptFrame(0); 7901 JavaScriptFrame* frame = locator.FindJavaScriptFrame(0);
7902 ASSERT(Context::cast(frame->context()) == *context); 7902 ASSERT(Context::cast(frame->context()) == *context);
7903 #endif 7903 #endif
7904 7904
7905 // Find where the 'eval' symbol is bound. It is unaliased only if 7905 // Find where the 'eval' symbol is bound. It is unaliased only if
7906 // it is bound in the global context. 7906 // it is bound in the global context.
7907 int index = -1; 7907 int index = -1;
7908 PropertyAttributes attributes = ABSENT; 7908 PropertyAttributes attributes = ABSENT;
7909 while (true) { 7909 while (true) {
7910 receiver = context->Lookup(isolate->factory()->eval_symbol(), 7910 receiver = context->Lookup(isolate->factory()->eval_symbol(),
7911 FOLLOW_PROTOTYPE_CHAIN, 7911 FOLLOW_PROTOTYPE_CHAIN,
7912 &index, &attributes); 7912 &index, &attributes);
7913 // Stop search when eval is found or when the global context is 7913 // Stop search when eval is found or when the global context is
7914 // reached. 7914 // reached.
7915 if (attributes != ABSENT || context->IsGlobalContext()) break; 7915 if (attributes != ABSENT || context->IsGlobalContext()) break;
7916 if (context->is_function_context()) { 7916 if (context->is_function_context()) {
7917 context = Handle<Context>(Context::cast(context->closure()->context())); 7917 context = Handle<Context>(Context::cast(context->closure()->context()),
7918 isolate);
7918 } else { 7919 } else {
7919 context = Handle<Context>(context->previous()); 7920 context = Handle<Context>(context->previous(), isolate);
7920 } 7921 }
7921 } 7922 }
7922 7923
7923 // If eval could not be resolved, it has been deleted and we need to 7924 // If eval could not be resolved, it has been deleted and we need to
7924 // throw a reference error. 7925 // throw a reference error.
7925 if (attributes == ABSENT) { 7926 if (attributes == ABSENT) {
7926 Handle<Object> name = isolate->factory()->eval_symbol(); 7927 Handle<Object> name = isolate->factory()->eval_symbol();
7927 Handle<Object> reference_error = 7928 Handle<Object> reference_error =
7928 isolate->factory()->NewReferenceError("not_defined", 7929 isolate->factory()->NewReferenceError("not_defined",
7929 HandleVector(&name, 1)); 7930 HandleVector(&name, 1));
7930 return MakePair(isolate->Throw(*reference_error), NULL); 7931 return MakePair(isolate->Throw(*reference_error), NULL);
7931 } 7932 }
7932 7933
7933 if (!context->IsGlobalContext()) { 7934 if (!context->IsGlobalContext()) {
7934 // 'eval' is not bound in the global context. Just call the function 7935 // 'eval' is not bound in the global context. Just call the function
7935 // with the given arguments. This is not necessarily the global eval. 7936 // with the given arguments. This is not necessarily the global eval.
7936 if (receiver->IsContext()) { 7937 if (receiver->IsContext()) {
7937 context = Handle<Context>::cast(receiver); 7938 context = Handle<Context>::cast(receiver);
7938 receiver = Handle<Object>(context->get(index), isolate); 7939 receiver = Handle<Object>(context->get(index), isolate);
7939 } else if (receiver->IsJSContextExtensionObject()) { 7940 } else if (receiver->IsJSContextExtensionObject()) {
7940 receiver = Handle<JSObject>( 7941 receiver = Handle<JSObject>(
7941 isolate->context()->global()->global_receiver()); 7942 isolate->context()->global()->global_receiver(), isolate);
7942 } 7943 }
7943 return MakePair(*callee, *receiver); 7944 return MakePair(*callee, *receiver);
7944 } 7945 }
7945 7946
7946 // 'eval' is bound in the global context, but it may have been overwritten. 7947 // 'eval' is bound in the global context, but it may have been overwritten.
7947 // Compare it to the builtin 'GlobalEval' function to make sure. 7948 // Compare it to the builtin 'GlobalEval' function to make sure.
7948 if (*callee != isolate->global_context()->global_eval_fun() || 7949 if (*callee != isolate->global_context()->global_eval_fun() ||
7949 !args[1]->IsString()) { 7950 !args[1]->IsString()) {
7950 return MakePair(*callee, 7951 return MakePair(*callee,
7951 isolate->context()->global()->global_receiver()); 7952 isolate->context()->global()->global_receiver());
(...skipping 3318 matching lines...) Expand 10 before | Expand all | Expand 10 after
11270 } else { 11271 } else {
11271 // Handle last resort GC and make sure to allow future allocations 11272 // Handle last resort GC and make sure to allow future allocations
11272 // to grow the heap without causing GCs (if possible). 11273 // to grow the heap without causing GCs (if possible).
11273 COUNTERS->gc_last_resort_from_js()->Increment(); 11274 COUNTERS->gc_last_resort_from_js()->Increment();
11274 HEAP->CollectAllGarbage(false); 11275 HEAP->CollectAllGarbage(false);
11275 } 11276 }
11276 } 11277 }
11277 11278
11278 11279
11279 } } // namespace v8::internal 11280 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/contexts.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698