OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 <stdlib.h> | 5 #include <stdlib.h> |
6 #include <limits> | 6 #include <limits> |
7 | 7 |
8 #include "src/v8.h" | 8 #include "src/v8.h" |
9 | 9 |
10 #include "src/accessors.h" | 10 #include "src/accessors.h" |
11 #include "src/allocation-site-scopes.h" | 11 #include "src/allocation-site-scopes.h" |
12 #include "src/api.h" | 12 #include "src/api.h" |
13 #include "src/arguments.h" | 13 #include "src/arguments.h" |
| 14 #include "src/base/cpu.h" |
| 15 #include "src/base/platform/platform.h" |
14 #include "src/bootstrapper.h" | 16 #include "src/bootstrapper.h" |
15 #include "src/codegen.h" | 17 #include "src/codegen.h" |
16 #include "src/compilation-cache.h" | 18 #include "src/compilation-cache.h" |
17 #include "src/compiler.h" | 19 #include "src/compiler.h" |
18 #include "src/conversions.h" | 20 #include "src/conversions.h" |
19 #include "src/cpu.h" | |
20 #include "src/cpu-profiler.h" | 21 #include "src/cpu-profiler.h" |
21 #include "src/date.h" | 22 #include "src/date.h" |
22 #include "src/dateparser-inl.h" | 23 #include "src/dateparser-inl.h" |
23 #include "src/debug.h" | 24 #include "src/debug.h" |
24 #include "src/deoptimizer.h" | 25 #include "src/deoptimizer.h" |
25 #include "src/execution.h" | 26 #include "src/execution.h" |
26 #include "src/full-codegen.h" | 27 #include "src/full-codegen.h" |
27 #include "src/global-handles.h" | 28 #include "src/global-handles.h" |
28 #include "src/isolate-inl.h" | 29 #include "src/isolate-inl.h" |
29 #include "src/json-parser.h" | 30 #include "src/json-parser.h" |
30 #include "src/json-stringifier.h" | 31 #include "src/json-stringifier.h" |
31 #include "src/jsregexp-inl.h" | 32 #include "src/jsregexp-inl.h" |
32 #include "src/jsregexp.h" | 33 #include "src/jsregexp.h" |
33 #include "src/liveedit.h" | 34 #include "src/liveedit.h" |
34 #include "src/misc-intrinsics.h" | 35 #include "src/misc-intrinsics.h" |
35 #include "src/parser.h" | 36 #include "src/parser.h" |
36 #include "src/platform.h" | |
37 #include "src/runtime.h" | 37 #include "src/runtime.h" |
38 #include "src/runtime-profiler.h" | 38 #include "src/runtime-profiler.h" |
39 #include "src/scopeinfo.h" | 39 #include "src/scopeinfo.h" |
40 #include "src/smart-pointers.h" | 40 #include "src/smart-pointers.h" |
41 #include "src/string-search.h" | 41 #include "src/string-search.h" |
42 #include "src/stub-cache.h" | 42 #include "src/stub-cache.h" |
43 #include "src/uri.h" | 43 #include "src/uri.h" |
44 #include "src/v8threads.h" | 44 #include "src/v8threads.h" |
45 #include "src/vm-state-inl.h" | 45 #include "src/vm-state-inl.h" |
46 | 46 |
(...skipping 6225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6272 return *isolate->factory()->NewNumber(value); | 6272 return *isolate->factory()->NewNumber(value); |
6273 } | 6273 } |
6274 | 6274 |
6275 | 6275 |
6276 RUNTIME_FUNCTION(Runtime_StringParseFloat) { | 6276 RUNTIME_FUNCTION(Runtime_StringParseFloat) { |
6277 HandleScope shs(isolate); | 6277 HandleScope shs(isolate); |
6278 ASSERT(args.length() == 1); | 6278 ASSERT(args.length() == 1); |
6279 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0); | 6279 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0); |
6280 | 6280 |
6281 subject = String::Flatten(subject); | 6281 subject = String::Flatten(subject); |
6282 double value = StringToDouble( | 6282 double value = StringToDouble(isolate->unicode_cache(), *subject, |
6283 isolate->unicode_cache(), *subject, ALLOW_TRAILING_JUNK, OS::nan_value()); | 6283 ALLOW_TRAILING_JUNK, base::OS::nan_value()); |
6284 | 6284 |
6285 return *isolate->factory()->NewNumber(value); | 6285 return *isolate->factory()->NewNumber(value); |
6286 } | 6286 } |
6287 | 6287 |
6288 | 6288 |
6289 static inline bool ToUpperOverflows(uc32 character) { | 6289 static inline bool ToUpperOverflows(uc32 character) { |
6290 // y with umlauts and the micro sign are the only characters that stop | 6290 // y with umlauts and the micro sign are the only characters that stop |
6291 // fitting into one-byte when converting to uppercase. | 6291 // fitting into one-byte when converting to uppercase. |
6292 static const uc32 yuml_code = 0xff; | 6292 static const uc32 yuml_code = 0xff; |
6293 static const uc32 micro_code = 0xb5; | 6293 static const uc32 micro_code = 0xb5; |
(...skipping 2254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8548 CONVERT_ARG_HANDLE_CHECKED(String, sync, 1); | 8548 CONVERT_ARG_HANDLE_CHECKED(String, sync, 1); |
8549 if (sync->IsOneByteEqualTo(STATIC_ASCII_VECTOR("no sync"))) { | 8549 if (sync->IsOneByteEqualTo(STATIC_ASCII_VECTOR("no sync"))) { |
8550 sync_with_compiler_thread = false; | 8550 sync_with_compiler_thread = false; |
8551 } | 8551 } |
8552 } | 8552 } |
8553 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 8553 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
8554 if (isolate->concurrent_recompilation_enabled() && | 8554 if (isolate->concurrent_recompilation_enabled() && |
8555 sync_with_compiler_thread) { | 8555 sync_with_compiler_thread) { |
8556 while (function->IsInOptimizationQueue()) { | 8556 while (function->IsInOptimizationQueue()) { |
8557 isolate->optimizing_compiler_thread()->InstallOptimizedFunctions(); | 8557 isolate->optimizing_compiler_thread()->InstallOptimizedFunctions(); |
8558 OS::Sleep(50); | 8558 base::OS::Sleep(50); |
8559 } | 8559 } |
8560 } | 8560 } |
8561 if (FLAG_always_opt) { | 8561 if (FLAG_always_opt) { |
8562 // We may have always opt, but that is more best-effort than a real | 8562 // We may have always opt, but that is more best-effort than a real |
8563 // promise, so we still say "no" if it is not optimized. | 8563 // promise, so we still say "no" if it is not optimized. |
8564 return function->IsOptimized() ? Smi::FromInt(3) // 3 == "always". | 8564 return function->IsOptimized() ? Smi::FromInt(3) // 3 == "always". |
8565 : Smi::FromInt(2); // 2 == "no". | 8565 : Smi::FromInt(2); // 2 == "no". |
8566 } | 8566 } |
8567 if (FLAG_deopt_every_n_times) { | 8567 if (FLAG_deopt_every_n_times) { |
8568 return Smi::FromInt(6); // 6 == "maybe deopted". | 8568 return Smi::FromInt(6); // 6 == "maybe deopted". |
(...skipping 966 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9535 | 9535 |
9536 // According to ECMA-262, section 15.9.1, page 117, the precision of | 9536 // According to ECMA-262, section 15.9.1, page 117, the precision of |
9537 // the number in a Date object representing a particular instant in | 9537 // the number in a Date object representing a particular instant in |
9538 // time is milliseconds. Therefore, we floor the result of getting | 9538 // time is milliseconds. Therefore, we floor the result of getting |
9539 // the OS time. | 9539 // the OS time. |
9540 double millis; | 9540 double millis; |
9541 if (FLAG_verify_predictable) { | 9541 if (FLAG_verify_predictable) { |
9542 millis = 1388534400000.0; // Jan 1 2014 00:00:00 GMT+0000 | 9542 millis = 1388534400000.0; // Jan 1 2014 00:00:00 GMT+0000 |
9543 millis += std::floor(isolate->heap()->synthetic_time()); | 9543 millis += std::floor(isolate->heap()->synthetic_time()); |
9544 } else { | 9544 } else { |
9545 millis = std::floor(OS::TimeCurrentMillis()); | 9545 millis = std::floor(base::OS::TimeCurrentMillis()); |
9546 } | 9546 } |
9547 return *isolate->factory()->NewNumber(millis); | 9547 return *isolate->factory()->NewNumber(millis); |
9548 } | 9548 } |
9549 | 9549 |
9550 | 9550 |
9551 RUNTIME_FUNCTION(Runtime_DateParseString) { | 9551 RUNTIME_FUNCTION(Runtime_DateParseString) { |
9552 HandleScope scope(isolate); | 9552 HandleScope scope(isolate); |
9553 ASSERT(args.length() == 2); | 9553 ASSERT(args.length() == 2); |
9554 CONVERT_ARG_HANDLE_CHECKED(String, str, 0); | 9554 CONVERT_ARG_HANDLE_CHECKED(String, str, 0); |
9555 CONVERT_ARG_HANDLE_CHECKED(JSArray, output, 1); | 9555 CONVERT_ARG_HANDLE_CHECKED(JSArray, output, 1); |
(...skipping 3635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13191 RUNTIME_ASSERT(compilation_state == Script::COMPILATION_STATE_INITIAL); | 13191 RUNTIME_ASSERT(compilation_state == Script::COMPILATION_STATE_INITIAL); |
13192 script->set_source(*source); | 13192 script->set_source(*source); |
13193 | 13193 |
13194 return isolate->heap()->undefined_value(); | 13194 return isolate->heap()->undefined_value(); |
13195 } | 13195 } |
13196 | 13196 |
13197 | 13197 |
13198 RUNTIME_FUNCTION(Runtime_SystemBreak) { | 13198 RUNTIME_FUNCTION(Runtime_SystemBreak) { |
13199 SealHandleScope shs(isolate); | 13199 SealHandleScope shs(isolate); |
13200 ASSERT(args.length() == 0); | 13200 ASSERT(args.length() == 0); |
13201 OS::DebugBreak(); | 13201 base::OS::DebugBreak(); |
13202 return isolate->heap()->undefined_value(); | 13202 return isolate->heap()->undefined_value(); |
13203 } | 13203 } |
13204 | 13204 |
13205 | 13205 |
13206 RUNTIME_FUNCTION(Runtime_DebugDisassembleFunction) { | 13206 RUNTIME_FUNCTION(Runtime_DebugDisassembleFunction) { |
13207 HandleScope scope(isolate); | 13207 HandleScope scope(isolate); |
13208 #ifdef DEBUG | 13208 #ifdef DEBUG |
13209 ASSERT(args.length() == 1); | 13209 ASSERT(args.length() == 1); |
13210 // Get the function and make sure it is compiled. | 13210 // Get the function and make sure it is compiled. |
13211 CONVERT_ARG_HANDLE_CHECKED(JSFunction, func, 0); | 13211 CONVERT_ARG_HANDLE_CHECKED(JSFunction, func, 0); |
(...skipping 1244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14456 return *isolate->factory()->NewStringFromAsciiChecked(version_string); | 14456 return *isolate->factory()->NewStringFromAsciiChecked(version_string); |
14457 } | 14457 } |
14458 | 14458 |
14459 | 14459 |
14460 RUNTIME_FUNCTION(Runtime_Abort) { | 14460 RUNTIME_FUNCTION(Runtime_Abort) { |
14461 SealHandleScope shs(isolate); | 14461 SealHandleScope shs(isolate); |
14462 ASSERT(args.length() == 1); | 14462 ASSERT(args.length() == 1); |
14463 CONVERT_SMI_ARG_CHECKED(message_id, 0); | 14463 CONVERT_SMI_ARG_CHECKED(message_id, 0); |
14464 const char* message = GetBailoutReason( | 14464 const char* message = GetBailoutReason( |
14465 static_cast<BailoutReason>(message_id)); | 14465 static_cast<BailoutReason>(message_id)); |
14466 OS::PrintError("abort: %s\n", message); | 14466 base::OS::PrintError("abort: %s\n", message); |
14467 isolate->PrintStack(stderr); | 14467 isolate->PrintStack(stderr); |
14468 OS::Abort(); | 14468 base::OS::Abort(); |
14469 UNREACHABLE(); | 14469 UNREACHABLE(); |
14470 return NULL; | 14470 return NULL; |
14471 } | 14471 } |
14472 | 14472 |
14473 | 14473 |
14474 RUNTIME_FUNCTION(Runtime_AbortJS) { | 14474 RUNTIME_FUNCTION(Runtime_AbortJS) { |
14475 HandleScope scope(isolate); | 14475 HandleScope scope(isolate); |
14476 ASSERT(args.length() == 1); | 14476 ASSERT(args.length() == 1); |
14477 CONVERT_ARG_HANDLE_CHECKED(String, message, 0); | 14477 CONVERT_ARG_HANDLE_CHECKED(String, message, 0); |
14478 OS::PrintError("abort: %s\n", message->ToCString().get()); | 14478 base::OS::PrintError("abort: %s\n", message->ToCString().get()); |
14479 isolate->PrintStack(stderr); | 14479 isolate->PrintStack(stderr); |
14480 OS::Abort(); | 14480 base::OS::Abort(); |
14481 UNREACHABLE(); | 14481 UNREACHABLE(); |
14482 return NULL; | 14482 return NULL; |
14483 } | 14483 } |
14484 | 14484 |
14485 | 14485 |
14486 RUNTIME_FUNCTION(Runtime_FlattenString) { | 14486 RUNTIME_FUNCTION(Runtime_FlattenString) { |
14487 HandleScope scope(isolate); | 14487 HandleScope scope(isolate); |
14488 ASSERT(args.length() == 1); | 14488 ASSERT(args.length() == 1); |
14489 CONVERT_ARG_HANDLE_CHECKED(String, str, 0); | 14489 CONVERT_ARG_HANDLE_CHECKED(String, str, 0); |
14490 return *String::Flatten(str); | 14490 return *String::Flatten(str); |
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15090 } | 15090 } |
15091 return NULL; | 15091 return NULL; |
15092 } | 15092 } |
15093 | 15093 |
15094 | 15094 |
15095 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { | 15095 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { |
15096 return &(kIntrinsicFunctions[static_cast<int>(id)]); | 15096 return &(kIntrinsicFunctions[static_cast<int>(id)]); |
15097 } | 15097 } |
15098 | 15098 |
15099 } } // namespace v8::internal | 15099 } } // namespace v8::internal |
OLD | NEW |