OLD | NEW |
---|---|
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 983 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
994 int hash = vector_hash(literal); | 994 int hash = vector_hash(literal); |
995 HashMap::Entry* entry = symbol_table_.Lookup(&literal, hash, true); | 995 HashMap::Entry* entry = symbol_table_.Lookup(&literal, hash, true); |
996 int id = static_cast<int>(reinterpret_cast<intptr_t>(entry->value)); | 996 int id = static_cast<int>(reinterpret_cast<intptr_t>(entry->value)); |
997 if (id == 0) { | 997 if (id == 0) { |
998 // Put (symbol_id_ + 1) into entry and increment it. | 998 // Put (symbol_id_ + 1) into entry and increment it. |
999 id = ++symbol_id_; | 999 id = ++symbol_id_; |
1000 entry->value = reinterpret_cast<void*>(id); | 1000 entry->value = reinterpret_cast<void*>(id); |
1001 Vector<Vector<const char> > symbol = symbol_entries_.AddBlock(1, literal); | 1001 Vector<Vector<const char> > symbol = symbol_entries_.AddBlock(1, literal); |
1002 entry->key = &symbol[0]; | 1002 entry->key = &symbol[0]; |
1003 } | 1003 } |
1004 symbol_store_.Add(id - 1); | 1004 WriteNumber(id - 1); |
1005 } | 1005 } |
1006 | 1006 |
1007 virtual Vector<unsigned> ExtractData() { | 1007 virtual Vector<unsigned> ExtractData() { |
1008 int function_size = function_store_.size(); | 1008 int function_size = function_store_.size(); |
1009 // Add terminator to symbols, then pad to unsigned size. | 1009 // Add terminator to symbols, then pad to unsigned size. |
1010 int symbol_size = symbol_store_.size(); | 1010 int symbol_size = symbol_store_.size(); |
1011 int padding = sizeof(unsigned) - (symbol_size % sizeof(unsigned)); | 1011 int padding = sizeof(unsigned) - (symbol_size % sizeof(unsigned)); |
1012 symbol_store_.AddBlock(padding, ScriptDataImpl::kNumberTerminator); | 1012 symbol_store_.AddBlock(padding, ScriptDataImpl::kNumberTerminator); |
1013 symbol_size += padding; | 1013 symbol_size += padding; |
1014 int total_size = ScriptDataImpl::kHeaderSize + function_size | 1014 int total_size = ScriptDataImpl::kHeaderSize + function_size |
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1496 CompilationZoneScope zone_scope(DONT_DELETE_ON_EXIT); | 1496 CompilationZoneScope zone_scope(DONT_DELETE_ON_EXIT); |
1497 | 1497 |
1498 HistogramTimerScope timer(&Counters::parse); | 1498 HistogramTimerScope timer(&Counters::parse); |
1499 Counters::total_parse_size.Increment(source->length()); | 1499 Counters::total_parse_size.Increment(source->length()); |
1500 fni_ = new FuncNameInferrer(); | 1500 fni_ = new FuncNameInferrer(); |
1501 | 1501 |
1502 // Initialize parser state. | 1502 // Initialize parser state. |
1503 source->TryFlatten(); | 1503 source->TryFlatten(); |
1504 scanner_.Initialize(source, JAVASCRIPT); | 1504 scanner_.Initialize(source, JAVASCRIPT); |
1505 ASSERT(target_stack_ == NULL); | 1505 ASSERT(target_stack_ == NULL); |
1506 if (pre_data_ != NULL) pre_data_->Initialize(); | |
1507 | |
Rico
2010/09/17 12:53:24
Delete extra blank line
| |
1506 | 1508 |
1507 // Compute the parsing mode. | 1509 // Compute the parsing mode. |
1508 mode_ = FLAG_lazy ? PARSE_LAZILY : PARSE_EAGERLY; | 1510 mode_ = FLAG_lazy ? PARSE_LAZILY : PARSE_EAGERLY; |
1509 if (allow_natives_syntax_ || extension_ != NULL) mode_ = PARSE_EAGERLY; | 1511 if (allow_natives_syntax_ || extension_ != NULL) mode_ = PARSE_EAGERLY; |
1510 | 1512 |
1511 Scope::Type type = | 1513 Scope::Type type = |
1512 in_global_context | 1514 in_global_context |
1513 ? Scope::GLOBAL_SCOPE | 1515 ? Scope::GLOBAL_SCOPE |
1514 : Scope::EVAL_SCOPE; | 1516 : Scope::EVAL_SCOPE; |
1515 Handle<String> no_name = factory()->EmptySymbol(); | 1517 Handle<String> no_name = factory()->EmptySymbol(); |
(...skipping 3969 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5485 PartialPreParser parser(no_script, allow_natives_syntax, extension); | 5487 PartialPreParser parser(no_script, allow_natives_syntax, extension); |
5486 if (!parser.PreParseProgram(source, stream)) return NULL; | 5488 if (!parser.PreParseProgram(source, stream)) return NULL; |
5487 // Extract the accumulated data from the recorder as a single | 5489 // Extract the accumulated data from the recorder as a single |
5488 // contiguous vector that we are responsible for disposing. | 5490 // contiguous vector that we are responsible for disposing. |
5489 Vector<unsigned> store = parser.recorder()->ExtractData(); | 5491 Vector<unsigned> store = parser.recorder()->ExtractData(); |
5490 return new ScriptDataImpl(store); | 5492 return new ScriptDataImpl(store); |
5491 } | 5493 } |
5492 | 5494 |
5493 | 5495 |
5494 void ScriptDataImpl::Initialize() { | 5496 void ScriptDataImpl::Initialize() { |
5497 // Resets pointers to initial value, if reusing a pre-used ScriptData. | |
Rico
2010/09/17 12:53:24
value->values
Lasse Reichstein
2010/09/17 12:55:13
Reworded to "Prepares script data for reading."
| |
5495 if (store_.length() >= kHeaderSize) { | 5498 if (store_.length() >= kHeaderSize) { |
5499 function_index_ = kHeaderSize; | |
5496 int symbol_data_offset = kHeaderSize + store_[kFunctionsSizeOffset]; | 5500 int symbol_data_offset = kHeaderSize + store_[kFunctionsSizeOffset]; |
5497 if (store_.length() > symbol_data_offset) { | 5501 if (store_.length() > symbol_data_offset) { |
5498 symbol_data_ = reinterpret_cast<byte*>(&store_[symbol_data_offset]); | 5502 symbol_data_ = reinterpret_cast<byte*>(&store_[symbol_data_offset]); |
5499 } else { | 5503 } else { |
5500 // Partial preparse causes no symbol information. | 5504 // Partial preparse causes no symbol information. |
5501 symbol_data_ = reinterpret_cast<byte*>(&store_[0] + store_.length()); | 5505 symbol_data_ = reinterpret_cast<byte*>(&store_[0] + store_.length()); |
5502 } | 5506 } |
5503 symbol_data_end_ = reinterpret_cast<byte*>(&store_[0] + store_.length()); | 5507 symbol_data_end_ = reinterpret_cast<byte*>(&store_[0] + store_.length()); |
5504 } | 5508 } |
5505 } | 5509 } |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5620 parser.ParseLazy(script_source, name, | 5624 parser.ParseLazy(script_source, name, |
5621 start_position, end_position, is_expression); | 5625 start_position, end_position, is_expression); |
5622 return result; | 5626 return result; |
5623 } | 5627 } |
5624 | 5628 |
5625 | 5629 |
5626 #undef NEW | 5630 #undef NEW |
5627 | 5631 |
5628 | 5632 |
5629 } } // namespace v8::internal | 5633 } } // namespace v8::internal |
OLD | NEW |