| OLD | NEW |
| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 } | 56 } |
| 57 } | 57 } |
| 58 | 58 |
| 59 void Iterate(ObjectVisitor* v) { | 59 void Iterate(ObjectVisitor* v) { |
| 60 v->VisitPointer(bit_cast<Object**, FixedArray**>(&cache_)); | 60 v->VisitPointer(bit_cast<Object**, FixedArray**>(&cache_)); |
| 61 } | 61 } |
| 62 | 62 |
| 63 | 63 |
| 64 bool Lookup(Vector<const char> name, Handle<JSFunction>* handle) { | 64 bool Lookup(Vector<const char> name, Handle<JSFunction>* handle) { |
| 65 for (int i = 0; i < cache_->length(); i+=2) { | 65 for (int i = 0; i < cache_->length(); i+=2) { |
| 66 AsciiString* str = AsciiString::cast(cache_->get(i)); | 66 SeqAsciiString* str = SeqAsciiString::cast(cache_->get(i)); |
| 67 if (str->IsEqualTo(name)) { | 67 if (str->IsEqualTo(name)) { |
| 68 *handle = Handle<JSFunction>(JSFunction::cast(cache_->get(i + 1))); | 68 *handle = Handle<JSFunction>(JSFunction::cast(cache_->get(i + 1))); |
| 69 return true; | 69 return true; |
| 70 } | 70 } |
| 71 } | 71 } |
| 72 return false; | 72 return false; |
| 73 } | 73 } |
| 74 | 74 |
| 75 | 75 |
| 76 void Add(Vector<const char> name, Handle<JSFunction> fun) { | 76 void Add(Vector<const char> name, Handle<JSFunction> fun) { |
| (...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 744 SourceCodeCache* cache, | 744 SourceCodeCache* cache, |
| 745 v8::Extension* extension, | 745 v8::Extension* extension, |
| 746 bool use_runtime_context) { | 746 bool use_runtime_context) { |
| 747 HandleScope scope; | 747 HandleScope scope; |
| 748 Handle<JSFunction> boilerplate; | 748 Handle<JSFunction> boilerplate; |
| 749 | 749 |
| 750 // If we can't find the function in the cache, we compile a new | 750 // If we can't find the function in the cache, we compile a new |
| 751 // function and insert it into the cache. | 751 // function and insert it into the cache. |
| 752 if (!cache->Lookup(name, &boilerplate)) { | 752 if (!cache->Lookup(name, &boilerplate)) { |
| 753 #ifdef DEBUG | 753 #ifdef DEBUG |
| 754 ASSERT(source->IsAscii()); | 754 ASSERT(source->IsAsciiRepresentation()); |
| 755 #endif | 755 #endif |
| 756 Handle<String> script_name = Factory::NewStringFromUtf8(name); | 756 Handle<String> script_name = Factory::NewStringFromUtf8(name); |
| 757 boilerplate = | 757 boilerplate = |
| 758 Compiler::Compile(source, script_name, 0, 0, extension, NULL); | 758 Compiler::Compile(source, script_name, 0, 0, extension, NULL); |
| 759 if (boilerplate.is_null()) return false; | 759 if (boilerplate.is_null()) return false; |
| 760 cache->Add(name, boilerplate); | 760 cache->Add(name, boilerplate); |
| 761 } | 761 } |
| 762 | 762 |
| 763 // Setup the function context. Conceptually, we should clone the | 763 // Setup the function context. Conceptually, we should clone the |
| 764 // function before overwriting the context but since we're in a | 764 // function before overwriting the context but since we're in a |
| (...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1334 if (!ConfigureGlobalObject(global_template)) return; | 1334 if (!ConfigureGlobalObject(global_template)) return; |
| 1335 | 1335 |
| 1336 if (!InstallExtensions(extensions)) return; | 1336 if (!InstallExtensions(extensions)) return; |
| 1337 | 1337 |
| 1338 if (!InstallSpecialObjects()) return; | 1338 if (!InstallSpecialObjects()) return; |
| 1339 | 1339 |
| 1340 result_ = global_context_; | 1340 result_ = global_context_; |
| 1341 } | 1341 } |
| 1342 | 1342 |
| 1343 } } // namespace v8::internal | 1343 } } // namespace v8::internal |
| OLD | NEW |