| 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 26 matching lines...) Expand all Loading... |
| 37 | 37 |
| 38 // A SourceCodeCache uses a FixedArray to store pairs of | 38 // A SourceCodeCache uses a FixedArray to store pairs of |
| 39 // (AsciiString*, JSFunction*), mapping names of native code files | 39 // (AsciiString*, JSFunction*), mapping names of native code files |
| 40 // (runtime.js, etc.) to precompiled functions. Instead of mapping | 40 // (runtime.js, etc.) to precompiled functions. Instead of mapping |
| 41 // names to functions it might make sense to let the JS2C tool | 41 // names to functions it might make sense to let the JS2C tool |
| 42 // generate an index for each native JS file. | 42 // generate an index for each native JS file. |
| 43 class SourceCodeCache BASE_EMBEDDED { | 43 class SourceCodeCache BASE_EMBEDDED { |
| 44 public: | 44 public: |
| 45 explicit SourceCodeCache(Script::Type type): type_(type), cache_(NULL) { } | 45 explicit SourceCodeCache(Script::Type type): type_(type), cache_(NULL) { } |
| 46 | 46 |
| 47 void Initialize(bool create_heap_objects) { | 47 void Initialize(Isolate* isolate, bool create_heap_objects) { |
| 48 cache_ = create_heap_objects ? | 48 cache_ = create_heap_objects ? isolate->heap()->empty_fixed_array() : NULL; |
| 49 Isolate::Current()->heap()->empty_fixed_array() : NULL; | |
| 50 } | 49 } |
| 51 | 50 |
| 52 void Iterate(ObjectVisitor* v) { | 51 void Iterate(ObjectVisitor* v) { |
| 53 v->VisitPointer(BitCast<Object**, FixedArray**>(&cache_)); | 52 v->VisitPointer(BitCast<Object**, FixedArray**>(&cache_)); |
| 54 } | 53 } |
| 55 | 54 |
| 56 bool Lookup(Vector<const char> name, Handle<SharedFunctionInfo>* handle) { | 55 bool Lookup(Vector<const char> name, Handle<SharedFunctionInfo>* handle) { |
| 57 for (int i = 0; i < cache_->length(); i+=2) { | 56 for (int i = 0; i < cache_->length(); i+=2) { |
| 58 SeqOneByteString* str = SeqOneByteString::cast(cache_->get(i)); | 57 SeqOneByteString* str = SeqOneByteString::cast(cache_->get(i)); |
| 59 if (str->IsUtf8EqualTo(name)) { | 58 if (str->IsUtf8EqualTo(name)) { |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 return length_; | 186 return length_; |
| 188 } | 187 } |
| 189 private: | 188 private: |
| 190 const char* data_; | 189 const char* data_; |
| 191 size_t length_; | 190 size_t length_; |
| 192 }; | 191 }; |
| 193 | 192 |
| 194 }} // namespace v8::internal | 193 }} // namespace v8::internal |
| 195 | 194 |
| 196 #endif // V8_BOOTSTRAPPER_H_ | 195 #endif // V8_BOOTSTRAPPER_H_ |
| OLD | NEW |