Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(180)

Side by Side Diff: src/asmjs/asm-wasm-builder.cc

Issue 2555203002: [wasm][asm.js] Utf8 encode exported function names. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | test/mjsunit/wasm/asm-wasm.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 // Required to get M_E etc. in MSVC. 7 // Required to get M_E etc. in MSVC.
8 #if defined(_WIN32) 8 #if defined(_WIN32)
9 #define _USE_MATH_DEFINES 9 #define _USE_MATH_DEFINES
10 #endif 10 #endif
(...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after
707 ZoneList<ObjectLiteralProperty*>* props = expr->properties(); 707 ZoneList<ObjectLiteralProperty*>* props = expr->properties();
708 for (int i = 0; i < props->length(); ++i) { 708 for (int i = 0; i < props->length(); ++i) {
709 ObjectLiteralProperty* prop = props->at(i); 709 ObjectLiteralProperty* prop = props->at(i);
710 DCHECK_EQ(kExportScope, scope_); 710 DCHECK_EQ(kExportScope, scope_);
711 VariableProxy* expr = prop->value()->AsVariableProxy(); 711 VariableProxy* expr = prop->value()->AsVariableProxy();
712 DCHECK_NOT_NULL(expr); 712 DCHECK_NOT_NULL(expr);
713 Variable* var = expr->var(); 713 Variable* var = expr->var();
714 Literal* name = prop->key()->AsLiteral(); 714 Literal* name = prop->key()->AsLiteral();
715 DCHECK_NOT_NULL(name); 715 DCHECK_NOT_NULL(name);
716 DCHECK(name->IsPropertyName()); 716 DCHECK(name->IsPropertyName());
717 const AstRawString* raw_name = name->AsRawPropertyName(); 717 Handle<String> function_name = name->AsPropertyName();
718 int length;
719 std::unique_ptr<char[]> utf8 = function_name->ToCString(
titzer 2016/12/07 16:19:18 Mmmm, I think this might be a dangling reference..
bradn 2016/12/08 08:50:24 ExportAs converts the Vector<char> to a ZoneVector
720 DISALLOW_NULLS, FAST_STRING_TRAVERSAL, &length);
718 if (var->is_function()) { 721 if (var->is_function()) {
719 WasmFunctionBuilder* function = LookupOrInsertFunction(var); 722 WasmFunctionBuilder* function = LookupOrInsertFunction(var);
720 function->ExportAs({reinterpret_cast<const char*>(raw_name->raw_data()), 723 function->ExportAs({utf8.get(), length});
721 raw_name->length()});
722 } 724 }
723 } 725 }
724 } 726 }
725 727
726 void VisitArrayLiteral(ArrayLiteral* expr) { UNREACHABLE(); } 728 void VisitArrayLiteral(ArrayLiteral* expr) { UNREACHABLE(); }
727 729
728 void LoadInitFunction() { 730 void LoadInitFunction() {
729 current_function_builder_ = init_function_; 731 current_function_builder_ = init_function_;
730 scope_ = kInitScope; 732 scope_ = kInitScope;
731 } 733 }
(...skipping 1231 matching lines...) Expand 10 before | Expand all | Expand 10 after
1963 impl.builder_->WriteAsmJsOffsetTable(*asm_offsets_buffer); 1965 impl.builder_->WriteAsmJsOffsetTable(*asm_offsets_buffer);
1964 return {module_buffer, asm_offsets_buffer, success}; 1966 return {module_buffer, asm_offsets_buffer, success};
1965 } 1967 }
1966 1968
1967 const char* AsmWasmBuilder::foreign_init_name = "__foreign_init__"; 1969 const char* AsmWasmBuilder::foreign_init_name = "__foreign_init__";
1968 const char* AsmWasmBuilder::single_function_name = "__single_function__"; 1970 const char* AsmWasmBuilder::single_function_name = "__single_function__";
1969 1971
1970 } // namespace wasm 1972 } // namespace wasm
1971 } // namespace internal 1973 } // namespace internal
1972 } // namespace v8 1974 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/wasm/asm-wasm.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698