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

Side by Side Diff: test/cctest/test-api.cc

Issue 3308010: Avoid (some) symbol lookups at parse time if preparse data is available. (Closed)
Patch Set: Fixed indentation too. Created 10 years, 3 months 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
OLDNEW
1 // Copyright 2007-2009 the V8 project authors. All rights reserved. 1 // Copyright 2007-2009 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 19 matching lines...) Expand all
30 #include "v8.h" 30 #include "v8.h"
31 31
32 #include "api.h" 32 #include "api.h"
33 #include "compilation-cache.h" 33 #include "compilation-cache.h"
34 #include "execution.h" 34 #include "execution.h"
35 #include "snapshot.h" 35 #include "snapshot.h"
36 #include "platform.h" 36 #include "platform.h"
37 #include "top.h" 37 #include "top.h"
38 #include "utils.h" 38 #include "utils.h"
39 #include "cctest.h" 39 #include "cctest.h"
40 #include "parser.h"
40 41
41 static const bool kLogThreading = true; 42 static const bool kLogThreading = true;
42 43
43 static bool IsNaN(double x) { 44 static bool IsNaN(double x) {
44 #ifdef WIN32 45 #ifdef WIN32
45 return _isnan(x); 46 return _isnan(x);
46 #else 47 #else
47 return isnan(x); 48 return isnan(x);
48 #endif 49 #endif
49 } 50 }
(...skipping 8544 matching lines...) Expand 10 before | Expand all | Expand 10 after
8594 v8::V8::Initialize(); 8595 v8::V8::Initialize();
8595 v8::HandleScope scope; 8596 v8::HandleScope scope;
8596 LocalContext context; 8597 LocalContext context;
8597 8598
8598 const char* script = "function foo(){ return 5;}\n" 8599 const char* script = "function foo(){ return 5;}\n"
8599 "function bar(){ return 6 + 7;} foo();"; 8600 "function bar(){ return 6 + 7;} foo();";
8600 v8::ScriptData* sd = 8601 v8::ScriptData* sd =
8601 v8::ScriptData::PreCompile(script, i::StrLength(script)); 8602 v8::ScriptData::PreCompile(script, i::StrLength(script));
8602 CHECK(!sd->HasError()); 8603 CHECK(!sd->HasError());
8603 // ScriptDataImpl private implementation details 8604 // ScriptDataImpl private implementation details
8604 const int kUnsignedSize = sizeof(unsigned); 8605 const int kHeaderSize = i::ScriptDataImpl::kHeaderSize;
8605 const int kHeaderSize = 4; 8606 const int kFunctionEntrySize = i::FunctionEntry::kSize;
8606 const int kFunctionEntrySize = 5;
8607 const int kFunctionEntryStartOffset = 0; 8607 const int kFunctionEntryStartOffset = 0;
8608 const int kFunctionEntryEndOffset = 1; 8608 const int kFunctionEntryEndOffset = 1;
8609 unsigned* sd_data = 8609 unsigned* sd_data =
8610 reinterpret_cast<unsigned*>(const_cast<char*>(sd->Data())); 8610 reinterpret_cast<unsigned*>(const_cast<char*>(sd->Data()));
8611 CHECK_EQ(sd->Length(),
8612 (kHeaderSize + 2 * kFunctionEntrySize) * kUnsignedSize);
8613 8611
8614 // Overwrite function bar's end position with 0. 8612 // Overwrite function bar's end position with 0.
8615 sd_data[kHeaderSize + 1 * kFunctionEntrySize + kFunctionEntryEndOffset] = 0; 8613 sd_data[kHeaderSize + 1 * kFunctionEntrySize + kFunctionEntryEndOffset] = 0;
8616 v8::TryCatch try_catch; 8614 v8::TryCatch try_catch;
8617 8615
8618 Local<String> source = String::New(script); 8616 Local<String> source = String::New(script);
8619 Local<Script> compiled_script = Script::New(source, NULL, sd); 8617 Local<Script> compiled_script = Script::New(source, NULL, sd);
8620 CHECK(try_catch.HasCaught()); 8618 CHECK(try_catch.HasCaught());
8621 String::AsciiValue exception_value(try_catch.Message()->Get()); 8619 String::AsciiValue exception_value(try_catch.Message()->Get());
8622 CHECK_EQ("Uncaught SyntaxError: Invalid preparser data for function bar", 8620 CHECK_EQ("Uncaught SyntaxError: Invalid preparser data for function bar",
(...skipping 2657 matching lines...) Expand 10 before | Expand all | Expand 10 after
11280 ExpectFalse("Object.prototype.hasOwnProperty.call(other, \'0\')"); 11278 ExpectFalse("Object.prototype.hasOwnProperty.call(other, \'0\')");
11281 11279
11282 CHECK_EQ(false, global0->HasRealIndexedProperty(0)); 11280 CHECK_EQ(false, global0->HasRealIndexedProperty(0));
11283 CHECK_EQ(false, global0->HasRealNamedProperty(v8_str("x"))); 11281 CHECK_EQ(false, global0->HasRealNamedProperty(v8_str("x")));
11284 CHECK_EQ(false, global0->HasRealNamedCallbackProperty(v8_str("x"))); 11282 CHECK_EQ(false, global0->HasRealNamedCallbackProperty(v8_str("x")));
11285 11283
11286 // Reset the failed access check callback so it does not influence 11284 // Reset the failed access check callback so it does not influence
11287 // the other tests. 11285 // the other tests.
11288 v8::V8::SetFailedAccessCheckCallbackFunction(NULL); 11286 v8::V8::SetFailedAccessCheckCallbackFunction(NULL);
11289 } 11287 }
OLDNEW
« no previous file with comments | « src/v8-counters.h ('k') | test/cctest/test-parsing.cc » ('j') | test/cctest/test-parsing.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698