OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 1273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1284 } | 1284 } |
1285 case JS_WEAK_MAP_TYPE: { | 1285 case JS_WEAK_MAP_TYPE: { |
1286 accumulator->Add("<JS WeakMap>"); | 1286 accumulator->Add("<JS WeakMap>"); |
1287 break; | 1287 break; |
1288 } | 1288 } |
1289 case JS_REGEXP_TYPE: { | 1289 case JS_REGEXP_TYPE: { |
1290 accumulator->Add("<JS RegExp>"); | 1290 accumulator->Add("<JS RegExp>"); |
1291 break; | 1291 break; |
1292 } | 1292 } |
1293 case JS_FUNCTION_TYPE: { | 1293 case JS_FUNCTION_TYPE: { |
1294 Object* fun_name = JSFunction::cast(this)->shared()->name(); | 1294 JSFunction* function = JSFunction::cast(this); |
| 1295 Object* fun_name = function->shared()->DebugName(); |
1295 bool printed = false; | 1296 bool printed = false; |
1296 if (fun_name->IsString()) { | 1297 if (fun_name->IsString()) { |
1297 String* str = String::cast(fun_name); | 1298 String* str = String::cast(fun_name); |
1298 if (str->length() > 0) { | 1299 if (str->length() > 0) { |
1299 accumulator->Add("<JS Function "); | 1300 accumulator->Add("<JS Function "); |
1300 accumulator->Put(str); | 1301 accumulator->Put(str); |
1301 accumulator->Put('>'); | |
1302 printed = true; | 1302 printed = true; |
1303 } | 1303 } |
1304 } | 1304 } |
1305 if (!printed) { | 1305 if (!printed) { |
1306 accumulator->Add("<JS Function>"); | 1306 accumulator->Add("<JS Function"); |
1307 } | 1307 } |
| 1308 accumulator->Add(" (SharedFunctionInfo %p)", |
| 1309 reinterpret_cast<intptr_t>(function->shared())); |
| 1310 accumulator->Put('>'); |
1308 break; | 1311 break; |
1309 } | 1312 } |
1310 case JS_GENERATOR_OBJECT_TYPE: { | 1313 case JS_GENERATOR_OBJECT_TYPE: { |
1311 accumulator->Add("<JS Generator>"); | 1314 accumulator->Add("<JS Generator>"); |
1312 break; | 1315 break; |
1313 } | 1316 } |
1314 case JS_MODULE_TYPE: { | 1317 case JS_MODULE_TYPE: { |
1315 accumulator->Add("<JS Module>"); | 1318 accumulator->Add("<JS Module>"); |
1316 break; | 1319 break; |
1317 } | 1320 } |
(...skipping 16 matching lines...) Expand all Loading... |
1334 Object* constructor_name = | 1337 Object* constructor_name = |
1335 JSFunction::cast(constructor)->shared()->name(); | 1338 JSFunction::cast(constructor)->shared()->name(); |
1336 if (constructor_name->IsString()) { | 1339 if (constructor_name->IsString()) { |
1337 String* str = String::cast(constructor_name); | 1340 String* str = String::cast(constructor_name); |
1338 if (str->length() > 0) { | 1341 if (str->length() > 0) { |
1339 bool vowel = AnWord(str); | 1342 bool vowel = AnWord(str); |
1340 accumulator->Add("<%sa%s ", | 1343 accumulator->Add("<%sa%s ", |
1341 global_object ? "Global Object: " : "", | 1344 global_object ? "Global Object: " : "", |
1342 vowel ? "n" : ""); | 1345 vowel ? "n" : ""); |
1343 accumulator->Put(str); | 1346 accumulator->Put(str); |
| 1347 accumulator->Add(" with %smap 0x%p", |
| 1348 map_of_this->is_deprecated() ? "deprecated " : "", |
| 1349 map_of_this); |
1344 printed = true; | 1350 printed = true; |
1345 } | 1351 } |
1346 } | 1352 } |
1347 } | 1353 } |
1348 } | 1354 } |
1349 if (!printed) { | 1355 if (!printed) { |
1350 accumulator->Add("<JS %sObject", global_object ? "Global " : ""); | 1356 accumulator->Add("<JS %sObject", global_object ? "Global " : ""); |
1351 } | 1357 } |
1352 } | 1358 } |
1353 if (IsJSValue()) { | 1359 if (IsJSValue()) { |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1449 ExternalUnsignedIntArray::cast(this)->length()); | 1455 ExternalUnsignedIntArray::cast(this)->length()); |
1450 break; | 1456 break; |
1451 case EXTERNAL_FLOAT_ARRAY_TYPE: | 1457 case EXTERNAL_FLOAT_ARRAY_TYPE: |
1452 accumulator->Add("<ExternalFloatArray[%u]>", | 1458 accumulator->Add("<ExternalFloatArray[%u]>", |
1453 ExternalFloatArray::cast(this)->length()); | 1459 ExternalFloatArray::cast(this)->length()); |
1454 break; | 1460 break; |
1455 case EXTERNAL_DOUBLE_ARRAY_TYPE: | 1461 case EXTERNAL_DOUBLE_ARRAY_TYPE: |
1456 accumulator->Add("<ExternalDoubleArray[%u]>", | 1462 accumulator->Add("<ExternalDoubleArray[%u]>", |
1457 ExternalDoubleArray::cast(this)->length()); | 1463 ExternalDoubleArray::cast(this)->length()); |
1458 break; | 1464 break; |
1459 case SHARED_FUNCTION_INFO_TYPE: | 1465 case SHARED_FUNCTION_INFO_TYPE: { |
1460 accumulator->Add("<SharedFunctionInfo>"); | 1466 SharedFunctionInfo* shared = SharedFunctionInfo::cast(this); |
| 1467 SmartArrayPointer<char> debug_name = |
| 1468 shared->DebugName()->ToCString(); |
| 1469 if (debug_name[0] != 0) { |
| 1470 accumulator->Add("<SharedFunctionInfo %s>", *debug_name); |
| 1471 } else { |
| 1472 accumulator->Add("<SharedFunctionInfo>"); |
| 1473 } |
1461 break; | 1474 break; |
| 1475 } |
1462 case JS_MESSAGE_OBJECT_TYPE: | 1476 case JS_MESSAGE_OBJECT_TYPE: |
1463 accumulator->Add("<JSMessageObject>"); | 1477 accumulator->Add("<JSMessageObject>"); |
1464 break; | 1478 break; |
1465 #define MAKE_STRUCT_CASE(NAME, Name, name) \ | 1479 #define MAKE_STRUCT_CASE(NAME, Name, name) \ |
1466 case NAME##_TYPE: \ | 1480 case NAME##_TYPE: \ |
1467 accumulator->Put('<'); \ | 1481 accumulator->Put('<'); \ |
1468 accumulator->Add(#Name); \ | 1482 accumulator->Add(#Name); \ |
1469 accumulator->Put('>'); \ | 1483 accumulator->Put('>'); \ |
1470 break; | 1484 break; |
1471 STRUCT_LIST(MAKE_STRUCT_CASE) | 1485 STRUCT_LIST(MAKE_STRUCT_CASE) |
(...skipping 6864 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8336 return true; | 8350 return true; |
8337 } else if (map == heap->ascii_string_map()) { | 8351 } else if (map == heap->ascii_string_map()) { |
8338 this->set_map(heap->undetectable_ascii_string_map()); | 8352 this->set_map(heap->undetectable_ascii_string_map()); |
8339 return true; | 8353 return true; |
8340 } | 8354 } |
8341 // Rest cannot be marked as undetectable | 8355 // Rest cannot be marked as undetectable |
8342 return false; | 8356 return false; |
8343 } | 8357 } |
8344 | 8358 |
8345 | 8359 |
8346 bool String::IsUtf8EqualTo(Vector<const char> str) { | 8360 bool String::IsUtf8EqualTo(Vector<const char> str, bool allow_prefix_match) { |
8347 int slen = length(); | 8361 int slen = length(); |
8348 // Can't check exact length equality, but we can check bounds. | 8362 // Can't check exact length equality, but we can check bounds. |
8349 int str_len = str.length(); | 8363 int str_len = str.length(); |
8350 if (str_len < slen || | 8364 if (!allow_prefix_match && |
8351 str_len > slen*static_cast<int>(unibrow::Utf8::kMaxEncodedSize)) { | 8365 (str_len < slen || |
| 8366 str_len > slen*static_cast<int>(unibrow::Utf8::kMaxEncodedSize))) { |
8352 return false; | 8367 return false; |
8353 } | 8368 } |
8354 int i; | 8369 int i; |
8355 unsigned remaining_in_str = static_cast<unsigned>(str_len); | 8370 unsigned remaining_in_str = static_cast<unsigned>(str_len); |
8356 const uint8_t* utf8_data = reinterpret_cast<const uint8_t*>(str.start()); | 8371 const uint8_t* utf8_data = reinterpret_cast<const uint8_t*>(str.start()); |
8357 for (i = 0; i < slen && remaining_in_str > 0; i++) { | 8372 for (i = 0; i < slen && remaining_in_str > 0; i++) { |
8358 unsigned cursor = 0; | 8373 unsigned cursor = 0; |
8359 uint32_t r = unibrow::Utf8::ValueOf(utf8_data, remaining_in_str, &cursor); | 8374 uint32_t r = unibrow::Utf8::ValueOf(utf8_data, remaining_in_str, &cursor); |
8360 ASSERT(cursor > 0 && cursor <= remaining_in_str); | 8375 ASSERT(cursor > 0 && cursor <= remaining_in_str); |
8361 if (r > unibrow::Utf16::kMaxNonSurrogateCharCode) { | 8376 if (r > unibrow::Utf16::kMaxNonSurrogateCharCode) { |
8362 if (i > slen - 1) return false; | 8377 if (i > slen - 1) return false; |
8363 if (Get(i++) != unibrow::Utf16::LeadSurrogate(r)) return false; | 8378 if (Get(i++) != unibrow::Utf16::LeadSurrogate(r)) return false; |
8364 if (Get(i) != unibrow::Utf16::TrailSurrogate(r)) return false; | 8379 if (Get(i) != unibrow::Utf16::TrailSurrogate(r)) return false; |
8365 } else { | 8380 } else { |
8366 if (Get(i) != r) return false; | 8381 if (Get(i) != r) return false; |
8367 } | 8382 } |
8368 utf8_data += cursor; | 8383 utf8_data += cursor; |
8369 remaining_in_str -= cursor; | 8384 remaining_in_str -= cursor; |
8370 } | 8385 } |
8371 return i == slen && remaining_in_str == 0; | 8386 return (allow_prefix_match || i == slen) && remaining_in_str == 0; |
8372 } | 8387 } |
8373 | 8388 |
8374 | 8389 |
8375 bool String::IsOneByteEqualTo(Vector<const uint8_t> str) { | 8390 bool String::IsOneByteEqualTo(Vector<const uint8_t> str) { |
8376 int slen = length(); | 8391 int slen = length(); |
8377 if (str.length() != slen) return false; | 8392 if (str.length() != slen) return false; |
8378 FlatContent content = GetFlatContent(); | 8393 FlatContent content = GetFlatContent(); |
8379 if (content.IsAscii()) { | 8394 if (content.IsAscii()) { |
8380 return CompareChars(content.ToOneByteVector().start(), | 8395 return CompareChars(content.ToOneByteVector().start(), |
8381 str.start(), slen) == 0; | 8396 str.start(), slen) == 0; |
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8981 ASSERT(cached_literals != NULL); | 8996 ASSERT(cached_literals != NULL); |
8982 function->set_literals(cached_literals); | 8997 function->set_literals(cached_literals); |
8983 } | 8998 } |
8984 Code* code = Code::cast(code_map->get(index)); | 8999 Code* code = Code::cast(code_map->get(index)); |
8985 ASSERT(code != NULL); | 9000 ASSERT(code != NULL); |
8986 ASSERT(function->context()->native_context() == code_map->get(index - 1)); | 9001 ASSERT(function->context()->native_context() == code_map->get(index - 1)); |
8987 function->ReplaceCode(code); | 9002 function->ReplaceCode(code); |
8988 } | 9003 } |
8989 | 9004 |
8990 | 9005 |
| 9006 void SharedFunctionInfo::ClearOptimizedCodeMap(const char* reason) { |
| 9007 if (!optimized_code_map()->IsSmi()) { |
| 9008 if (FLAG_trace_opt) { |
| 9009 PrintF("[clearing optimizing code map (%s) for ", reason); |
| 9010 ShortPrint(); |
| 9011 PrintF("]\n"); |
| 9012 } |
| 9013 set_optimized_code_map(Smi::FromInt(0)); |
| 9014 } |
| 9015 } |
| 9016 |
| 9017 |
8991 bool JSFunction::CompileLazy(Handle<JSFunction> function, | 9018 bool JSFunction::CompileLazy(Handle<JSFunction> function, |
8992 ClearExceptionFlag flag) { | 9019 ClearExceptionFlag flag) { |
8993 bool result = true; | 9020 bool result = true; |
8994 if (function->shared()->is_compiled()) { | 9021 if (function->shared()->is_compiled()) { |
8995 function->ReplaceCode(function->shared()->code()); | 9022 function->ReplaceCode(function->shared()->code()); |
8996 function->shared()->set_code_age(0); | 9023 function->shared()->set_code_age(0); |
8997 } else { | 9024 } else { |
8998 ASSERT(function->shared()->allows_lazy_compilation()); | 9025 ASSERT(function->shared()->allows_lazy_compilation()); |
8999 CompilationInfoWithZone info(function); | 9026 CompilationInfoWithZone info(function); |
9000 result = CompileLazyHelper(&info, flag); | 9027 result = CompileLazyHelper(&info, flag); |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9194 SmartArrayPointer<char> name = shared()->DebugName()->ToCString(); | 9221 SmartArrayPointer<char> name = shared()->DebugName()->ToCString(); |
9195 PrintF(out, "%s", *name); | 9222 PrintF(out, "%s", *name); |
9196 } | 9223 } |
9197 | 9224 |
9198 | 9225 |
9199 Context* JSFunction::NativeContextFromLiterals(FixedArray* literals) { | 9226 Context* JSFunction::NativeContextFromLiterals(FixedArray* literals) { |
9200 return Context::cast(literals->get(JSFunction::kLiteralNativeContextIndex)); | 9227 return Context::cast(literals->get(JSFunction::kLiteralNativeContextIndex)); |
9201 } | 9228 } |
9202 | 9229 |
9203 | 9230 |
| 9231 bool JSFunction::PassesHydrogenFilter() { |
| 9232 String* name = shared()->DebugName(); |
| 9233 if (*FLAG_hydrogen_filter != '\0') { |
| 9234 Vector<const char> filter = CStrVector(FLAG_hydrogen_filter); |
| 9235 if (filter[0] != '-' && name->IsUtf8EqualTo(filter)) return true; |
| 9236 if (filter[0] == '-' && |
| 9237 !name->IsUtf8EqualTo(filter.SubVector(1, filter.length()))) { |
| 9238 return true; |
| 9239 } |
| 9240 if (filter[filter.length() - 1] == '*' && |
| 9241 name->IsUtf8EqualTo(filter.SubVector(0, filter.length() - 1), true)) { |
| 9242 return true; |
| 9243 } |
| 9244 return false; |
| 9245 } |
| 9246 |
| 9247 return true; |
| 9248 } |
| 9249 |
| 9250 |
9204 MaybeObject* Oddball::Initialize(const char* to_string, | 9251 MaybeObject* Oddball::Initialize(const char* to_string, |
9205 Object* to_number, | 9252 Object* to_number, |
9206 byte kind) { | 9253 byte kind) { |
9207 String* internalized_to_string; | 9254 String* internalized_to_string; |
9208 { MaybeObject* maybe_string = | 9255 { MaybeObject* maybe_string = |
9209 Isolate::Current()->heap()->InternalizeUtf8String( | 9256 Isolate::Current()->heap()->InternalizeUtf8String( |
9210 CStrVector(to_string)); | 9257 CStrVector(to_string)); |
9211 if (!maybe_string->To(&internalized_to_string)) return maybe_string; | 9258 if (!maybe_string->To(&internalized_to_string)) return maybe_string; |
9212 } | 9259 } |
9213 set_to_string(internalized_to_string); | 9260 set_to_string(internalized_to_string); |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9448 // non-optimizable if optimization is disabled for the shared | 9495 // non-optimizable if optimization is disabled for the shared |
9449 // function info. | 9496 // function info. |
9450 set_optimization_disabled(true); | 9497 set_optimization_disabled(true); |
9451 // Code should be the lazy compilation stub or else unoptimized. If the | 9498 // Code should be the lazy compilation stub or else unoptimized. If the |
9452 // latter, disable optimization for the code too. | 9499 // latter, disable optimization for the code too. |
9453 ASSERT(code()->kind() == Code::FUNCTION || code()->kind() == Code::BUILTIN); | 9500 ASSERT(code()->kind() == Code::FUNCTION || code()->kind() == Code::BUILTIN); |
9454 if (code()->kind() == Code::FUNCTION) { | 9501 if (code()->kind() == Code::FUNCTION) { |
9455 code()->set_optimizable(false); | 9502 code()->set_optimizable(false); |
9456 } | 9503 } |
9457 if (FLAG_trace_opt) { | 9504 if (FLAG_trace_opt) { |
9458 PrintF("[disabled optimization for %s, reason: %s]\n", | 9505 PrintF("[disabled optimization for "); |
9459 *DebugName()->ToCString(), reason); | 9506 ShortPrint(); |
| 9507 PrintF(", reason: %s]\n", reason); |
9460 } | 9508 } |
9461 } | 9509 } |
9462 | 9510 |
9463 | 9511 |
9464 bool SharedFunctionInfo::VerifyBailoutId(BailoutId id) { | 9512 bool SharedFunctionInfo::VerifyBailoutId(BailoutId id) { |
9465 ASSERT(!id.IsNone()); | 9513 ASSERT(!id.IsNone()); |
9466 Code* unoptimized = code(); | 9514 Code* unoptimized = code(); |
9467 DeoptimizationOutputData* data = | 9515 DeoptimizationOutputData* data = |
9468 DeoptimizationOutputData::cast(unoptimized->deoptimization_data()); | 9516 DeoptimizationOutputData::cast(unoptimized->deoptimization_data()); |
9469 unsigned ignore = Deoptimizer::GetOutputInfo(data, id, this); | 9517 unsigned ignore = Deoptimizer::GetOutputInfo(data, id, this); |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9604 if (!FLAG_cache_optimized_code) return -1; | 9652 if (!FLAG_cache_optimized_code) return -1; |
9605 Object* value = optimized_code_map(); | 9653 Object* value = optimized_code_map(); |
9606 if (!value->IsSmi()) { | 9654 if (!value->IsSmi()) { |
9607 FixedArray* optimized_code_map = FixedArray::cast(value); | 9655 FixedArray* optimized_code_map = FixedArray::cast(value); |
9608 int length = optimized_code_map->length(); | 9656 int length = optimized_code_map->length(); |
9609 for (int i = 0; i < length; i += 3) { | 9657 for (int i = 0; i < length; i += 3) { |
9610 if (optimized_code_map->get(i) == native_context) { | 9658 if (optimized_code_map->get(i) == native_context) { |
9611 return i + 1; | 9659 return i + 1; |
9612 } | 9660 } |
9613 } | 9661 } |
| 9662 if (FLAG_trace_opt) { |
| 9663 PrintF("[didn't find optimized code in optimized code map for "); |
| 9664 ShortPrint(); |
| 9665 PrintF("]\n"); |
| 9666 } |
9614 } | 9667 } |
9615 return -1; | 9668 return -1; |
9616 } | 9669 } |
9617 | 9670 |
9618 | 9671 |
9619 #define DECLARE_TAG(ignore1, name, ignore2) name, | 9672 #define DECLARE_TAG(ignore1, name, ignore2) name, |
9620 const char* const VisitorSynchronization::kTags[ | 9673 const char* const VisitorSynchronization::kTags[ |
9621 VisitorSynchronization::kNumberOfSyncTags] = { | 9674 VisitorSynchronization::kNumberOfSyncTags] = { |
9622 VISITOR_SYNCHRONIZATION_TAGS_LIST(DECLARE_TAG) | 9675 VISITOR_SYNCHRONIZATION_TAGS_LIST(DECLARE_TAG) |
9623 }; | 9676 }; |
(...skipping 5637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15261 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); | 15314 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); |
15262 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); | 15315 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); |
15263 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); | 15316 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); |
15264 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); | 15317 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); |
15265 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); | 15318 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); |
15266 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); | 15319 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); |
15267 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); | 15320 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); |
15268 } | 15321 } |
15269 | 15322 |
15270 } } // namespace v8::internal | 15323 } } // namespace v8::internal |
OLD | NEW |