OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 |
11 // with the distribution. | 11 // with the distribution. |
12 // * Neither the name of Google Inc. nor the names of its | 12 // * Neither the name of Google Inc. nor the names of its |
13 // contributors may be used to endorse or promote products derived | 13 // contributors may be used to endorse or promote products derived |
14 // from this software without specific prior written permission. | 14 // from this software without specific prior written permission. |
15 // | 15 // |
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 #include <v8.h> | 28 #include <include/v8.h> |
29 | |
30 #include <include/libplatform/libplatform.h> | |
29 | 31 |
30 #include <map> | 32 #include <map> |
31 #include <string> | 33 #include <string> |
32 | 34 |
33 #ifdef COMPRESS_STARTUP_DATA_BZ2 | 35 #ifdef COMPRESS_STARTUP_DATA_BZ2 |
34 #error Using compressed startup data is not supported for this sample | 36 #error Using compressed startup data is not supported for this sample |
35 #endif | 37 #endif |
36 | 38 |
37 using namespace std; | 39 using namespace std; |
38 using namespace v8; | 40 using namespace v8; |
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
637 void PrintMap(map<string, string>* m) { | 639 void PrintMap(map<string, string>* m) { |
638 for (map<string, string>::iterator i = m->begin(); i != m->end(); i++) { | 640 for (map<string, string>::iterator i = m->begin(); i != m->end(); i++) { |
639 pair<string, string> entry = *i; | 641 pair<string, string> entry = *i; |
640 printf("%s: %s\n", entry.first.c_str(), entry.second.c_str()); | 642 printf("%s: %s\n", entry.first.c_str(), entry.second.c_str()); |
641 } | 643 } |
642 } | 644 } |
643 | 645 |
644 | 646 |
645 int main(int argc, char* argv[]) { | 647 int main(int argc, char* argv[]) { |
646 v8::V8::InitializeICU(); | 648 v8::V8::InitializeICU(); |
649 v8::Platform* platform = v8::platform::CreateDefaultPlatform(0); | |
650 v8::V8::InitializePlatform(platform); | |
Jakob Kummerow
2014/07/02 07:37:52
Is it intentional that this platform is never shut
jochen (gone - plz use gerrit)
2014/07/02 07:39:25
in this file, we also never dispose v8 (or the iso
| |
647 map<string, string> options; | 651 map<string, string> options; |
648 string file; | 652 string file; |
649 ParseOptions(argc, argv, &options, &file); | 653 ParseOptions(argc, argv, &options, &file); |
650 if (file.empty()) { | 654 if (file.empty()) { |
651 fprintf(stderr, "No script was specified.\n"); | 655 fprintf(stderr, "No script was specified.\n"); |
652 return 1; | 656 return 1; |
653 } | 657 } |
654 Isolate* isolate = Isolate::New(); | 658 Isolate* isolate = Isolate::New(); |
655 Isolate::Scope isolate_scope(isolate); | 659 Isolate::Scope isolate_scope(isolate); |
656 HandleScope scope(isolate); | 660 HandleScope scope(isolate); |
657 Handle<String> source = ReadFile(isolate, file); | 661 Handle<String> source = ReadFile(isolate, file); |
658 if (source.IsEmpty()) { | 662 if (source.IsEmpty()) { |
659 fprintf(stderr, "Error reading '%s'.\n", file.c_str()); | 663 fprintf(stderr, "Error reading '%s'.\n", file.c_str()); |
660 return 1; | 664 return 1; |
661 } | 665 } |
662 JsHttpRequestProcessor processor(isolate, source); | 666 JsHttpRequestProcessor processor(isolate, source); |
663 map<string, string> output; | 667 map<string, string> output; |
664 if (!processor.Initialize(&options, &output)) { | 668 if (!processor.Initialize(&options, &output)) { |
665 fprintf(stderr, "Error initializing processor.\n"); | 669 fprintf(stderr, "Error initializing processor.\n"); |
666 return 1; | 670 return 1; |
667 } | 671 } |
668 if (!ProcessEntries(&processor, kSampleSize, kSampleRequests)) | 672 if (!ProcessEntries(&processor, kSampleSize, kSampleRequests)) |
669 return 1; | 673 return 1; |
670 PrintMap(&output); | 674 PrintMap(&output); |
671 } | 675 } |
OLD | NEW |