| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_BOOTSTRAPPER_H_ | 5 #ifndef V8_BOOTSTRAPPER_H_ |
| 6 #define V8_BOOTSTRAPPER_H_ | 6 #define V8_BOOTSTRAPPER_H_ |
| 7 | 7 |
| 8 #include "src/factory.h" | 8 #include "src/factory.h" |
| 9 | 9 |
| 10 namespace v8 { | 10 namespace v8 { |
| 11 namespace internal { | 11 namespace internal { |
| 12 | 12 |
| 13 // A SourceCodeCache uses a FixedArray to store pairs of | 13 // A SourceCodeCache uses a FixedArray to store pairs of |
| 14 // (AsciiString*, JSFunction*), mapping names of native code files | 14 // (AsciiString*, JSFunction*), mapping names of native code files |
| 15 // (runtime.js, etc.) to precompiled functions. Instead of mapping | 15 // (runtime.js, etc.) to precompiled functions. Instead of mapping |
| 16 // names to functions it might make sense to let the JS2C tool | 16 // names to functions it might make sense to let the JS2C tool |
| 17 // generate an index for each native JS file. | 17 // generate an index for each native JS file. |
| 18 class SourceCodeCache FINAL BASE_EMBEDDED { | 18 class SourceCodeCache FINAL BASE_EMBEDDED { |
| 19 public: | 19 public: |
| 20 explicit SourceCodeCache(Script::Type type): type_(type), cache_(NULL) { } | 20 explicit SourceCodeCache(Script::Type type): type_(type), cache_(NULL) { } |
| 21 | 21 |
| 22 void Initialize(Isolate* isolate, bool create_heap_objects) { | 22 void Initialize(Isolate* isolate, bool create_heap_objects) { |
| 23 cache_ = create_heap_objects ? isolate->heap()->empty_fixed_array() : NULL; | 23 cache_ = create_heap_objects ? isolate->heap()->empty_fixed_array() : NULL; |
| 24 } | 24 } |
| 25 | 25 |
| 26 void Iterate(ObjectVisitor* v) { | 26 void Iterate(ObjectVisitor* v) { |
| 27 v->VisitPointer(BitCast<Object**, FixedArray**>(&cache_)); | 27 v->VisitPointer(bit_cast<Object**, FixedArray**>(&cache_)); |
| 28 } | 28 } |
| 29 | 29 |
| 30 bool Lookup(Vector<const char> name, Handle<SharedFunctionInfo>* handle) { | 30 bool Lookup(Vector<const char> name, Handle<SharedFunctionInfo>* handle) { |
| 31 for (int i = 0; i < cache_->length(); i+=2) { | 31 for (int i = 0; i < cache_->length(); i+=2) { |
| 32 SeqOneByteString* str = SeqOneByteString::cast(cache_->get(i)); | 32 SeqOneByteString* str = SeqOneByteString::cast(cache_->get(i)); |
| 33 if (str->IsUtf8EqualTo(name)) { | 33 if (str->IsUtf8EqualTo(name)) { |
| 34 *handle = Handle<SharedFunctionInfo>( | 34 *handle = Handle<SharedFunctionInfo>( |
| 35 SharedFunctionInfo::cast(cache_->get(i + 1))); | 35 SharedFunctionInfo::cast(cache_->get(i + 1))); |
| 36 return true; | 36 return true; |
| 37 } | 37 } |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 virtual size_t length() const OVERRIDE { return length_; } | 162 virtual size_t length() const OVERRIDE { return length_; } |
| 163 | 163 |
| 164 private: | 164 private: |
| 165 const char* data_; | 165 const char* data_; |
| 166 size_t length_; | 166 size_t length_; |
| 167 }; | 167 }; |
| 168 | 168 |
| 169 }} // namespace v8::internal | 169 }} // namespace v8::internal |
| 170 | 170 |
| 171 #endif // V8_BOOTSTRAPPER_H_ | 171 #endif // V8_BOOTSTRAPPER_H_ |
| OLD | NEW |