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

Side by Side Diff: src/bootstrapper.cc

Issue 1113009: Merge 4205:4215 from bleeding_edge to partial_snapshots branch. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/partial_snapshots/
Patch Set: Created 10 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/bootstrapper.h ('k') | src/circular-queue.h » ('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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 52
53 void Initialize(bool create_heap_objects) { 53 void Initialize(bool create_heap_objects) {
54 cache_ = create_heap_objects ? Heap::empty_fixed_array() : NULL; 54 cache_ = create_heap_objects ? Heap::empty_fixed_array() : NULL;
55 } 55 }
56 56
57 void Iterate(ObjectVisitor* v) { 57 void Iterate(ObjectVisitor* v) {
58 v->VisitPointer(BitCast<Object**, FixedArray**>(&cache_)); 58 v->VisitPointer(BitCast<Object**, FixedArray**>(&cache_));
59 } 59 }
60 60
61 61
62 bool Lookup(Vector<const char> name, Handle<JSFunction>* handle) { 62 bool Lookup(Vector<const char> name, Handle<SharedFunctionInfo>* handle) {
63 for (int i = 0; i < cache_->length(); i+=2) { 63 for (int i = 0; i < cache_->length(); i+=2) {
64 SeqAsciiString* str = SeqAsciiString::cast(cache_->get(i)); 64 SeqAsciiString* str = SeqAsciiString::cast(cache_->get(i));
65 if (str->IsEqualTo(name)) { 65 if (str->IsEqualTo(name)) {
66 *handle = Handle<JSFunction>(JSFunction::cast(cache_->get(i + 1))); 66 *handle = Handle<SharedFunctionInfo>(
67 SharedFunctionInfo::cast(cache_->get(i + 1)));
67 return true; 68 return true;
68 } 69 }
69 } 70 }
70 return false; 71 return false;
71 } 72 }
72 73
73 74
74 void Add(Vector<const char> name, Handle<JSFunction> fun) { 75 void Add(Vector<const char> name, Handle<SharedFunctionInfo> shared) {
75 ASSERT(fun->IsBoilerplate());
76 HandleScope scope; 76 HandleScope scope;
77 int length = cache_->length(); 77 int length = cache_->length();
78 Handle<FixedArray> new_array = 78 Handle<FixedArray> new_array =
79 Factory::NewFixedArray(length + 2, TENURED); 79 Factory::NewFixedArray(length + 2, TENURED);
80 cache_->CopyTo(0, *new_array, 0, cache_->length()); 80 cache_->CopyTo(0, *new_array, 0, cache_->length());
81 cache_ = *new_array; 81 cache_ = *new_array;
82 Handle<String> str = Factory::NewStringFromAscii(name, TENURED); 82 Handle<String> str = Factory::NewStringFromAscii(name, TENURED);
83 cache_->set(length, *str); 83 cache_->set(length, *str);
84 cache_->set(length + 1, *fun); 84 cache_->set(length + 1, *shared);
85 Script::cast(fun->shared()->script())->set_type(Smi::FromInt(type_)); 85 Script::cast(shared->script())->set_type(Smi::FromInt(type_));
86 } 86 }
87 87
88 private: 88 private:
89 Script::Type type_; 89 Script::Type type_;
90 FixedArray* cache_; 90 FixedArray* cache_;
91 DISALLOW_COPY_AND_ASSIGN(SourceCodeCache); 91 DISALLOW_COPY_AND_ASSIGN(SourceCodeCache);
92 }; 92 };
93 93
94 static SourceCodeCache extensions_cache(Script::TYPE_EXTENSION); 94 static SourceCodeCache extensions_cache(Script::TYPE_EXTENSION);
95 // This is for delete, not delete[]. 95 // This is for delete, not delete[].
(...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after
853 } 853 }
854 854
855 855
856 bool Genesis::CompileScriptCached(Vector<const char> name, 856 bool Genesis::CompileScriptCached(Vector<const char> name,
857 Handle<String> source, 857 Handle<String> source,
858 SourceCodeCache* cache, 858 SourceCodeCache* cache,
859 v8::Extension* extension, 859 v8::Extension* extension,
860 Handle<Context> top_context, 860 Handle<Context> top_context,
861 bool use_runtime_context) { 861 bool use_runtime_context) {
862 HandleScope scope; 862 HandleScope scope;
863 Handle<JSFunction> boilerplate; 863 Handle<SharedFunctionInfo> function_info;
864 864
865 // If we can't find the function in the cache, we compile a new 865 // If we can't find the function in the cache, we compile a new
866 // function and insert it into the cache. 866 // function and insert it into the cache.
867 if (cache == NULL || !cache->Lookup(name, &boilerplate)) { 867 if (cache == NULL || !cache->Lookup(name, &function_info)) {
868 ASSERT(source->IsAsciiRepresentation()); 868 ASSERT(source->IsAsciiRepresentation());
869 Handle<String> script_name = Factory::NewStringFromUtf8(name); 869 Handle<String> script_name = Factory::NewStringFromUtf8(name);
870 boilerplate = Compiler::Compile( 870 function_info = Compiler::Compile(
871 source, 871 source,
872 script_name, 872 script_name,
873 0, 873 0,
874 0, 874 0,
875 extension, 875 extension,
876 NULL, 876 NULL,
877 Handle<String>::null(), 877 Handle<String>::null(),
878 use_runtime_context ? NATIVES_CODE : NOT_NATIVES_CODE); 878 use_runtime_context ? NATIVES_CODE : NOT_NATIVES_CODE);
879 if (boilerplate.is_null()) return false; 879 if (function_info.is_null()) return false;
880 if (cache != NULL) cache->Add(name, boilerplate); 880 if (cache != NULL) cache->Add(name, function_info);
881 } 881 }
882 882
883 // Setup the function context. Conceptually, we should clone the 883 // Setup the function context. Conceptually, we should clone the
884 // function before overwriting the context but since we're in a 884 // function before overwriting the context but since we're in a
885 // single-threaded environment it is not strictly necessary. 885 // single-threaded environment it is not strictly necessary.
886 ASSERT(top_context->IsGlobalContext()); 886 ASSERT(top_context->IsGlobalContext());
887 Handle<Context> context = 887 Handle<Context> context =
888 Handle<Context>(use_runtime_context 888 Handle<Context>(use_runtime_context
889 ? Handle<Context>(top_context->runtime_context()) 889 ? Handle<Context>(top_context->runtime_context())
890 : top_context); 890 : top_context);
891 Handle<JSFunction> fun = 891 Handle<JSFunction> fun =
892 Factory::NewFunctionFromBoilerplate(boilerplate, context); 892 Factory::NewFunctionFromSharedFunctionInfo(function_info, context);
893 893
894 // Call function using either the runtime object or the global 894 // Call function using either the runtime object or the global
895 // object as the receiver. Provide no parameters. 895 // object as the receiver. Provide no parameters.
896 Handle<Object> receiver = 896 Handle<Object> receiver =
897 Handle<Object>(use_runtime_context 897 Handle<Object>(use_runtime_context
898 ? top_context->builtins() 898 ? top_context->builtins()
899 : top_context->global()); 899 : top_context->global());
900 bool has_pending_exception; 900 bool has_pending_exception;
901 Handle<Object> result = 901 Handle<Object> result =
902 Execution::Call(fun, receiver, 0, NULL, &has_pending_exception); 902 Execution::Call(fun, receiver, 0, NULL, &has_pending_exception);
(...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after
1583 } 1583 }
1584 1584
1585 1585
1586 // Restore statics that are thread local. 1586 // Restore statics that are thread local.
1587 char* BootstrapperActive::RestoreState(char* from) { 1587 char* BootstrapperActive::RestoreState(char* from) {
1588 nesting_ = *reinterpret_cast<int*>(from); 1588 nesting_ = *reinterpret_cast<int*>(from);
1589 return from + sizeof(nesting_); 1589 return from + sizeof(nesting_);
1590 } 1590 }
1591 1591
1592 } } // namespace v8::internal 1592 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/bootstrapper.h ('k') | src/circular-queue.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698