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

Side by Side Diff: src/runtime.cc

Issue 157503002: A64: Synchronize with r18444. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « src/runtime.h ('k') | src/runtime-profiler.h » ('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 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
(...skipping 2939 matching lines...) Expand 10 before | Expand all | Expand 10 after
2950 2950
2951 CONVERT_ARG_HANDLE_CHECKED(JSFunction, target, 0); 2951 CONVERT_ARG_HANDLE_CHECKED(JSFunction, target, 0);
2952 Handle<Object> code = args.at<Object>(1); 2952 Handle<Object> code = args.at<Object>(1);
2953 2953
2954 if (code->IsNull()) return *target; 2954 if (code->IsNull()) return *target;
2955 RUNTIME_ASSERT(code->IsJSFunction()); 2955 RUNTIME_ASSERT(code->IsJSFunction());
2956 Handle<JSFunction> source = Handle<JSFunction>::cast(code); 2956 Handle<JSFunction> source = Handle<JSFunction>::cast(code);
2957 Handle<SharedFunctionInfo> target_shared(target->shared()); 2957 Handle<SharedFunctionInfo> target_shared(target->shared());
2958 Handle<SharedFunctionInfo> source_shared(source->shared()); 2958 Handle<SharedFunctionInfo> source_shared(source->shared());
2959 2959
2960 if (!JSFunction::EnsureCompiled(source, KEEP_EXCEPTION)) { 2960 if (!Compiler::EnsureCompiled(source, KEEP_EXCEPTION)) {
2961 return Failure::Exception(); 2961 return Failure::Exception();
2962 } 2962 }
2963 2963
2964 // Mark both, the source and the target, as un-flushable because the 2964 // Mark both, the source and the target, as un-flushable because the
2965 // shared unoptimized code makes them impossible to enqueue in a list. 2965 // shared unoptimized code makes them impossible to enqueue in a list.
2966 ASSERT(target_shared->code()->gc_metadata() == NULL); 2966 ASSERT(target_shared->code()->gc_metadata() == NULL);
2967 ASSERT(source_shared->code()->gc_metadata() == NULL); 2967 ASSERT(source_shared->code()->gc_metadata() == NULL);
2968 target_shared->set_dont_flush(true); 2968 target_shared->set_dont_flush(true);
2969 source_shared->set_dont_flush(true); 2969 source_shared->set_dont_flush(true);
2970 2970
(...skipping 1471 matching lines...) Expand 10 before | Expand all | Expand 10 after
4442 uint16_t char1 = stream1.GetNext(); 4442 uint16_t char1 = stream1.GetNext();
4443 uint16_t char2 = stream2.GetNext(); 4443 uint16_t char2 = stream2.GetNext();
4444 if (char1 != char2) return Smi::FromInt(char1 - char2); 4444 if (char1 != char2) return Smi::FromInt(char1 - char2);
4445 } 4445 }
4446 4446
4447 return Smi::FromInt(str1_length - str2_length); 4447 return Smi::FromInt(str1_length - str2_length);
4448 } 4448 }
4449 4449
4450 4450
4451 RUNTIME_FUNCTION(MaybeObject*, Runtime_SubString) { 4451 RUNTIME_FUNCTION(MaybeObject*, Runtime_SubString) {
4452 SealHandleScope shs(isolate); 4452 HandleScope scope(isolate);
4453 ASSERT(args.length() == 3); 4453 ASSERT(args.length() == 3);
4454 4454
4455 CONVERT_ARG_CHECKED(String, value, 0); 4455 CONVERT_ARG_HANDLE_CHECKED(String, string, 0);
4456 int start, end; 4456 int start, end;
4457 // We have a fast integer-only case here to avoid a conversion to double in 4457 // We have a fast integer-only case here to avoid a conversion to double in
4458 // the common case where from and to are Smis. 4458 // the common case where from and to are Smis.
4459 if (args[1]->IsSmi() && args[2]->IsSmi()) { 4459 if (args[1]->IsSmi() && args[2]->IsSmi()) {
4460 CONVERT_SMI_ARG_CHECKED(from_number, 1); 4460 CONVERT_SMI_ARG_CHECKED(from_number, 1);
4461 CONVERT_SMI_ARG_CHECKED(to_number, 2); 4461 CONVERT_SMI_ARG_CHECKED(to_number, 2);
4462 start = from_number; 4462 start = from_number;
4463 end = to_number; 4463 end = to_number;
4464 } else { 4464 } else {
4465 CONVERT_DOUBLE_ARG_CHECKED(from_number, 1); 4465 CONVERT_DOUBLE_ARG_CHECKED(from_number, 1);
4466 CONVERT_DOUBLE_ARG_CHECKED(to_number, 2); 4466 CONVERT_DOUBLE_ARG_CHECKED(to_number, 2);
4467 start = FastD2IChecked(from_number); 4467 start = FastD2IChecked(from_number);
4468 end = FastD2IChecked(to_number); 4468 end = FastD2IChecked(to_number);
4469 } 4469 }
4470 RUNTIME_ASSERT(end >= start); 4470 RUNTIME_ASSERT(end >= start);
4471 RUNTIME_ASSERT(start >= 0); 4471 RUNTIME_ASSERT(start >= 0);
4472 RUNTIME_ASSERT(end <= value->length()); 4472 RUNTIME_ASSERT(end <= string->length());
4473 isolate->counters()->sub_string_runtime()->Increment(); 4473 isolate->counters()->sub_string_runtime()->Increment();
4474 return value->SubString(start, end); 4474
4475 return *isolate->factory()->NewSubString(string, start, end);
4475 } 4476 }
4476 4477
4477 4478
4478 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringMatch) { 4479 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringMatch) {
4479 HandleScope handles(isolate); 4480 HandleScope handles(isolate);
4480 ASSERT_EQ(3, args.length()); 4481 ASSERT_EQ(3, args.length());
4481 4482
4482 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0); 4483 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0);
4483 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 1); 4484 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 1);
4484 CONVERT_ARG_HANDLE_CHECKED(JSArray, regexp_info, 2); 4485 CONVERT_ARG_HANDLE_CHECKED(JSArray, regexp_info, 2);
(...skipping 2060 matching lines...) Expand 10 before | Expand all | Expand 10 after
6545 args, isolate, isolate->runtime_state()->to_upper_mapping()); 6546 args, isolate, isolate->runtime_state()->to_upper_mapping());
6546 } 6547 }
6547 6548
6548 6549
6549 static inline bool IsTrimWhiteSpace(unibrow::uchar c) { 6550 static inline bool IsTrimWhiteSpace(unibrow::uchar c) {
6550 return unibrow::WhiteSpace::Is(c) || c == 0x200b || c == 0xfeff; 6551 return unibrow::WhiteSpace::Is(c) || c == 0x200b || c == 0xfeff;
6551 } 6552 }
6552 6553
6553 6554
6554 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringTrim) { 6555 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringTrim) {
6555 SealHandleScope shs(isolate); 6556 HandleScope scope(isolate);
6556 ASSERT(args.length() == 3); 6557 ASSERT(args.length() == 3);
6557 6558
6558 CONVERT_ARG_CHECKED(String, s, 0); 6559 CONVERT_ARG_HANDLE_CHECKED(String, string, 0);
6559 CONVERT_BOOLEAN_ARG_CHECKED(trimLeft, 1); 6560 CONVERT_BOOLEAN_ARG_CHECKED(trimLeft, 1);
6560 CONVERT_BOOLEAN_ARG_CHECKED(trimRight, 2); 6561 CONVERT_BOOLEAN_ARG_CHECKED(trimRight, 2);
6561 6562
6562 s->TryFlatten(); 6563 string = FlattenGetString(string);
6563 int length = s->length(); 6564 int length = string->length();
6564 6565
6565 int left = 0; 6566 int left = 0;
6566 if (trimLeft) { 6567 if (trimLeft) {
6567 while (left < length && IsTrimWhiteSpace(s->Get(left))) { 6568 while (left < length && IsTrimWhiteSpace(string->Get(left))) {
6568 left++; 6569 left++;
6569 } 6570 }
6570 } 6571 }
6571 6572
6572 int right = length; 6573 int right = length;
6573 if (trimRight) { 6574 if (trimRight) {
6574 while (right > left && IsTrimWhiteSpace(s->Get(right - 1))) { 6575 while (right > left && IsTrimWhiteSpace(string->Get(right - 1))) {
6575 right--; 6576 right--;
6576 } 6577 }
6577 } 6578 }
6578 return s->SubString(left, right); 6579
6580 return *isolate->factory()->NewSubString(string, left, right);
6579 } 6581 }
6580 6582
6581 6583
6582 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringSplit) { 6584 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringSplit) {
6583 HandleScope handle_scope(isolate); 6585 HandleScope handle_scope(isolate);
6584 ASSERT(args.length() == 3); 6586 ASSERT(args.length() == 3);
6585 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0); 6587 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0);
6586 CONVERT_ARG_HANDLE_CHECKED(String, pattern, 1); 6588 CONVERT_ARG_HANDLE_CHECKED(String, pattern, 1);
6587 CONVERT_NUMBER_CHECKED(uint32_t, limit, Uint32, args[2]); 6589 CONVERT_NUMBER_CHECKED(uint32_t, limit, Uint32, args[2]);
6588 6590
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
6971 SealHandleScope shs(isolate); 6973 SealHandleScope shs(isolate);
6972 ASSERT(args.length() == 2); 6974 ASSERT(args.length() == 2);
6973 6975
6974 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); 6976 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]);
6975 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); 6977 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]);
6976 return isolate->heap()->NumberFromInt32(x * y); 6978 return isolate->heap()->NumberFromInt32(x * y);
6977 } 6979 }
6978 6980
6979 6981
6980 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringAdd) { 6982 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringAdd) {
6981 SealHandleScope shs(isolate); 6983 HandleScope scope(isolate);
6982 ASSERT(args.length() == 2); 6984 ASSERT(args.length() == 2);
6983 CONVERT_ARG_CHECKED(String, str1, 0); 6985 CONVERT_ARG_HANDLE_CHECKED(String, str1, 0);
6984 CONVERT_ARG_CHECKED(String, str2, 1); 6986 CONVERT_ARG_HANDLE_CHECKED(String, str2, 1);
6985 isolate->counters()->string_add_runtime()->Increment(); 6987 isolate->counters()->string_add_runtime()->Increment();
6986 return isolate->heap()->AllocateConsString(str1, str2); 6988 return *isolate->factory()->NewConsString(str1, str2);
6987 } 6989 }
6988 6990
6989 6991
6990 template <typename sinkchar> 6992 template <typename sinkchar>
6991 static inline void StringBuilderConcatHelper(String* special, 6993 static inline void StringBuilderConcatHelper(String* special,
6992 sinkchar* sink, 6994 sinkchar* sink,
6993 FixedArray* fixed_array, 6995 FixedArray* fixed_array,
6994 int array_length) { 6996 int array_length) {
6995 int position = 0; 6997 int position = 0;
6996 for (int i = 0; i < array_length; i++) { 6998 for (int i = 0; i < array_length; i++) {
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after
7725 return isolate->heap()->NumberFromDouble(floor(x)); 7727 return isolate->heap()->NumberFromDouble(floor(x));
7726 } 7728 }
7727 7729
7728 7730
7729 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_log) { 7731 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_log) {
7730 SealHandleScope shs(isolate); 7732 SealHandleScope shs(isolate);
7731 ASSERT(args.length() == 1); 7733 ASSERT(args.length() == 1);
7732 isolate->counters()->math_log()->Increment(); 7734 isolate->counters()->math_log()->Increment();
7733 7735
7734 CONVERT_DOUBLE_ARG_CHECKED(x, 0); 7736 CONVERT_DOUBLE_ARG_CHECKED(x, 0);
7735 return isolate->heap()->AllocateHeapNumber(fast_log(x)); 7737 return isolate->heap()->AllocateHeapNumber(log(x));
7736 } 7738 }
7737 7739
7738 7740
7739 // Slow version of Math.pow. We check for fast paths for special cases. 7741 // Slow version of Math.pow. We check for fast paths for special cases.
7740 // Used if SSE2/VFP3 is not available. 7742 // Used if SSE2/VFP3 is not available.
7741 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_pow) { 7743 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_pow) {
7742 SealHandleScope shs(isolate); 7744 SealHandleScope shs(isolate);
7743 ASSERT(args.length() == 2); 7745 ASSERT(args.length() == 2);
7744 isolate->counters()->math_pow()->Increment(); 7746 isolate->counters()->math_pow()->Increment();
7745 7747
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
8197 bound_function = Execution::TryGetConstructorDelegate(isolate, 8199 bound_function = Execution::TryGetConstructorDelegate(isolate,
8198 bound_function, 8200 bound_function,
8199 &exception_thrown); 8201 &exception_thrown);
8200 if (exception_thrown) return Failure::Exception(); 8202 if (exception_thrown) return Failure::Exception();
8201 } 8203 }
8202 ASSERT(bound_function->IsJSFunction()); 8204 ASSERT(bound_function->IsJSFunction());
8203 8205
8204 bool exception = false; 8206 bool exception = false;
8205 Handle<Object> result = 8207 Handle<Object> result =
8206 Execution::New(Handle<JSFunction>::cast(bound_function), 8208 Execution::New(Handle<JSFunction>::cast(bound_function),
8207 total_argc, *param_data, &exception); 8209 total_argc, param_data.get(), &exception);
8208 if (exception) { 8210 if (exception) {
8209 return Failure::Exception(); 8211 return Failure::Exception();
8210 } 8212 }
8211 ASSERT(!result.is_null()); 8213 ASSERT(!result.is_null());
8212 return *result; 8214 return *result;
8213 } 8215 }
8214 8216
8215 8217
8216 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewObject) { 8218 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewObject) {
8217 HandleScope scope(isolate); 8219 HandleScope scope(isolate);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
8258 // ignored anyway, we use the global object as the receiver 8260 // ignored anyway, we use the global object as the receiver
8259 // instead of a new JSFunction object. This way, errors are 8261 // instead of a new JSFunction object. This way, errors are
8260 // reported the same way whether or not 'Function' is called 8262 // reported the same way whether or not 'Function' is called
8261 // using 'new'. 8263 // using 'new'.
8262 return isolate->context()->global_object(); 8264 return isolate->context()->global_object();
8263 } 8265 }
8264 } 8266 }
8265 8267
8266 // The function should be compiled for the optimization hints to be 8268 // The function should be compiled for the optimization hints to be
8267 // available. 8269 // available.
8268 JSFunction::EnsureCompiled(function, CLEAR_EXCEPTION); 8270 Compiler::EnsureCompiled(function, CLEAR_EXCEPTION);
8269 8271
8270 Handle<SharedFunctionInfo> shared(function->shared(), isolate); 8272 Handle<SharedFunctionInfo> shared(function->shared(), isolate);
8271 if (!function->has_initial_map() && 8273 if (!function->has_initial_map() &&
8272 shared->IsInobjectSlackTrackingInProgress()) { 8274 shared->IsInobjectSlackTrackingInProgress()) {
8273 // The tracking is already in progress for another function. We can only 8275 // The tracking is already in progress for another function. We can only
8274 // track one initial_map at a time, so we force the completion before the 8276 // track one initial_map at a time, so we force the completion before the
8275 // function is called as a constructor for the first time. 8277 // function is called as a constructor for the first time.
8276 shared->CompleteInobjectSlackTracking(); 8278 shared->CompleteInobjectSlackTracking();
8277 } 8279 }
8278 8280
(...skipping 11 matching lines...) Expand all
8290 HandleScope scope(isolate); 8292 HandleScope scope(isolate);
8291 ASSERT(args.length() == 1); 8293 ASSERT(args.length() == 1);
8292 8294
8293 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); 8295 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
8294 function->shared()->CompleteInobjectSlackTracking(); 8296 function->shared()->CompleteInobjectSlackTracking();
8295 8297
8296 return isolate->heap()->undefined_value(); 8298 return isolate->heap()->undefined_value();
8297 } 8299 }
8298 8300
8299 8301
8300 RUNTIME_FUNCTION(MaybeObject*, Runtime_LazyCompile) { 8302 RUNTIME_FUNCTION(MaybeObject*, Runtime_CompileUnoptimized) {
8301 HandleScope scope(isolate); 8303 HandleScope scope(isolate);
8302 ASSERT(args.length() == 1); 8304 ASSERT(args.length() == 1);
8303 8305
8304 Handle<JSFunction> function = args.at<JSFunction>(0); 8306 Handle<JSFunction> function = args.at<JSFunction>(0);
8305 #ifdef DEBUG 8307 #ifdef DEBUG
8306 if (FLAG_trace_lazy && !function->shared()->is_compiled()) { 8308 if (FLAG_trace_lazy && !function->shared()->is_compiled()) {
8307 PrintF("[lazy: "); 8309 PrintF("[unoptimized: ");
8308 function->PrintName(); 8310 function->PrintName();
8309 PrintF("]\n"); 8311 PrintF("]\n");
8310 } 8312 }
8311 #endif 8313 #endif
8312 8314
8313 // Compile the target function. 8315 // Compile the target function.
8314 ASSERT(!function->is_compiled()); 8316 ASSERT(function->shared()->allows_lazy_compilation());
8315 if (!JSFunction::CompileLazy(function, KEEP_EXCEPTION)) { 8317
8316 return Failure::Exception(); 8318 Handle<Code> code = Compiler::GetUnoptimizedCode(function);
8317 } 8319 RETURN_IF_EMPTY_HANDLE(isolate, code);
8320 function->ReplaceCode(*code);
8318 8321
8319 // All done. Return the compiled code. 8322 // All done. Return the compiled code.
8320 ASSERT(function->is_compiled()); 8323 ASSERT(function->is_compiled());
8321 return function->code(); 8324 ASSERT(function->code()->kind() == Code::FUNCTION ||
8325 (FLAG_always_opt &&
8326 function->code()->kind() == Code::OPTIMIZED_FUNCTION));
8327 return *code;
8322 } 8328 }
8323 8329
8324 8330
8325 bool AllowOptimization(Isolate* isolate, Handle<JSFunction> function) { 8331 RUNTIME_FUNCTION(MaybeObject*, Runtime_CompileOptimized) {
8326 // If the function is not compiled ignore the lazy 8332 HandleScope scope(isolate);
8327 // recompilation. This can happen if the debugger is activated and 8333 ASSERT(args.length() == 2);
8328 // the function is returned to the not compiled state. 8334 Handle<JSFunction> function = args.at<JSFunction>(0);
8329 if (!function->shared()->is_compiled()) return false; 8335 CONVERT_BOOLEAN_ARG_CHECKED(concurrent, 1);
8330 8336
8331 // If the function is not optimizable or debugger is active continue using the 8337 Handle<Code> unoptimized(function->shared()->code());
8332 // code from the full compiler. 8338 if (!function->shared()->is_compiled()) {
8333 if (!isolate->use_crankshaft() || 8339 // If the function is not compiled, do not optimize.
8334 function->shared()->optimization_disabled() || 8340 // This can happen if the debugger is activated and
8335 isolate->DebuggerHasBreakPoints()) { 8341 // the function is returned to the not compiled state.
8342 // TODO(yangguo): reconsider this.
8343 function->ReplaceCode(function->shared()->code());
8344 } else if (!isolate->use_crankshaft() ||
8345 function->shared()->optimization_disabled() ||
8346 isolate->DebuggerHasBreakPoints()) {
8347 // If the function is not optimizable or debugger is active continue
8348 // using the code from the full compiler.
8336 if (FLAG_trace_opt) { 8349 if (FLAG_trace_opt) {
8337 PrintF("[failed to optimize "); 8350 PrintF("[failed to optimize ");
8338 function->PrintName(); 8351 function->PrintName();
8339 PrintF(": is code optimizable: %s, is debugger enabled: %s]\n", 8352 PrintF(": is code optimizable: %s, is debugger enabled: %s]\n",
8340 function->shared()->optimization_disabled() ? "F" : "T", 8353 function->shared()->optimization_disabled() ? "F" : "T",
8341 isolate->DebuggerHasBreakPoints() ? "T" : "F"); 8354 isolate->DebuggerHasBreakPoints() ? "T" : "F");
8342 } 8355 }
8343 return false; 8356 function->ReplaceCode(*unoptimized);
8357 } else {
8358 Compiler::ConcurrencyMode mode = concurrent ? Compiler::CONCURRENT
8359 : Compiler::NOT_CONCURRENT;
8360 Handle<Code> code = Compiler::GetOptimizedCode(function, unoptimized, mode);
8361 function->ReplaceCode(code.is_null() ? *unoptimized : *code);
8344 } 8362 }
8345 return true;
8346 }
8347 8363
8348 8364 ASSERT(function->code()->kind() == Code::FUNCTION ||
8349 RUNTIME_FUNCTION(MaybeObject*, Runtime_LazyRecompile) { 8365 function->code()->kind() == Code::OPTIMIZED_FUNCTION ||
8350 HandleScope scope(isolate); 8366 function->IsInOptimizationQueue());
8351 ASSERT(args.length() == 1);
8352 Handle<JSFunction> function = args.at<JSFunction>(0);
8353
8354 if (!AllowOptimization(isolate, function)) {
8355 function->ReplaceCode(function->shared()->code());
8356 return function->code();
8357 }
8358 function->shared()->code()->set_profiler_ticks(0);
8359 if (JSFunction::CompileOptimized(function, CLEAR_EXCEPTION)) {
8360 return function->code();
8361 }
8362 if (FLAG_trace_opt) {
8363 PrintF("[failed to optimize ");
8364 function->PrintName();
8365 PrintF(": optimized compilation failed]\n");
8366 }
8367 function->ReplaceCode(function->shared()->code());
8368 return function->code(); 8367 return function->code();
8369 } 8368 }
8370 8369
8371 8370
8372 RUNTIME_FUNCTION(MaybeObject*, Runtime_ConcurrentRecompile) {
8373 HandleScope handle_scope(isolate);
8374 ASSERT(args.length() == 1);
8375 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
8376 if (!AllowOptimization(isolate, function)) {
8377 function->ReplaceCode(function->shared()->code());
8378 return isolate->heap()->undefined_value();
8379 }
8380 function->shared()->code()->set_profiler_ticks(0);
8381 ASSERT(isolate->concurrent_recompilation_enabled());
8382 if (!Compiler::RecompileConcurrent(function)) {
8383 function->ReplaceCode(function->shared()->code());
8384 }
8385 return isolate->heap()->undefined_value();
8386 }
8387
8388
8389 class ActivationsFinder : public ThreadVisitor { 8371 class ActivationsFinder : public ThreadVisitor {
8390 public: 8372 public:
8391 Code* code_; 8373 Code* code_;
8392 bool has_code_activations_; 8374 bool has_code_activations_;
8393 8375
8394 explicit ActivationsFinder(Code* code) 8376 explicit ActivationsFinder(Code* code)
8395 : code_(code), 8377 : code_(code),
8396 has_code_activations_(false) { } 8378 has_code_activations_(false) { }
8397 8379
8398 void VisitThread(Isolate* isolate, ThreadLocalTop* top) { 8380 void VisitThread(Isolate* isolate, ThreadLocalTop* top) {
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
8519 ? isolate->heap()->true_value() : isolate->heap()->false_value(); 8501 ? isolate->heap()->true_value() : isolate->heap()->false_value();
8520 } 8502 }
8521 8503
8522 8504
8523 RUNTIME_FUNCTION(MaybeObject*, Runtime_OptimizeFunctionOnNextCall) { 8505 RUNTIME_FUNCTION(MaybeObject*, Runtime_OptimizeFunctionOnNextCall) {
8524 HandleScope scope(isolate); 8506 HandleScope scope(isolate);
8525 RUNTIME_ASSERT(args.length() == 1 || args.length() == 2); 8507 RUNTIME_ASSERT(args.length() == 1 || args.length() == 2);
8526 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); 8508 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
8527 8509
8528 if (!function->IsOptimizable()) return isolate->heap()->undefined_value(); 8510 if (!function->IsOptimizable()) return isolate->heap()->undefined_value();
8529 function->MarkForLazyRecompilation(); 8511 function->MarkForOptimization();
8530 8512
8531 Code* unoptimized = function->shared()->code(); 8513 Code* unoptimized = function->shared()->code();
8532 if (args.length() == 2 && 8514 if (args.length() == 2 &&
8533 unoptimized->kind() == Code::FUNCTION) { 8515 unoptimized->kind() == Code::FUNCTION) {
8534 CONVERT_ARG_HANDLE_CHECKED(String, type, 1); 8516 CONVERT_ARG_HANDLE_CHECKED(String, type, 1);
8535 if (type->IsOneByteEqualTo(STATIC_ASCII_VECTOR("osr"))) { 8517 if (type->IsOneByteEqualTo(STATIC_ASCII_VECTOR("osr"))) {
8536 // Start patching from the currently patched loop nesting level. 8518 // Start patching from the currently patched loop nesting level.
8537 int current_level = unoptimized->allow_osr_at_loop_nesting_level(); 8519 int current_level = unoptimized->allow_osr_at_loop_nesting_level();
8538 ASSERT(BackEdgeTable::Verify(isolate, unoptimized, current_level)); 8520 ASSERT(BackEdgeTable::Verify(isolate, unoptimized, current_level));
8539 for (int i = current_level + 1; i <= Code::kMaxLoopNestingMarker; i++) { 8521 for (int i = current_level + 1; i <= Code::kMaxLoopNestingMarker; i++) {
8540 unoptimized->set_allow_osr_at_loop_nesting_level(i); 8522 unoptimized->set_allow_osr_at_loop_nesting_level(i);
8541 isolate->runtime_profiler()->AttemptOnStackReplacement(*function); 8523 isolate->runtime_profiler()->AttemptOnStackReplacement(*function);
8542 } 8524 }
8543 } else if (type->IsOneByteEqualTo(STATIC_ASCII_VECTOR("concurrent"))) { 8525 } else if (type->IsOneByteEqualTo(STATIC_ASCII_VECTOR("concurrent")) &&
8544 function->MarkForConcurrentRecompilation(); 8526 isolate->concurrent_recompilation_enabled()) {
8527 function->MarkForConcurrentOptimization();
8545 } 8528 }
8546 } 8529 }
8547 8530
8548 return isolate->heap()->undefined_value(); 8531 return isolate->heap()->undefined_value();
8549 } 8532 }
8550 8533
8551 8534
8552 RUNTIME_FUNCTION(MaybeObject*, Runtime_NeverOptimizeFunction) { 8535 RUNTIME_FUNCTION(MaybeObject*, Runtime_NeverOptimizeFunction) {
8553 HandleScope scope(isolate); 8536 HandleScope scope(isolate);
8554 ASSERT(args.length() == 1); 8537 ASSERT(args.length() == 1);
(...skipping 13 matching lines...) Expand all
8568 bool sync_with_compiler_thread = true; 8551 bool sync_with_compiler_thread = true;
8569 if (args.length() == 2) { 8552 if (args.length() == 2) {
8570 CONVERT_ARG_HANDLE_CHECKED(String, sync, 1); 8553 CONVERT_ARG_HANDLE_CHECKED(String, sync, 1);
8571 if (sync->IsOneByteEqualTo(STATIC_ASCII_VECTOR("no sync"))) { 8554 if (sync->IsOneByteEqualTo(STATIC_ASCII_VECTOR("no sync"))) {
8572 sync_with_compiler_thread = false; 8555 sync_with_compiler_thread = false;
8573 } 8556 }
8574 } 8557 }
8575 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); 8558 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
8576 if (isolate->concurrent_recompilation_enabled() && 8559 if (isolate->concurrent_recompilation_enabled() &&
8577 sync_with_compiler_thread) { 8560 sync_with_compiler_thread) {
8578 while (function->IsInRecompileQueue()) { 8561 while (function->IsInOptimizationQueue()) {
8579 isolate->optimizing_compiler_thread()->InstallOptimizedFunctions(); 8562 isolate->optimizing_compiler_thread()->InstallOptimizedFunctions();
8580 OS::Sleep(50); 8563 OS::Sleep(50);
8581 } 8564 }
8582 } 8565 }
8583 if (FLAG_always_opt) { 8566 if (FLAG_always_opt) {
8584 // We may have always opt, but that is more best-effort than a real 8567 // We may have always opt, but that is more best-effort than a real
8585 // promise, so we still say "no" if it is not optimized. 8568 // promise, so we still say "no" if it is not optimized.
8586 return function->IsOptimized() ? Smi::FromInt(3) // 3 == "always". 8569 return function->IsOptimized() ? Smi::FromInt(3) // 3 == "always".
8587 : Smi::FromInt(2); // 2 == "no". 8570 : Smi::FromInt(2); // 2 == "no".
8588 } 8571 }
(...skipping 15 matching lines...) Expand all
8604 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetOptimizationCount) { 8587 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetOptimizationCount) {
8605 HandleScope scope(isolate); 8588 HandleScope scope(isolate);
8606 ASSERT(args.length() == 1); 8589 ASSERT(args.length() == 1);
8607 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); 8590 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
8608 return Smi::FromInt(function->shared()->opt_count()); 8591 return Smi::FromInt(function->shared()->opt_count());
8609 } 8592 }
8610 8593
8611 8594
8612 static bool IsSuitableForOnStackReplacement(Isolate* isolate, 8595 static bool IsSuitableForOnStackReplacement(Isolate* isolate,
8613 Handle<JSFunction> function, 8596 Handle<JSFunction> function,
8614 Handle<Code> unoptimized) { 8597 Handle<Code> current_code) {
8615 // Keep track of whether we've succeeded in optimizing. 8598 // Keep track of whether we've succeeded in optimizing.
8616 if (!isolate->use_crankshaft() || !unoptimized->optimizable()) return false; 8599 if (!isolate->use_crankshaft() || !current_code->optimizable()) return false;
8617 // If we are trying to do OSR when there are already optimized 8600 // If we are trying to do OSR when there are already optimized
8618 // activations of the function, it means (a) the function is directly or 8601 // activations of the function, it means (a) the function is directly or
8619 // indirectly recursive and (b) an optimized invocation has been 8602 // indirectly recursive and (b) an optimized invocation has been
8620 // deoptimized so that we are currently in an unoptimized activation. 8603 // deoptimized so that we are currently in an unoptimized activation.
8621 // Check for optimized activations of this function. 8604 // Check for optimized activations of this function.
8622 for (JavaScriptFrameIterator it(isolate); !it.done(); it.Advance()) { 8605 for (JavaScriptFrameIterator it(isolate); !it.done(); it.Advance()) {
8623 JavaScriptFrame* frame = it.frame(); 8606 JavaScriptFrame* frame = it.frame();
8624 if (frame->is_optimized() && frame->function() == *function) return false; 8607 if (frame->is_optimized() && frame->function() == *function) return false;
8625 } 8608 }
8626 8609
8627 return true; 8610 return true;
8628 } 8611 }
8629 8612
8630 8613
8631 RUNTIME_FUNCTION(MaybeObject*, Runtime_CompileForOnStackReplacement) { 8614 RUNTIME_FUNCTION(MaybeObject*, Runtime_CompileForOnStackReplacement) {
8632 HandleScope scope(isolate); 8615 HandleScope scope(isolate);
8633 ASSERT(args.length() == 2); 8616 ASSERT(args.length() == 1);
8634 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); 8617 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
8635 CONVERT_NUMBER_CHECKED(uint32_t, pc_offset, Uint32, args[1]); 8618 Handle<Code> caller_code(function->shared()->code());
8636 Handle<Code> unoptimized(function->shared()->code(), isolate);
8637
8638 #ifdef DEBUG
8639 JavaScriptFrameIterator it(isolate);
8640 JavaScriptFrame* frame = it.frame();
8641 ASSERT_EQ(frame->function(), *function);
8642 ASSERT_EQ(frame->LookupCode(), *unoptimized);
8643 ASSERT(unoptimized->contains(frame->pc()));
8644
8645 ASSERT(pc_offset ==
8646 static_cast<uint32_t>(frame->pc() - unoptimized->instruction_start()));
8647 #endif // DEBUG
8648 8619
8649 // We're not prepared to handle a function with arguments object. 8620 // We're not prepared to handle a function with arguments object.
8650 ASSERT(!function->shared()->uses_arguments()); 8621 ASSERT(!function->shared()->uses_arguments());
8651 8622
8623 // Passing the PC in the javascript frame from the caller directly is
8624 // not GC safe, so we walk the stack to get it.
8625 JavaScriptFrameIterator it(isolate);
8626 JavaScriptFrame* frame = it.frame();
8627 if (!caller_code->contains(frame->pc())) {
8628 // Code on the stack may not be the code object referenced by the shared
8629 // function info. It may have been replaced to include deoptimization data.
8630 caller_code = Handle<Code>(frame->LookupCode());
8631 }
8632
8633 uint32_t pc_offset = static_cast<uint32_t>(
8634 frame->pc() - caller_code->instruction_start());
8635
8636 #ifdef DEBUG
8637 ASSERT_EQ(frame->function(), *function);
8638 ASSERT_EQ(frame->LookupCode(), *caller_code);
8639 ASSERT(caller_code->contains(frame->pc()));
8640 #endif // DEBUG
8641
8642
8643 BailoutId ast_id = caller_code->TranslatePcOffsetToAstId(pc_offset);
8644 ASSERT(!ast_id.IsNone());
8645
8646 Compiler::ConcurrencyMode mode = isolate->concurrent_osr_enabled()
8647 ? Compiler::CONCURRENT : Compiler::NOT_CONCURRENT;
8652 Handle<Code> result = Handle<Code>::null(); 8648 Handle<Code> result = Handle<Code>::null();
8653 BailoutId ast_id = BailoutId::None();
8654 8649
8655 if (isolate->concurrent_osr_enabled()) { 8650 OptimizedCompileJob* job = NULL;
8656 if (isolate->optimizing_compiler_thread()-> 8651 if (mode == Compiler::CONCURRENT) {
8657 IsQueuedForOSR(function, pc_offset)) { 8652 // Gate the OSR entry with a stack check.
8658 // Still waiting for the optimizing compiler thread to finish. Carry on. 8653 BackEdgeTable::AddStackCheck(caller_code, pc_offset);
8654 // Poll already queued compilation jobs.
8655 OptimizingCompilerThread* thread = isolate->optimizing_compiler_thread();
8656 if (thread->IsQueuedForOSR(function, ast_id)) {
8659 if (FLAG_trace_osr) { 8657 if (FLAG_trace_osr) {
8660 PrintF("[COSR - polling recompile tasks for "); 8658 PrintF("[OSR - Still waiting for queued: ");
8661 function->PrintName(); 8659 function->PrintName();
8662 PrintF("]\n"); 8660 PrintF(" at AST id %d]\n", ast_id.ToInt());
8663 } 8661 }
8664 return NULL; 8662 return NULL;
8665 } 8663 }
8666 8664
8667 RecompileJob* job = isolate->optimizing_compiler_thread()-> 8665 job = thread->FindReadyOSRCandidate(function, ast_id);
8668 FindReadyOSRCandidate(function, pc_offset); 8666 }
8669 8667
8670 if (job == NULL) { 8668 if (job != NULL) {
8671 if (IsSuitableForOnStackReplacement(isolate, function, unoptimized) && 8669 if (FLAG_trace_osr) {
8672 Compiler::RecompileConcurrent(function, pc_offset)) { 8670 PrintF("[OSR - Found ready: ");
8673 if (function->IsMarkedForLazyRecompilation() || 8671 function->PrintName();
8674 function->IsMarkedForConcurrentRecompilation()) { 8672 PrintF(" at AST id %d]\n", ast_id.ToInt());
8675 // Prevent regular recompilation if we queue this for OSR.
8676 // TODO(yangguo): remove this as soon as OSR becomes one-shot.
8677 function->ReplaceCode(*unoptimized);
8678 }
8679 return NULL;
8680 }
8681 // Fall through to the end in case of failure.
8682 } else {
8683 // TODO(titzer): don't install the OSR code into the function.
8684 ast_id = job->info()->osr_ast_id();
8685 result = Compiler::InstallOptimizedCode(job);
8686 } 8673 }
8687 } else if (IsSuitableForOnStackReplacement(isolate, function, unoptimized)) { 8674 result = Compiler::GetConcurrentlyOptimizedCode(job);
8688 ast_id = unoptimized->TranslatePcOffsetToAstId(pc_offset); 8675 } else if (result.is_null() &&
8689 ASSERT(!ast_id.IsNone()); 8676 IsSuitableForOnStackReplacement(isolate, function, caller_code)) {
8690 if (FLAG_trace_osr) { 8677 if (FLAG_trace_osr) {
8691 PrintF("[OSR - replacing at AST id %d in ", ast_id.ToInt()); 8678 PrintF("[OSR - Compiling: ");
8692 function->PrintName(); 8679 function->PrintName();
8693 PrintF("]\n"); 8680 PrintF(" at AST id %d]\n", ast_id.ToInt());
8694 } 8681 }
8695 // Attempt OSR compilation. 8682 result = Compiler::GetOptimizedCode(function, caller_code, mode, ast_id);
8696 result = JSFunction::CompileOsr(function, ast_id, CLEAR_EXCEPTION); 8683 if (result.is_identical_to(isolate->builtins()->InOptimizationQueue())) {
8684 // Optimization is queued. Return to check later.
8685 return NULL;
8686 }
8697 } 8687 }
8698 8688
8699 // Revert the patched back edge table, regardless of whether OSR succeeds. 8689 // Revert the patched back edge table, regardless of whether OSR succeeds.
8700 BackEdgeTable::Revert(isolate, *unoptimized); 8690 BackEdgeTable::Revert(isolate, *caller_code);
8701 8691
8702 // Check whether we ended up with usable optimized code. 8692 // Check whether we ended up with usable optimized code.
8703 if (!result.is_null() && result->kind() == Code::OPTIMIZED_FUNCTION) { 8693 if (!result.is_null() && result->kind() == Code::OPTIMIZED_FUNCTION) {
8704 DeoptimizationInputData* data = 8694 DeoptimizationInputData* data =
8705 DeoptimizationInputData::cast(result->deoptimization_data()); 8695 DeoptimizationInputData::cast(result->deoptimization_data());
8706 8696
8707 if (data->OsrPcOffset()->value() >= 0) { 8697 if (data->OsrPcOffset()->value() >= 0) {
8708 ASSERT(BailoutId(data->OsrAstId()->value()) == ast_id); 8698 ASSERT(BailoutId(data->OsrAstId()->value()) == ast_id);
8709 if (FLAG_trace_osr) { 8699 if (FLAG_trace_osr) {
8710 PrintF("[OSR - entry at AST id %d, offset %d in optimized code]\n", 8700 PrintF("[OSR - Entry at AST id %d, offset %d in optimized code]\n",
8711 ast_id.ToInt(), data->OsrPcOffset()->value()); 8701 ast_id.ToInt(), data->OsrPcOffset()->value());
8712 } 8702 }
8713 // TODO(titzer): this is a massive hack to make the deopt counts 8703 // TODO(titzer): this is a massive hack to make the deopt counts
8714 // match. Fix heuristics for reenabling optimizations! 8704 // match. Fix heuristics for reenabling optimizations!
8715 function->shared()->increment_deopt_count(); 8705 function->shared()->increment_deopt_count();
8706
8707 // TODO(titzer): Do not install code into the function.
8708 function->ReplaceCode(*result);
8716 return *result; 8709 return *result;
8717 } 8710 }
8718 } 8711 }
8719 8712
8713 // Failed.
8720 if (FLAG_trace_osr) { 8714 if (FLAG_trace_osr) {
8721 PrintF("[OSR - optimization failed for "); 8715 PrintF("[OSR - Failed: ");
8722 function->PrintName(); 8716 function->PrintName();
8723 PrintF("]\n"); 8717 PrintF(" at AST id %d]\n", ast_id.ToInt());
8724 } 8718 }
8725 8719
8726 if (function->IsMarkedForLazyRecompilation() || 8720 function->ReplaceCode(function->shared()->code());
8727 function->IsMarkedForConcurrentRecompilation()) {
8728 function->ReplaceCode(function->shared()->code());
8729 }
8730 return NULL; 8721 return NULL;
8731 } 8722 }
8732 8723
8733 8724
8734 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetAllocationTimeout) { 8725 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetAllocationTimeout) {
8735 SealHandleScope shs(isolate); 8726 SealHandleScope shs(isolate);
8736 ASSERT(args.length() == 2); 8727 ASSERT(args.length() == 2);
8737 #ifdef DEBUG 8728 #ifdef DEBUG
8738 CONVERT_SMI_ARG_CHECKED(interval, 0); 8729 CONVERT_SMI_ARG_CHECKED(interval, 0);
8739 CONVERT_SMI_ARG_CHECKED(timeout, 1); 8730 CONVERT_SMI_ARG_CHECKED(timeout, 1);
(...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after
9421 9412
9422 // First check if this is a real stack overflow. 9413 // First check if this is a real stack overflow.
9423 if (isolate->stack_guard()->IsStackOverflow()) { 9414 if (isolate->stack_guard()->IsStackOverflow()) {
9424 return isolate->StackOverflow(); 9415 return isolate->StackOverflow();
9425 } 9416 }
9426 9417
9427 return Execution::HandleStackGuardInterrupt(isolate); 9418 return Execution::HandleStackGuardInterrupt(isolate);
9428 } 9419 }
9429 9420
9430 9421
9431 RUNTIME_FUNCTION(MaybeObject*, Runtime_TryInstallRecompiledCode) { 9422 RUNTIME_FUNCTION(MaybeObject*, Runtime_TryInstallOptimizedCode) {
9432 HandleScope scope(isolate); 9423 HandleScope scope(isolate);
9433 ASSERT(args.length() == 1); 9424 ASSERT(args.length() == 1);
9434 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); 9425 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
9435 9426
9436 // First check if this is a real stack overflow. 9427 // First check if this is a real stack overflow.
9437 if (isolate->stack_guard()->IsStackOverflow()) { 9428 if (isolate->stack_guard()->IsStackOverflow()) {
9438 SealHandleScope shs(isolate); 9429 SealHandleScope shs(isolate);
9439 return isolate->StackOverflow(); 9430 return isolate->StackOverflow();
9440 } 9431 }
9441 9432
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
9609 9600
9610 RUNTIME_FUNCTION(MaybeObject*, Runtime_GlobalReceiver) { 9601 RUNTIME_FUNCTION(MaybeObject*, Runtime_GlobalReceiver) {
9611 SealHandleScope shs(isolate); 9602 SealHandleScope shs(isolate);
9612 ASSERT(args.length() == 1); 9603 ASSERT(args.length() == 1);
9613 Object* global = args[0]; 9604 Object* global = args[0];
9614 if (!global->IsJSGlobalObject()) return isolate->heap()->null_value(); 9605 if (!global->IsJSGlobalObject()) return isolate->heap()->null_value();
9615 return JSGlobalObject::cast(global)->global_receiver(); 9606 return JSGlobalObject::cast(global)->global_receiver();
9616 } 9607 }
9617 9608
9618 9609
9610 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsAttachedGlobal) {
9611 SealHandleScope shs(isolate);
9612 ASSERT(args.length() == 1);
9613 Object* global = args[0];
9614 if (!global->IsJSGlobalObject()) return isolate->heap()->false_value();
9615 return isolate->heap()->ToBoolean(
9616 !JSGlobalObject::cast(global)->IsDetached());
9617 }
9618
9619
9619 RUNTIME_FUNCTION(MaybeObject*, Runtime_ParseJson) { 9620 RUNTIME_FUNCTION(MaybeObject*, Runtime_ParseJson) {
9620 HandleScope scope(isolate); 9621 HandleScope scope(isolate);
9621 ASSERT_EQ(1, args.length()); 9622 ASSERT_EQ(1, args.length());
9622 CONVERT_ARG_HANDLE_CHECKED(String, source, 0); 9623 CONVERT_ARG_HANDLE_CHECKED(String, source, 0);
9623 9624
9624 source = Handle<String>(FlattenGetString(source)); 9625 source = Handle<String>(FlattenGetString(source));
9625 // Optimized fast case where we only have ASCII characters. 9626 // Optimized fast case where we only have ASCII characters.
9626 Handle<Object> result; 9627 Handle<Object> result;
9627 if (source->IsSeqOneByteString()) { 9628 if (source->IsSeqOneByteString()) {
9628 result = JsonParser<true>::Parse(source); 9629 result = JsonParser<true>::Parse(source);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
9670 !CodeGenerationFromStringsAllowed(isolate, context)) { 9671 !CodeGenerationFromStringsAllowed(isolate, context)) {
9671 Handle<Object> error_message = 9672 Handle<Object> error_message =
9672 context->ErrorMessageForCodeGenerationFromStrings(); 9673 context->ErrorMessageForCodeGenerationFromStrings();
9673 return isolate->Throw(*isolate->factory()->NewEvalError( 9674 return isolate->Throw(*isolate->factory()->NewEvalError(
9674 "code_gen_from_strings", HandleVector<Object>(&error_message, 1))); 9675 "code_gen_from_strings", HandleVector<Object>(&error_message, 1)));
9675 } 9676 }
9676 9677
9677 // Compile source string in the native context. 9678 // Compile source string in the native context.
9678 ParseRestriction restriction = function_literal_only 9679 ParseRestriction restriction = function_literal_only
9679 ? ONLY_SINGLE_FUNCTION_LITERAL : NO_PARSE_RESTRICTION; 9680 ? ONLY_SINGLE_FUNCTION_LITERAL : NO_PARSE_RESTRICTION;
9680 Handle<SharedFunctionInfo> shared = Compiler::CompileEval( 9681 Handle<JSFunction> fun = Compiler::GetFunctionFromEval(
9681 source, context, true, CLASSIC_MODE, restriction, RelocInfo::kNoPosition); 9682 source, context, CLASSIC_MODE, restriction, RelocInfo::kNoPosition);
9682 RETURN_IF_EMPTY_HANDLE(isolate, shared); 9683 RETURN_IF_EMPTY_HANDLE(isolate, fun);
9683 Handle<JSFunction> fun =
9684 isolate->factory()->NewFunctionFromSharedFunctionInfo(shared,
9685 context,
9686 NOT_TENURED);
9687 return *fun; 9684 return *fun;
9688 } 9685 }
9689 9686
9690 9687
9691 static ObjectPair CompileGlobalEval(Isolate* isolate, 9688 static ObjectPair CompileGlobalEval(Isolate* isolate,
9692 Handle<String> source, 9689 Handle<String> source,
9693 Handle<Object> receiver, 9690 Handle<Object> receiver,
9694 LanguageMode language_mode, 9691 LanguageMode language_mode,
9695 int scope_position) { 9692 int scope_position) {
9696 Handle<Context> context = Handle<Context>(isolate->context()); 9693 Handle<Context> context = Handle<Context>(isolate->context());
9697 Handle<Context> native_context = Handle<Context>(context->native_context()); 9694 Handle<Context> native_context = Handle<Context>(context->native_context());
9698 9695
9699 // Check if native context allows code generation from 9696 // Check if native context allows code generation from
9700 // strings. Throw an exception if it doesn't. 9697 // strings. Throw an exception if it doesn't.
9701 if (native_context->allow_code_gen_from_strings()->IsFalse() && 9698 if (native_context->allow_code_gen_from_strings()->IsFalse() &&
9702 !CodeGenerationFromStringsAllowed(isolate, native_context)) { 9699 !CodeGenerationFromStringsAllowed(isolate, native_context)) {
9703 Handle<Object> error_message = 9700 Handle<Object> error_message =
9704 native_context->ErrorMessageForCodeGenerationFromStrings(); 9701 native_context->ErrorMessageForCodeGenerationFromStrings();
9705 isolate->Throw(*isolate->factory()->NewEvalError( 9702 isolate->Throw(*isolate->factory()->NewEvalError(
9706 "code_gen_from_strings", HandleVector<Object>(&error_message, 1))); 9703 "code_gen_from_strings", HandleVector<Object>(&error_message, 1)));
9707 return MakePair(Failure::Exception(), NULL); 9704 return MakePair(Failure::Exception(), NULL);
9708 } 9705 }
9709 9706
9710 // Deal with a normal eval call with a string argument. Compile it 9707 // Deal with a normal eval call with a string argument. Compile it
9711 // and return the compiled function bound in the local context. 9708 // and return the compiled function bound in the local context.
9712 Handle<SharedFunctionInfo> shared = Compiler::CompileEval( 9709 static const ParseRestriction restriction = NO_PARSE_RESTRICTION;
9713 source, 9710 Handle<JSFunction> compiled = Compiler::GetFunctionFromEval(
9714 context, 9711 source, context, language_mode, restriction, scope_position);
9715 context->IsNativeContext(), 9712 RETURN_IF_EMPTY_HANDLE_VALUE(isolate, compiled,
9716 language_mode,
9717 NO_PARSE_RESTRICTION,
9718 scope_position);
9719 RETURN_IF_EMPTY_HANDLE_VALUE(isolate, shared,
9720 MakePair(Failure::Exception(), NULL)); 9713 MakePair(Failure::Exception(), NULL));
9721 Handle<JSFunction> compiled =
9722 isolate->factory()->NewFunctionFromSharedFunctionInfo(
9723 shared, context, NOT_TENURED);
9724 return MakePair(*compiled, *receiver); 9714 return MakePair(*compiled, *receiver);
9725 } 9715 }
9726 9716
9727 9717
9728 RUNTIME_FUNCTION(ObjectPair, Runtime_ResolvePossiblyDirectEval) { 9718 RUNTIME_FUNCTION(ObjectPair, Runtime_ResolvePossiblyDirectEval) {
9729 HandleScope scope(isolate); 9719 HandleScope scope(isolate);
9730 ASSERT(args.length() == 5); 9720 ASSERT(args.length() == 5);
9731 9721
9732 Handle<Object> callee = args.at<Object>(0); 9722 Handle<Object> callee = args.at<Object>(0);
9733 9723
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
9924 slow_storage = loop_scope.CloseAndEscape(new_storage); 9914 slow_storage = loop_scope.CloseAndEscape(new_storage);
9925 } 9915 }
9926 } 9916 }
9927 } 9917 }
9928 clear_storage(); 9918 clear_storage();
9929 set_storage(*slow_storage); 9919 set_storage(*slow_storage);
9930 fast_elements_ = false; 9920 fast_elements_ = false;
9931 } 9921 }
9932 9922
9933 inline void clear_storage() { 9923 inline void clear_storage() {
9934 isolate_->global_handles()->Destroy( 9924 GlobalHandles::Destroy(Handle<Object>::cast(storage_).location());
9935 Handle<Object>::cast(storage_).location());
9936 } 9925 }
9937 9926
9938 inline void set_storage(FixedArray* storage) { 9927 inline void set_storage(FixedArray* storage) {
9939 storage_ = Handle<FixedArray>::cast( 9928 storage_ = Handle<FixedArray>::cast(
9940 isolate_->global_handles()->Create(storage)); 9929 isolate_->global_handles()->Create(storage));
9941 } 9930 }
9942 9931
9943 Isolate* isolate_; 9932 Isolate* isolate_;
9944 Handle<FixedArray> storage_; // Always a global handle. 9933 Handle<FixedArray> storage_; // Always a global handle.
9945 // Index after last seen index. Always less than or equal to 9934 // Index after last seen index. Always less than or equal to
(...skipping 1403 matching lines...) Expand 10 before | Expand all | Expand 10 after
11349 static Handle<JSObject> MaterializeStackLocalsWithFrameInspector( 11338 static Handle<JSObject> MaterializeStackLocalsWithFrameInspector(
11350 Isolate* isolate, 11339 Isolate* isolate,
11351 Handle<JSObject> target, 11340 Handle<JSObject> target,
11352 Handle<JSFunction> function, 11341 Handle<JSFunction> function,
11353 FrameInspector* frame_inspector) { 11342 FrameInspector* frame_inspector) {
11354 Handle<SharedFunctionInfo> shared(function->shared()); 11343 Handle<SharedFunctionInfo> shared(function->shared());
11355 Handle<ScopeInfo> scope_info(shared->scope_info()); 11344 Handle<ScopeInfo> scope_info(shared->scope_info());
11356 11345
11357 // First fill all parameters. 11346 // First fill all parameters.
11358 for (int i = 0; i < scope_info->ParameterCount(); ++i) { 11347 for (int i = 0; i < scope_info->ParameterCount(); ++i) {
11348 Handle<String> name(scope_info->ParameterName(i));
11349 VariableMode mode;
11350 InitializationFlag init_flag;
11351 // Do not materialize the parameter if it is shadowed by a context local.
11352 if (scope_info->ContextSlotIndex(*name, &mode, &init_flag) != -1) continue;
11353
11359 Handle<Object> value(i < frame_inspector->GetParametersCount() 11354 Handle<Object> value(i < frame_inspector->GetParametersCount()
11360 ? frame_inspector->GetParameter(i) 11355 ? frame_inspector->GetParameter(i)
11361 : isolate->heap()->undefined_value(), 11356 : isolate->heap()->undefined_value(),
11362 isolate); 11357 isolate);
11363 ASSERT(!value->IsTheHole()); 11358 ASSERT(!value->IsTheHole());
11364 11359
11365 RETURN_IF_EMPTY_HANDLE_VALUE( 11360 RETURN_IF_EMPTY_HANDLE_VALUE(
11366 isolate, 11361 isolate,
11367 Runtime::SetObjectProperty(isolate, 11362 Runtime::SetObjectProperty(
11368 target, 11363 isolate, target, name, value, NONE, kNonStrictMode),
11369 Handle<String>(scope_info->ParameterName(i)),
11370 value,
11371 NONE,
11372 kNonStrictMode),
11373 Handle<JSObject>()); 11364 Handle<JSObject>());
11374 } 11365 }
11375 11366
11376 // Second fill all stack locals. 11367 // Second fill all stack locals.
11377 for (int i = 0; i < scope_info->StackLocalCount(); ++i) { 11368 for (int i = 0; i < scope_info->StackLocalCount(); ++i) {
11369 Handle<String> name(scope_info->StackLocalName(i));
11378 Handle<Object> value(frame_inspector->GetExpression(i), isolate); 11370 Handle<Object> value(frame_inspector->GetExpression(i), isolate);
11379 if (value->IsTheHole()) continue; 11371 if (value->IsTheHole()) continue;
11380 11372
11381 RETURN_IF_EMPTY_HANDLE_VALUE( 11373 RETURN_IF_EMPTY_HANDLE_VALUE(
11382 isolate, 11374 isolate,
11383 Runtime::SetObjectProperty( 11375 Runtime::SetObjectProperty(
11384 isolate, 11376 isolate, target, name, value, NONE, kNonStrictMode),
11385 target,
11386 Handle<String>(scope_info->StackLocalName(i)),
11387 value,
11388 NONE,
11389 kNonStrictMode),
11390 Handle<JSObject>()); 11377 Handle<JSObject>());
11391 } 11378 }
11392 11379
11393 return target; 11380 return target;
11394 } 11381 }
11395 11382
11396 11383
11397 static void UpdateStackLocalsFromMaterializedObject(Isolate* isolate, 11384 static void UpdateStackLocalsFromMaterializedObject(Isolate* isolate,
11398 Handle<JSObject> target, 11385 Handle<JSObject> target,
11399 Handle<JSFunction> function, 11386 Handle<JSFunction> function,
(...skipping 1148 matching lines...) Expand 10 before | Expand all | Expand 10 after
12548 static_cast<BreakPositionAlignment>(statement_aligned_code); 12535 static_cast<BreakPositionAlignment>(statement_aligned_code);
12549 12536
12550 // Get the script from the script wrapper. 12537 // Get the script from the script wrapper.
12551 RUNTIME_ASSERT(wrapper->value()->IsScript()); 12538 RUNTIME_ASSERT(wrapper->value()->IsScript());
12552 Handle<Script> script(Script::cast(wrapper->value())); 12539 Handle<Script> script(Script::cast(wrapper->value()));
12553 12540
12554 // Set break point. 12541 // Set break point.
12555 if (!isolate->debug()->SetBreakPointForScript(script, break_point_object_arg, 12542 if (!isolate->debug()->SetBreakPointForScript(script, break_point_object_arg,
12556 &source_position, 12543 &source_position,
12557 alignment)) { 12544 alignment)) {
12558 return isolate->heap()->undefined_value(); 12545 return isolate->heap()->undefined_value();
12559 } 12546 }
12560 12547
12561 return Smi::FromInt(source_position); 12548 return Smi::FromInt(source_position);
12562 } 12549 }
12563 12550
12564 12551
12565 // Clear a break point 12552 // Clear a break point
12566 // args[0]: number: break point object 12553 // args[0]: number: break point object
12567 RUNTIME_FUNCTION(MaybeObject*, Runtime_ClearBreakPoint) { 12554 RUNTIME_FUNCTION(MaybeObject*, Runtime_ClearBreakPoint) {
12568 HandleScope scope(isolate); 12555 HandleScope scope(isolate);
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
12708 Handle<Context> context, 12695 Handle<Context> context,
12709 Handle<Object> context_extension, 12696 Handle<Object> context_extension,
12710 Handle<Object> receiver, 12697 Handle<Object> receiver,
12711 Handle<String> source) { 12698 Handle<String> source) {
12712 if (context_extension->IsJSObject()) { 12699 if (context_extension->IsJSObject()) {
12713 Handle<JSObject> extension = Handle<JSObject>::cast(context_extension); 12700 Handle<JSObject> extension = Handle<JSObject>::cast(context_extension);
12714 Handle<JSFunction> closure(context->closure(), isolate); 12701 Handle<JSFunction> closure(context->closure(), isolate);
12715 context = isolate->factory()->NewWithContext(closure, context, extension); 12702 context = isolate->factory()->NewWithContext(closure, context, extension);
12716 } 12703 }
12717 12704
12718 Handle<SharedFunctionInfo> shared = Compiler::CompileEval( 12705 Handle<JSFunction> eval_fun =
12719 source, 12706 Compiler::GetFunctionFromEval(source,
12720 context, 12707 context,
12721 context->IsNativeContext(), 12708 CLASSIC_MODE,
12722 CLASSIC_MODE, 12709 NO_PARSE_RESTRICTION,
12723 NO_PARSE_RESTRICTION, 12710 RelocInfo::kNoPosition);
12724 RelocInfo::kNoPosition); 12711 RETURN_IF_EMPTY_HANDLE(isolate, eval_fun);
12725 RETURN_IF_EMPTY_HANDLE(isolate, shared);
12726 12712
12727 Handle<JSFunction> eval_fun =
12728 isolate->factory()->NewFunctionFromSharedFunctionInfo(
12729 shared, context, NOT_TENURED);
12730 bool pending_exception; 12713 bool pending_exception;
12731 Handle<Object> result = Execution::Call( 12714 Handle<Object> result = Execution::Call(
12732 isolate, eval_fun, receiver, 0, NULL, &pending_exception); 12715 isolate, eval_fun, receiver, 0, NULL, &pending_exception);
12733 12716
12734 if (pending_exception) return Failure::Exception(); 12717 if (pending_exception) return Failure::Exception();
12735 12718
12736 // Skip the global proxy as it has no properties and always delegates to the 12719 // Skip the global proxy as it has no properties and always delegates to the
12737 // real global object. 12720 // real global object.
12738 if (result->IsJSGlobalProxy()) { 12721 if (result->IsJSGlobalProxy()) {
12739 result = Handle<JSObject>(JSObject::cast(result->GetPrototype(isolate))); 12722 result = Handle<JSObject>(JSObject::cast(result->GetPrototype(isolate)));
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
13135 return isolate->heap()->undefined_value(); 13118 return isolate->heap()->undefined_value();
13136 } 13119 }
13137 13120
13138 13121
13139 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugDisassembleFunction) { 13122 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugDisassembleFunction) {
13140 HandleScope scope(isolate); 13123 HandleScope scope(isolate);
13141 #ifdef DEBUG 13124 #ifdef DEBUG
13142 ASSERT(args.length() == 1); 13125 ASSERT(args.length() == 1);
13143 // Get the function and make sure it is compiled. 13126 // Get the function and make sure it is compiled.
13144 CONVERT_ARG_HANDLE_CHECKED(JSFunction, func, 0); 13127 CONVERT_ARG_HANDLE_CHECKED(JSFunction, func, 0);
13145 if (!JSFunction::EnsureCompiled(func, KEEP_EXCEPTION)) { 13128 if (!Compiler::EnsureCompiled(func, KEEP_EXCEPTION)) {
13146 return Failure::Exception(); 13129 return Failure::Exception();
13147 } 13130 }
13148 func->code()->PrintLn(); 13131 func->code()->PrintLn();
13149 #endif // DEBUG 13132 #endif // DEBUG
13150 return isolate->heap()->undefined_value(); 13133 return isolate->heap()->undefined_value();
13151 } 13134 }
13152 13135
13153 13136
13154 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugDisassembleConstructor) { 13137 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugDisassembleConstructor) {
13155 HandleScope scope(isolate); 13138 HandleScope scope(isolate);
13156 #ifdef DEBUG 13139 #ifdef DEBUG
13157 ASSERT(args.length() == 1); 13140 ASSERT(args.length() == 1);
13158 // Get the function and make sure it is compiled. 13141 // Get the function and make sure it is compiled.
13159 CONVERT_ARG_HANDLE_CHECKED(JSFunction, func, 0); 13142 CONVERT_ARG_HANDLE_CHECKED(JSFunction, func, 0);
13160 if (!JSFunction::EnsureCompiled(func, KEEP_EXCEPTION)) { 13143 if (!Compiler::EnsureCompiled(func, KEEP_EXCEPTION)) {
13161 return Failure::Exception(); 13144 return Failure::Exception();
13162 } 13145 }
13163 func->shared()->construct_stub()->PrintLn(); 13146 func->shared()->construct_stub()->PrintLn();
13164 #endif // DEBUG 13147 #endif // DEBUG
13165 return isolate->heap()->undefined_value(); 13148 return isolate->heap()->undefined_value();
13166 } 13149 }
13167 13150
13168 13151
13169 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetInferredName) { 13152 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetInferredName) {
13170 SealHandleScope shs(isolate); 13153 SealHandleScope shs(isolate);
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
13523 } 13506 }
13524 } 13507 }
13525 13508
13526 13509
13527 // Sets a v8 flag. 13510 // Sets a v8 flag.
13528 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetFlags) { 13511 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetFlags) {
13529 SealHandleScope shs(isolate); 13512 SealHandleScope shs(isolate);
13530 CONVERT_ARG_CHECKED(String, arg, 0); 13513 CONVERT_ARG_CHECKED(String, arg, 0);
13531 SmartArrayPointer<char> flags = 13514 SmartArrayPointer<char> flags =
13532 arg->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); 13515 arg->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL);
13533 FlagList::SetFlagsFromString(*flags, StrLength(*flags)); 13516 FlagList::SetFlagsFromString(flags.get(), StrLength(flags.get()));
13534 return isolate->heap()->undefined_value(); 13517 return isolate->heap()->undefined_value();
13535 } 13518 }
13536 13519
13537 13520
13538 // Performs a GC. 13521 // Performs a GC.
13539 // Presently, it only does a full GC. 13522 // Presently, it only does a full GC.
13540 RUNTIME_FUNCTION(MaybeObject*, Runtime_CollectGarbage) { 13523 RUNTIME_FUNCTION(MaybeObject*, Runtime_CollectGarbage) {
13541 SealHandleScope shs(isolate); 13524 SealHandleScope shs(isolate);
13542 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, "%CollectGarbage"); 13525 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, "%CollectGarbage");
13543 return isolate->heap()->undefined_value(); 13526 return isolate->heap()->undefined_value();
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
13781 13764
13782 RETURN_IF_EMPTY_HANDLE(isolate, 13765 RETURN_IF_EMPTY_HANDLE(isolate,
13783 JSObject::SetLocalPropertyIgnoreAttributes( 13766 JSObject::SetLocalPropertyIgnoreAttributes(
13784 local_object, 13767 local_object,
13785 isolate->factory()->NewStringFromAscii(CStrVector("dateFormat")), 13768 isolate->factory()->NewStringFromAscii(CStrVector("dateFormat")),
13786 isolate->factory()->NewStringFromAscii(CStrVector("valid")), 13769 isolate->factory()->NewStringFromAscii(CStrVector("valid")),
13787 NONE)); 13770 NONE));
13788 13771
13789 // Make object handle weak so we can delete the data format once GC kicks in. 13772 // Make object handle weak so we can delete the data format once GC kicks in.
13790 Handle<Object> wrapper = isolate->global_handles()->Create(*local_object); 13773 Handle<Object> wrapper = isolate->global_handles()->Create(*local_object);
13791 GlobalHandles::MakeWeak(reinterpret_cast<Object**>(wrapper.location()), 13774 GlobalHandles::MakeWeak(wrapper.location(),
13792 NULL, 13775 reinterpret_cast<void*>(wrapper.location()),
13793 DateFormat::DeleteDateFormat); 13776 DateFormat::DeleteDateFormat);
13794 return *local_object; 13777 return *local_object;
13795 } 13778 }
13796 13779
13797 13780
13798 RUNTIME_FUNCTION(MaybeObject*, Runtime_InternalDateFormat) { 13781 RUNTIME_FUNCTION(MaybeObject*, Runtime_InternalDateFormat) {
13799 HandleScope scope(isolate); 13782 HandleScope scope(isolate);
13800 13783
13801 ASSERT(args.length() == 2); 13784 ASSERT(args.length() == 2);
13802 13785
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
13885 local_object->SetInternalField(0, reinterpret_cast<Smi*>(number_format)); 13868 local_object->SetInternalField(0, reinterpret_cast<Smi*>(number_format));
13886 13869
13887 RETURN_IF_EMPTY_HANDLE(isolate, 13870 RETURN_IF_EMPTY_HANDLE(isolate,
13888 JSObject::SetLocalPropertyIgnoreAttributes( 13871 JSObject::SetLocalPropertyIgnoreAttributes(
13889 local_object, 13872 local_object,
13890 isolate->factory()->NewStringFromAscii(CStrVector("numberFormat")), 13873 isolate->factory()->NewStringFromAscii(CStrVector("numberFormat")),
13891 isolate->factory()->NewStringFromAscii(CStrVector("valid")), 13874 isolate->factory()->NewStringFromAscii(CStrVector("valid")),
13892 NONE)); 13875 NONE));
13893 13876
13894 Handle<Object> wrapper = isolate->global_handles()->Create(*local_object); 13877 Handle<Object> wrapper = isolate->global_handles()->Create(*local_object);
13895 GlobalHandles::MakeWeak(reinterpret_cast<Object**>(wrapper.location()), 13878 GlobalHandles::MakeWeak(wrapper.location(),
13896 NULL, 13879 reinterpret_cast<void*>(wrapper.location()),
13897 NumberFormat::DeleteNumberFormat); 13880 NumberFormat::DeleteNumberFormat);
13898 return *local_object; 13881 return *local_object;
13899 } 13882 }
13900 13883
13901 13884
13902 RUNTIME_FUNCTION(MaybeObject*, Runtime_InternalNumberFormat) { 13885 RUNTIME_FUNCTION(MaybeObject*, Runtime_InternalNumberFormat) {
13903 HandleScope scope(isolate); 13886 HandleScope scope(isolate);
13904 13887
13905 ASSERT(args.length() == 2); 13888 ASSERT(args.length() == 2);
13906 13889
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
13997 local_object->SetInternalField(0, reinterpret_cast<Smi*>(collator)); 13980 local_object->SetInternalField(0, reinterpret_cast<Smi*>(collator));
13998 13981
13999 RETURN_IF_EMPTY_HANDLE(isolate, 13982 RETURN_IF_EMPTY_HANDLE(isolate,
14000 JSObject::SetLocalPropertyIgnoreAttributes( 13983 JSObject::SetLocalPropertyIgnoreAttributes(
14001 local_object, 13984 local_object,
14002 isolate->factory()->NewStringFromAscii(CStrVector("collator")), 13985 isolate->factory()->NewStringFromAscii(CStrVector("collator")),
14003 isolate->factory()->NewStringFromAscii(CStrVector("valid")), 13986 isolate->factory()->NewStringFromAscii(CStrVector("valid")),
14004 NONE)); 13987 NONE));
14005 13988
14006 Handle<Object> wrapper = isolate->global_handles()->Create(*local_object); 13989 Handle<Object> wrapper = isolate->global_handles()->Create(*local_object);
14007 GlobalHandles::MakeWeak(reinterpret_cast<Object**>(wrapper.location()), 13990 GlobalHandles::MakeWeak(wrapper.location(),
14008 NULL, 13991 reinterpret_cast<void*>(wrapper.location()),
14009 Collator::DeleteCollator); 13992 Collator::DeleteCollator);
14010 return *local_object; 13993 return *local_object;
14011 } 13994 }
14012 13995
14013 13996
14014 RUNTIME_FUNCTION(MaybeObject*, Runtime_InternalCompare) { 13997 RUNTIME_FUNCTION(MaybeObject*, Runtime_InternalCompare) {
14015 HandleScope scope(isolate); 13998 HandleScope scope(isolate);
14016 13999
14017 ASSERT(args.length() == 3); 14000 ASSERT(args.length() == 3);
14018 14001
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
14073 RETURN_IF_EMPTY_HANDLE(isolate, 14056 RETURN_IF_EMPTY_HANDLE(isolate,
14074 JSObject::SetLocalPropertyIgnoreAttributes( 14057 JSObject::SetLocalPropertyIgnoreAttributes(
14075 local_object, 14058 local_object,
14076 isolate->factory()->NewStringFromAscii(CStrVector("breakIterator")), 14059 isolate->factory()->NewStringFromAscii(CStrVector("breakIterator")),
14077 isolate->factory()->NewStringFromAscii(CStrVector("valid")), 14060 isolate->factory()->NewStringFromAscii(CStrVector("valid")),
14078 NONE)); 14061 NONE));
14079 14062
14080 // Make object handle weak so we can delete the break iterator once GC kicks 14063 // Make object handle weak so we can delete the break iterator once GC kicks
14081 // in. 14064 // in.
14082 Handle<Object> wrapper = isolate->global_handles()->Create(*local_object); 14065 Handle<Object> wrapper = isolate->global_handles()->Create(*local_object);
14083 GlobalHandles::MakeWeak(reinterpret_cast<Object**>(wrapper.location()), 14066 GlobalHandles::MakeWeak(wrapper.location(),
14084 NULL, 14067 reinterpret_cast<void*>(wrapper.location()),
14085 BreakIterator::DeleteBreakIterator); 14068 BreakIterator::DeleteBreakIterator);
14086 return *local_object; 14069 return *local_object;
14087 } 14070 }
14088 14071
14089 14072
14090 RUNTIME_FUNCTION(MaybeObject*, Runtime_BreakIteratorAdoptText) { 14073 RUNTIME_FUNCTION(MaybeObject*, Runtime_BreakIteratorAdoptText) {
14091 HandleScope scope(isolate); 14074 HandleScope scope(isolate);
14092 14075
14093 ASSERT(args.length() == 2); 14076 ASSERT(args.length() == 2);
14094 14077
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
14298 OS::Abort(); 14281 OS::Abort();
14299 UNREACHABLE(); 14282 UNREACHABLE();
14300 return NULL; 14283 return NULL;
14301 } 14284 }
14302 14285
14303 14286
14304 RUNTIME_FUNCTION(MaybeObject*, Runtime_AbortJS) { 14287 RUNTIME_FUNCTION(MaybeObject*, Runtime_AbortJS) {
14305 HandleScope scope(isolate); 14288 HandleScope scope(isolate);
14306 ASSERT(args.length() == 1); 14289 ASSERT(args.length() == 1);
14307 CONVERT_ARG_HANDLE_CHECKED(String, message, 0); 14290 CONVERT_ARG_HANDLE_CHECKED(String, message, 0);
14308 OS::PrintError("abort: %s\n", *message->ToCString()); 14291 OS::PrintError("abort: %s\n", message->ToCString().get());
14309 isolate->PrintStack(stderr); 14292 isolate->PrintStack(stderr);
14310 OS::Abort(); 14293 OS::Abort();
14311 UNREACHABLE(); 14294 UNREACHABLE();
14312 return NULL; 14295 return NULL;
14313 } 14296 }
14314 14297
14315 14298
14316 RUNTIME_FUNCTION(MaybeObject*, Runtime_FlattenString) { 14299 RUNTIME_FUNCTION(MaybeObject*, Runtime_FlattenString) {
14317 HandleScope scope(isolate); 14300 HandleScope scope(isolate);
14318 ASSERT(args.length() == 1); 14301 ASSERT(args.length() == 1);
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after
14885 // Handle last resort GC and make sure to allow future allocations 14868 // Handle last resort GC and make sure to allow future allocations
14886 // to grow the heap without causing GCs (if possible). 14869 // to grow the heap without causing GCs (if possible).
14887 isolate->counters()->gc_last_resort_from_js()->Increment(); 14870 isolate->counters()->gc_last_resort_from_js()->Increment();
14888 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, 14871 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags,
14889 "Runtime::PerformGC"); 14872 "Runtime::PerformGC");
14890 } 14873 }
14891 } 14874 }
14892 14875
14893 14876
14894 } } // namespace v8::internal 14877 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/runtime.h ('k') | src/runtime-profiler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698