| 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 29 matching lines...) Expand all Loading... |
| 40 namespace v8 { | 40 namespace v8 { |
| 41 namespace internal { | 41 namespace internal { |
| 42 | 42 |
| 43 // A SourceCodeCache uses a FixedArray to store pairs of | 43 // A SourceCodeCache uses a FixedArray to store pairs of |
| 44 // (AsciiString*, JSFunction*), mapping names of native code files | 44 // (AsciiString*, JSFunction*), mapping names of native code files |
| 45 // (runtime.js, etc.) to precompiled functions. Instead of mapping | 45 // (runtime.js, etc.) to precompiled functions. Instead of mapping |
| 46 // names to functions it might make sense to let the JS2C tool | 46 // names to functions it might make sense to let the JS2C tool |
| 47 // generate an index for each native JS file. | 47 // generate an index for each native JS file. |
| 48 class SourceCodeCache BASE_EMBEDDED { | 48 class SourceCodeCache BASE_EMBEDDED { |
| 49 public: | 49 public: |
| 50 explicit SourceCodeCache(Script::Type type): type_(type) { } | 50 explicit SourceCodeCache(Script::Type type): type_(type), cache_(NULL) { } |
| 51 | 51 |
| 52 void Initialize(bool create_heap_objects) { | 52 void Initialize(bool create_heap_objects) { |
| 53 if (create_heap_objects) { | 53 cache_ = create_heap_objects ? Heap::empty_fixed_array() : NULL; |
| 54 cache_ = Heap::empty_fixed_array(); | |
| 55 } else { | |
| 56 cache_ = NULL; | |
| 57 } | |
| 58 } | 54 } |
| 59 | 55 |
| 60 void Iterate(ObjectVisitor* v) { | 56 void Iterate(ObjectVisitor* v) { |
| 61 v->VisitPointer(bit_cast<Object**, FixedArray**>(&cache_)); | 57 v->VisitPointer(bit_cast<Object**, FixedArray**>(&cache_)); |
| 62 } | 58 } |
| 63 | 59 |
| 64 | 60 |
| 65 bool Lookup(Vector<const char> name, Handle<JSFunction>* handle) { | 61 bool Lookup(Vector<const char> name, Handle<JSFunction>* handle) { |
| 66 for (int i = 0; i < cache_->length(); i+=2) { | 62 for (int i = 0; i < cache_->length(); i+=2) { |
| 67 SeqAsciiString* str = SeqAsciiString::cast(cache_->get(i)); | 63 SeqAsciiString* str = SeqAsciiString::cast(cache_->get(i)); |
| (...skipping 1534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1602 } | 1598 } |
| 1603 | 1599 |
| 1604 | 1600 |
| 1605 // Restore statics that are thread local. | 1601 // Restore statics that are thread local. |
| 1606 char* Genesis::RestoreState(char* from) { | 1602 char* Genesis::RestoreState(char* from) { |
| 1607 current_ = *reinterpret_cast<Genesis**>(from); | 1603 current_ = *reinterpret_cast<Genesis**>(from); |
| 1608 return from + sizeof(current_); | 1604 return from + sizeof(current_); |
| 1609 } | 1605 } |
| 1610 | 1606 |
| 1611 } } // namespace v8::internal | 1607 } } // namespace v8::internal |
| OLD | NEW |