Chromium Code Reviews| Index: runtime/vm/object.cc |
| diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc |
| index 04c4e6824dc5cc8a75cef79673ad47d4fa45a660..3c99ebeb223bdedf1501014b77989a6ed82f30cf 100644 |
| --- a/runtime/vm/object.cc |
| +++ b/runtime/vm/object.cc |
| @@ -7453,6 +7453,7 @@ void Function::SetDeoptReasonForAll(intptr_t deopt_id, |
| } |
| bool Function::CheckSourceFingerprint(const char* prefix, int32_t fp) const { |
| + /* |
|
rmacnak
2017/08/23 01:16:50
if (Isolate::Current()->flags->obfuscate) return;
Vyacheslav Egorov (Google)
2017/08/23 15:54:52
Done.
|
| if ((kernel_offset() <= 0) && (SourceFingerprint() != fp)) { |
| const bool recalculatingFingerprints = false; |
| if (recalculatingFingerprints) { |
| @@ -7467,7 +7468,7 @@ bool Function::CheckSourceFingerprint(const char* prefix, int32_t fp) const { |
| ToFullyQualifiedCString(), fp, SourceFingerprint()); |
| return false; |
| } |
| - } |
| + }*/ |
| return true; |
| } |
| @@ -8656,19 +8657,29 @@ class CompressedTokenStreamData : public Scanner::TokenCollector { |
| static const bool kPrintTokenObjects = false; |
| CompressedTokenStreamData(const GrowableObjectArray& ta, |
| - CompressedTokenMap* map) |
| + CompressedTokenMap* map, |
| + Obfuscator* obfuscator) |
| : buffer_(NULL), |
| stream_(&buffer_, Reallocate, kInitialBufferSize), |
| token_objects_(ta), |
| tokens_(map), |
| + str_(String::Handle()), |
| value_(Object::Handle()), |
| fresh_index_smi_(Smi::Handle()), |
| - num_tokens_collected_(0) {} |
| + num_tokens_collected_(0), |
| + obfuscator_(obfuscator) {} |
| virtual ~CompressedTokenStreamData() {} |
| virtual void AddToken(const Scanner::TokenDescriptor& token) { |
| if (token.kind == Token::kIDENT) { // Identifier token. |
| AddIdentToken(*token.literal); |
| + } else if (token.kind == Token::kINTERPOL_VAR) { |
| + str_ = token.literal->raw(); |
| + str_ = obfuscator_->Rename(str_); |
| + |
| + Scanner::TokenDescriptor token_copy = token; |
| + token_copy.literal = &str_; |
| + AddLiteralToken(token_copy); |
| } else if (Token::NeedsLiteralToken(token.kind)) { // Literal token. |
| AddLiteralToken(token); |
| } else { // Keyword, pseudo keyword etc. |
| @@ -8691,15 +8702,17 @@ class CompressedTokenStreamData : public Scanner::TokenCollector { |
| void AddIdentToken(const String& ident) { |
| ASSERT(ident.IsSymbol()); |
| const intptr_t fresh_index = token_objects_.Length(); |
| + str_ = ident.raw(); |
| + str_ = obfuscator_->Rename(str_); |
| fresh_index_smi_ = Smi::New(fresh_index); |
| intptr_t index = Smi::Value( |
| Smi::RawCast(tokens_->InsertOrGetValue(ident, fresh_index_smi_))); |
| if (index == fresh_index) { |
| - token_objects_.Add(ident); |
| + token_objects_.Add(str_); |
| if (kPrintTokenObjects) { |
| int iid = Isolate::Current()->main_port() % 1024; |
| - OS::Print("ident %03x %p <%s>\n", iid, ident.raw(), |
| - ident.ToCString()); |
| + OS::Print("%03x ident <%s -> %s>\n", iid, ident.ToCString(), |
| + str_.ToCString()); |
| } |
| } |
| WriteIndex(index); |
| @@ -8762,9 +8775,11 @@ class CompressedTokenStreamData : public Scanner::TokenCollector { |
| WriteStream stream_; |
| const GrowableObjectArray& token_objects_; |
| CompressedTokenMap* tokens_; |
| + String& str_; |
| Object& value_; |
| Smi& fresh_index_smi_; |
| intptr_t num_tokens_collected_; |
| + Obfuscator* obfuscator_; |
| DISALLOW_COPY_AND_ASSIGN(CompressedTokenStreamData); |
| }; |
| @@ -8794,8 +8809,9 @@ RawTokenStream* TokenStream::New(const String& source, |
| token_objects_map = HashTables::New<CompressedTokenMap>( |
| kInitialPrivateCapacity, Heap::kOld); |
| } |
| + Obfuscator obfuscator(thread, private_key); |
| CompressedTokenMap map(token_objects_map.raw()); |
| - CompressedTokenStreamData data(token_objects, &map); |
| + CompressedTokenStreamData data(token_objects, &map, &obfuscator); |
| Scanner scanner(source, private_key); |
| scanner.ScanAll(&data); |
| INC_STAT(thread, num_tokens_scanned, data.NumTokens()); |
| @@ -9236,6 +9252,7 @@ void Script::Tokenize(const String& private_key, bool use_shared_tokens) const { |
| // Already tokenized. |
| return; |
| } |
| + |
| // Get the source, scan and allocate the token stream. |
| VMTagScope tagScope(thread, VMTag::kCompileScannerTagId); |
| CSTAT_TIMER_SCOPE(thread, scanner_timer); |