| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 // Assert that the given argument has a valid value for a StrictModeFlag | 109 // Assert that the given argument has a valid value for a StrictModeFlag |
| 110 // and store it in a StrictModeFlag variable with the given name. | 110 // and store it in a StrictModeFlag variable with the given name. |
| 111 #define CONVERT_STRICT_MODE_ARG(name, index) \ | 111 #define CONVERT_STRICT_MODE_ARG(name, index) \ |
| 112 ASSERT(args[index]->IsSmi()); \ | 112 ASSERT(args[index]->IsSmi()); \ |
| 113 ASSERT(args.smi_at(index) == kStrictMode || \ | 113 ASSERT(args.smi_at(index) == kStrictMode || \ |
| 114 args.smi_at(index) == kNonStrictMode); \ | 114 args.smi_at(index) == kNonStrictMode); \ |
| 115 StrictModeFlag name = \ | 115 StrictModeFlag name = \ |
| 116 static_cast<StrictModeFlag>(args.smi_at(index)); | 116 static_cast<StrictModeFlag>(args.smi_at(index)); |
| 117 | 117 |
| 118 | 118 |
| 119 // Assert that the given argument has a valid value for a LanguageMode |
| 120 // and store it in a LanguageMode variable with the given name. |
| 121 #define CONVERT_LANGUAGE_MODE_ARG(name, index) \ |
| 122 ASSERT(args[index]->IsSmi()); \ |
| 123 ASSERT(args.smi_at(index) == CLASSIC_MODE || \ |
| 124 args.smi_at(index) == STRICT_MODE || \ |
| 125 args.smi_at(index) == EXTENDED_MODE); \ |
| 126 LanguageMode name = \ |
| 127 static_cast<LanguageMode>(args.smi_at(index)); |
| 128 |
| 129 |
| 119 MUST_USE_RESULT static MaybeObject* DeepCopyBoilerplate(Isolate* isolate, | 130 MUST_USE_RESULT static MaybeObject* DeepCopyBoilerplate(Isolate* isolate, |
| 120 JSObject* boilerplate) { | 131 JSObject* boilerplate) { |
| 121 StackLimitCheck check(isolate); | 132 StackLimitCheck check(isolate); |
| 122 if (check.HasOverflowed()) return isolate->StackOverflow(); | 133 if (check.HasOverflowed()) return isolate->StackOverflow(); |
| 123 | 134 |
| 124 Heap* heap = isolate->heap(); | 135 Heap* heap = isolate->heap(); |
| 125 Object* result; | 136 Object* result; |
| 126 { MaybeObject* maybe_result = heap->CopyJSObject(boilerplate); | 137 { MaybeObject* maybe_result = heap->CopyJSObject(boilerplate); |
| 127 if (!maybe_result->ToObject(&result)) return maybe_result; | 138 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 128 } | 139 } |
| (...skipping 1266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1395 attr |= lookup.GetAttributes() & DONT_DELETE; | 1406 attr |= lookup.GetAttributes() & DONT_DELETE; |
| 1396 } | 1407 } |
| 1397 PropertyAttributes attributes = static_cast<PropertyAttributes>(attr); | 1408 PropertyAttributes attributes = static_cast<PropertyAttributes>(attr); |
| 1398 | 1409 |
| 1399 RETURN_IF_EMPTY_HANDLE(isolate, | 1410 RETURN_IF_EMPTY_HANDLE(isolate, |
| 1400 SetLocalPropertyIgnoreAttributes(global, | 1411 SetLocalPropertyIgnoreAttributes(global, |
| 1401 name, | 1412 name, |
| 1402 value, | 1413 value, |
| 1403 attributes)); | 1414 attributes)); |
| 1404 } else { | 1415 } else { |
| 1405 StrictModeFlag strict_mode = DeclareGlobalsStrictModeFlag::decode(flags); | 1416 LanguageMode language_mode = DeclareGlobalsLanguageMode::decode(flags); |
| 1417 StrictModeFlag strict_mode_flag = (language_mode == CLASSIC_MODE) |
| 1418 ? kNonStrictMode : kStrictMode; |
| 1406 RETURN_IF_EMPTY_HANDLE(isolate, | 1419 RETURN_IF_EMPTY_HANDLE(isolate, |
| 1407 SetProperty(global, | 1420 SetProperty(global, |
| 1408 name, | 1421 name, |
| 1409 value, | 1422 value, |
| 1410 static_cast<PropertyAttributes>(attr), | 1423 static_cast<PropertyAttributes>(attr), |
| 1411 strict_mode)); | 1424 strict_mode_flag)); |
| 1412 } | 1425 } |
| 1413 } | 1426 } |
| 1414 | 1427 |
| 1415 ASSERT(!isolate->has_pending_exception()); | 1428 ASSERT(!isolate->has_pending_exception()); |
| 1416 return isolate->heap()->undefined_value(); | 1429 return isolate->heap()->undefined_value(); |
| 1417 } | 1430 } |
| 1418 | 1431 |
| 1419 | 1432 |
| 1420 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeclareContextSlot) { | 1433 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeclareContextSlot) { |
| 1421 HandleScope scope(isolate); | 1434 HandleScope scope(isolate); |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1507 kNonStrictMode)); | 1520 kNonStrictMode)); |
| 1508 } | 1521 } |
| 1509 | 1522 |
| 1510 return isolate->heap()->undefined_value(); | 1523 return isolate->heap()->undefined_value(); |
| 1511 } | 1524 } |
| 1512 | 1525 |
| 1513 | 1526 |
| 1514 RUNTIME_FUNCTION(MaybeObject*, Runtime_InitializeVarGlobal) { | 1527 RUNTIME_FUNCTION(MaybeObject*, Runtime_InitializeVarGlobal) { |
| 1515 NoHandleAllocation nha; | 1528 NoHandleAllocation nha; |
| 1516 // args[0] == name | 1529 // args[0] == name |
| 1517 // args[1] == strict_mode | 1530 // args[1] == language_mode |
| 1518 // args[2] == value (optional) | 1531 // args[2] == value (optional) |
| 1519 | 1532 |
| 1520 // Determine if we need to assign to the variable if it already | 1533 // Determine if we need to assign to the variable if it already |
| 1521 // exists (based on the number of arguments). | 1534 // exists (based on the number of arguments). |
| 1522 RUNTIME_ASSERT(args.length() == 2 || args.length() == 3); | 1535 RUNTIME_ASSERT(args.length() == 2 || args.length() == 3); |
| 1523 bool assign = args.length() == 3; | 1536 bool assign = args.length() == 3; |
| 1524 | 1537 |
| 1525 CONVERT_ARG_CHECKED(String, name, 0); | 1538 CONVERT_ARG_CHECKED(String, name, 0); |
| 1526 GlobalObject* global = isolate->context()->global(); | 1539 GlobalObject* global = isolate->context()->global(); |
| 1527 RUNTIME_ASSERT(args[1]->IsSmi()); | 1540 RUNTIME_ASSERT(args[1]->IsSmi()); |
| 1528 CONVERT_STRICT_MODE_ARG(strict_mode, 1); | 1541 CONVERT_LANGUAGE_MODE_ARG(language_mode, 1); |
| 1542 StrictModeFlag strict_mode_flag = (language_mode == CLASSIC_MODE) |
| 1543 ? kNonStrictMode : kStrictMode; |
| 1529 | 1544 |
| 1530 // According to ECMA-262, section 12.2, page 62, the property must | 1545 // According to ECMA-262, section 12.2, page 62, the property must |
| 1531 // not be deletable. | 1546 // not be deletable. |
| 1532 PropertyAttributes attributes = DONT_DELETE; | 1547 PropertyAttributes attributes = DONT_DELETE; |
| 1533 | 1548 |
| 1534 // Lookup the property locally in the global object. If it isn't | 1549 // Lookup the property locally in the global object. If it isn't |
| 1535 // there, there is a property with this name in the prototype chain. | 1550 // there, there is a property with this name in the prototype chain. |
| 1536 // We follow Safari and Firefox behavior and only set the property | 1551 // We follow Safari and Firefox behavior and only set the property |
| 1537 // locally if there is an explicit initialization value that we have | 1552 // locally if there is an explicit initialization value that we have |
| 1538 // to assign to the property. | 1553 // to assign to the property. |
| 1539 // Note that objects can have hidden prototypes, so we need to traverse | 1554 // Note that objects can have hidden prototypes, so we need to traverse |
| 1540 // the whole chain of hidden prototypes to do a 'local' lookup. | 1555 // the whole chain of hidden prototypes to do a 'local' lookup. |
| 1541 Object* object = global; | 1556 Object* object = global; |
| 1542 LookupResult lookup(isolate); | 1557 LookupResult lookup(isolate); |
| 1543 while (object->IsJSObject() && | 1558 while (object->IsJSObject() && |
| 1544 JSObject::cast(object)->map()->is_hidden_prototype()) { | 1559 JSObject::cast(object)->map()->is_hidden_prototype()) { |
| 1545 JSObject* raw_holder = JSObject::cast(object); | 1560 JSObject* raw_holder = JSObject::cast(object); |
| 1546 raw_holder->LocalLookup(*name, &lookup); | 1561 raw_holder->LocalLookup(*name, &lookup); |
| 1547 if (lookup.IsProperty() && lookup.type() == INTERCEPTOR) { | 1562 if (lookup.IsProperty() && lookup.type() == INTERCEPTOR) { |
| 1548 HandleScope handle_scope(isolate); | 1563 HandleScope handle_scope(isolate); |
| 1549 Handle<JSObject> holder(raw_holder); | 1564 Handle<JSObject> holder(raw_holder); |
| 1550 PropertyAttributes intercepted = holder->GetPropertyAttribute(*name); | 1565 PropertyAttributes intercepted = holder->GetPropertyAttribute(*name); |
| 1551 // Update the raw pointer in case it's changed due to GC. | 1566 // Update the raw pointer in case it's changed due to GC. |
| 1552 raw_holder = *holder; | 1567 raw_holder = *holder; |
| 1553 if (intercepted != ABSENT && (intercepted & READ_ONLY) == 0) { | 1568 if (intercepted != ABSENT && (intercepted & READ_ONLY) == 0) { |
| 1554 // Found an interceptor that's not read only. | 1569 // Found an interceptor that's not read only. |
| 1555 if (assign) { | 1570 if (assign) { |
| 1556 return raw_holder->SetProperty( | 1571 return raw_holder->SetProperty( |
| 1557 &lookup, *name, args[2], attributes, strict_mode); | 1572 &lookup, *name, args[2], attributes, strict_mode_flag); |
| 1558 } else { | 1573 } else { |
| 1559 return isolate->heap()->undefined_value(); | 1574 return isolate->heap()->undefined_value(); |
| 1560 } | 1575 } |
| 1561 } | 1576 } |
| 1562 } | 1577 } |
| 1563 object = raw_holder->GetPrototype(); | 1578 object = raw_holder->GetPrototype(); |
| 1564 } | 1579 } |
| 1565 | 1580 |
| 1566 // Reload global in case the loop above performed a GC. | 1581 // Reload global in case the loop above performed a GC. |
| 1567 global = isolate->context()->global(); | 1582 global = isolate->context()->global(); |
| 1568 if (assign) { | 1583 if (assign) { |
| 1569 return global->SetProperty(*name, args[2], attributes, strict_mode); | 1584 return global->SetProperty(*name, args[2], attributes, strict_mode_flag); |
| 1570 } | 1585 } |
| 1571 return isolate->heap()->undefined_value(); | 1586 return isolate->heap()->undefined_value(); |
| 1572 } | 1587 } |
| 1573 | 1588 |
| 1574 | 1589 |
| 1575 RUNTIME_FUNCTION(MaybeObject*, Runtime_InitializeConstGlobal) { | 1590 RUNTIME_FUNCTION(MaybeObject*, Runtime_InitializeConstGlobal) { |
| 1576 // All constants are declared with an initial value. The name | 1591 // All constants are declared with an initial value. The name |
| 1577 // of the constant is the first argument and the initial value | 1592 // of the constant is the first argument and the initial value |
| 1578 // is the second. | 1593 // is the second. |
| 1579 RUNTIME_ASSERT(args.length() == 2); | 1594 RUNTIME_ASSERT(args.length() == 2); |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1926 | 1941 |
| 1927 return *holder; | 1942 return *holder; |
| 1928 } | 1943 } |
| 1929 | 1944 |
| 1930 | 1945 |
| 1931 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetDefaultReceiver) { | 1946 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetDefaultReceiver) { |
| 1932 NoHandleAllocation handle_free; | 1947 NoHandleAllocation handle_free; |
| 1933 ASSERT(args.length() == 1); | 1948 ASSERT(args.length() == 1); |
| 1934 CONVERT_CHECKED(JSFunction, function, args[0]); | 1949 CONVERT_CHECKED(JSFunction, function, args[0]); |
| 1935 SharedFunctionInfo* shared = function->shared(); | 1950 SharedFunctionInfo* shared = function->shared(); |
| 1936 if (shared->native() || shared->strict_mode()) { | 1951 if (shared->native() || !shared->is_classic_mode()) { |
| 1937 return isolate->heap()->undefined_value(); | 1952 return isolate->heap()->undefined_value(); |
| 1938 } | 1953 } |
| 1939 // Returns undefined for strict or native functions, or | 1954 // Returns undefined for strict or native functions, or |
| 1940 // the associated global receiver for "normal" functions. | 1955 // the associated global receiver for "normal" functions. |
| 1941 | 1956 |
| 1942 Context* global_context = | 1957 Context* global_context = |
| 1943 function->context()->global()->global_context(); | 1958 function->context()->global()->global_context(); |
| 1944 return global_context->global()->global_receiver(); | 1959 return global_context->global()->global_receiver(); |
| 1945 } | 1960 } |
| 1946 | 1961 |
| (...skipping 2802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4749 SetLocalPropertyIgnoreAttributes(name, args[2], attributes); | 4764 SetLocalPropertyIgnoreAttributes(name, args[2], attributes); |
| 4750 } | 4765 } |
| 4751 | 4766 |
| 4752 | 4767 |
| 4753 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeleteProperty) { | 4768 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeleteProperty) { |
| 4754 NoHandleAllocation ha; | 4769 NoHandleAllocation ha; |
| 4755 ASSERT(args.length() == 3); | 4770 ASSERT(args.length() == 3); |
| 4756 | 4771 |
| 4757 CONVERT_CHECKED(JSReceiver, object, args[0]); | 4772 CONVERT_CHECKED(JSReceiver, object, args[0]); |
| 4758 CONVERT_CHECKED(String, key, args[1]); | 4773 CONVERT_CHECKED(String, key, args[1]); |
| 4759 CONVERT_SMI_ARG_CHECKED(strict, 2); | 4774 CONVERT_STRICT_MODE_ARG(strict_mode, 2); |
| 4760 return object->DeleteProperty(key, (strict == kStrictMode) | 4775 return object->DeleteProperty(key, (strict_mode == kStrictMode) |
| 4761 ? JSReceiver::STRICT_DELETION | 4776 ? JSReceiver::STRICT_DELETION |
| 4762 : JSReceiver::NORMAL_DELETION); | 4777 : JSReceiver::NORMAL_DELETION); |
| 4763 } | 4778 } |
| 4764 | 4779 |
| 4765 | 4780 |
| 4766 static Object* HasLocalPropertyImplementation(Isolate* isolate, | 4781 static Object* HasLocalPropertyImplementation(Isolate* isolate, |
| 4767 Handle<JSObject> object, | 4782 Handle<JSObject> object, |
| 4768 Handle<String> key) { | 4783 Handle<String> key) { |
| 4769 if (object->HasLocalProperty(*key)) return isolate->heap()->true_value(); | 4784 if (object->HasLocalProperty(*key)) return isolate->heap()->true_value(); |
| 4770 // Handle hidden prototypes. If there's a hidden prototype above this thing | 4785 // Handle hidden prototypes. If there's a hidden prototype above this thing |
| (...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5176 } else { | 5191 } else { |
| 5177 return isolate->initial_object_prototype()->GetElement(index); | 5192 return isolate->initial_object_prototype()->GetElement(index); |
| 5178 } | 5193 } |
| 5179 } | 5194 } |
| 5180 | 5195 |
| 5181 // Handle special arguments properties. | 5196 // Handle special arguments properties. |
| 5182 if (key->Equals(isolate->heap()->length_symbol())) return Smi::FromInt(n); | 5197 if (key->Equals(isolate->heap()->length_symbol())) return Smi::FromInt(n); |
| 5183 if (key->Equals(isolate->heap()->callee_symbol())) { | 5198 if (key->Equals(isolate->heap()->callee_symbol())) { |
| 5184 Object* function = frame->function(); | 5199 Object* function = frame->function(); |
| 5185 if (function->IsJSFunction() && | 5200 if (function->IsJSFunction() && |
| 5186 JSFunction::cast(function)->shared()->strict_mode()) { | 5201 !JSFunction::cast(function)->shared()->is_classic_mode()) { |
| 5187 return isolate->Throw(*isolate->factory()->NewTypeError( | 5202 return isolate->Throw(*isolate->factory()->NewTypeError( |
| 5188 "strict_arguments_callee", HandleVector<Object>(NULL, 0))); | 5203 "strict_arguments_callee", HandleVector<Object>(NULL, 0))); |
| 5189 } | 5204 } |
| 5190 return function; | 5205 return function; |
| 5191 } | 5206 } |
| 5192 | 5207 |
| 5193 // Lookup in the initial Object.prototype object. | 5208 // Lookup in the initial Object.prototype object. |
| 5194 return isolate->initial_object_prototype()->GetProperty(*key); | 5209 return isolate->initial_object_prototype()->GetProperty(*key); |
| 5195 } | 5210 } |
| 5196 | 5211 |
| (...skipping 3906 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9103 } | 9118 } |
| 9104 | 9119 |
| 9105 | 9120 |
| 9106 RUNTIME_FUNCTION(MaybeObject*, Runtime_StoreContextSlot) { | 9121 RUNTIME_FUNCTION(MaybeObject*, Runtime_StoreContextSlot) { |
| 9107 HandleScope scope(isolate); | 9122 HandleScope scope(isolate); |
| 9108 ASSERT(args.length() == 4); | 9123 ASSERT(args.length() == 4); |
| 9109 | 9124 |
| 9110 Handle<Object> value(args[0], isolate); | 9125 Handle<Object> value(args[0], isolate); |
| 9111 CONVERT_ARG_CHECKED(Context, context, 1); | 9126 CONVERT_ARG_CHECKED(Context, context, 1); |
| 9112 CONVERT_ARG_CHECKED(String, name, 2); | 9127 CONVERT_ARG_CHECKED(String, name, 2); |
| 9113 CONVERT_STRICT_MODE_ARG(strict_mode, 3); | 9128 CONVERT_LANGUAGE_MODE_ARG(language_mode, 3); |
| 9129 StrictModeFlag strict_mode = (language_mode == CLASSIC_MODE) |
| 9130 ? kNonStrictMode : kStrictMode; |
| 9114 | 9131 |
| 9115 int index; | 9132 int index; |
| 9116 PropertyAttributes attributes; | 9133 PropertyAttributes attributes; |
| 9117 ContextLookupFlags flags = FOLLOW_CHAINS; | 9134 ContextLookupFlags flags = FOLLOW_CHAINS; |
| 9118 BindingFlags binding_flags; | 9135 BindingFlags binding_flags; |
| 9119 Handle<Object> holder = context->Lookup(name, | 9136 Handle<Object> holder = context->Lookup(name, |
| 9120 flags, | 9137 flags, |
| 9121 &index, | 9138 &index, |
| 9122 &attributes, | 9139 &attributes, |
| 9123 &binding_flags); | 9140 &binding_flags); |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9471 | 9488 |
| 9472 // Check if global context allows code generation from | 9489 // Check if global context allows code generation from |
| 9473 // strings. Throw an exception if it doesn't. | 9490 // strings. Throw an exception if it doesn't. |
| 9474 if (!CodeGenerationFromStringsAllowed(isolate, context)) { | 9491 if (!CodeGenerationFromStringsAllowed(isolate, context)) { |
| 9475 return isolate->Throw(*isolate->factory()->NewError( | 9492 return isolate->Throw(*isolate->factory()->NewError( |
| 9476 "code_gen_from_strings", HandleVector<Object>(NULL, 0))); | 9493 "code_gen_from_strings", HandleVector<Object>(NULL, 0))); |
| 9477 } | 9494 } |
| 9478 | 9495 |
| 9479 // Compile source string in the global context. | 9496 // Compile source string in the global context. |
| 9480 Handle<SharedFunctionInfo> shared = Compiler::CompileEval( | 9497 Handle<SharedFunctionInfo> shared = Compiler::CompileEval( |
| 9481 source, context, true, kNonStrictMode, RelocInfo::kNoPosition); | 9498 source, context, true, CLASSIC_MODE, RelocInfo::kNoPosition); |
| 9482 if (shared.is_null()) return Failure::Exception(); | 9499 if (shared.is_null()) return Failure::Exception(); |
| 9483 Handle<JSFunction> fun = | 9500 Handle<JSFunction> fun = |
| 9484 isolate->factory()->NewFunctionFromSharedFunctionInfo(shared, | 9501 isolate->factory()->NewFunctionFromSharedFunctionInfo(shared, |
| 9485 context, | 9502 context, |
| 9486 NOT_TENURED); | 9503 NOT_TENURED); |
| 9487 return *fun; | 9504 return *fun; |
| 9488 } | 9505 } |
| 9489 | 9506 |
| 9490 | 9507 |
| 9491 static ObjectPair CompileGlobalEval(Isolate* isolate, | 9508 static ObjectPair CompileGlobalEval(Isolate* isolate, |
| 9492 Handle<String> source, | 9509 Handle<String> source, |
| 9493 Handle<Object> receiver, | 9510 Handle<Object> receiver, |
| 9494 StrictModeFlag strict_mode, | 9511 LanguageMode language_mode, |
| 9495 int scope_position) { | 9512 int scope_position) { |
| 9496 Handle<Context> context = Handle<Context>(isolate->context()); | 9513 Handle<Context> context = Handle<Context>(isolate->context()); |
| 9497 Handle<Context> global_context = Handle<Context>(context->global_context()); | 9514 Handle<Context> global_context = Handle<Context>(context->global_context()); |
| 9498 | 9515 |
| 9499 // Check if global context allows code generation from | 9516 // Check if global context allows code generation from |
| 9500 // strings. Throw an exception if it doesn't. | 9517 // strings. Throw an exception if it doesn't. |
| 9501 if (!CodeGenerationFromStringsAllowed(isolate, global_context)) { | 9518 if (!CodeGenerationFromStringsAllowed(isolate, global_context)) { |
| 9502 isolate->Throw(*isolate->factory()->NewError( | 9519 isolate->Throw(*isolate->factory()->NewError( |
| 9503 "code_gen_from_strings", HandleVector<Object>(NULL, 0))); | 9520 "code_gen_from_strings", HandleVector<Object>(NULL, 0))); |
| 9504 return MakePair(Failure::Exception(), NULL); | 9521 return MakePair(Failure::Exception(), NULL); |
| 9505 } | 9522 } |
| 9506 | 9523 |
| 9507 // Deal with a normal eval call with a string argument. Compile it | 9524 // Deal with a normal eval call with a string argument. Compile it |
| 9508 // and return the compiled function bound in the local context. | 9525 // and return the compiled function bound in the local context. |
| 9509 Handle<SharedFunctionInfo> shared = Compiler::CompileEval( | 9526 Handle<SharedFunctionInfo> shared = Compiler::CompileEval( |
| 9510 source, | 9527 source, |
| 9511 Handle<Context>(isolate->context()), | 9528 Handle<Context>(isolate->context()), |
| 9512 context->IsGlobalContext(), | 9529 context->IsGlobalContext(), |
| 9513 strict_mode, | 9530 language_mode, |
| 9514 scope_position); | 9531 scope_position); |
| 9515 if (shared.is_null()) return MakePair(Failure::Exception(), NULL); | 9532 if (shared.is_null()) return MakePair(Failure::Exception(), NULL); |
| 9516 Handle<JSFunction> compiled = | 9533 Handle<JSFunction> compiled = |
| 9517 isolate->factory()->NewFunctionFromSharedFunctionInfo( | 9534 isolate->factory()->NewFunctionFromSharedFunctionInfo( |
| 9518 shared, context, NOT_TENURED); | 9535 shared, context, NOT_TENURED); |
| 9519 return MakePair(*compiled, *receiver); | 9536 return MakePair(*compiled, *receiver); |
| 9520 } | 9537 } |
| 9521 | 9538 |
| 9522 | 9539 |
| 9523 RUNTIME_FUNCTION(ObjectPair, Runtime_ResolvePossiblyDirectEval) { | 9540 RUNTIME_FUNCTION(ObjectPair, Runtime_ResolvePossiblyDirectEval) { |
| 9524 ASSERT(args.length() == 5); | 9541 ASSERT(args.length() == 5); |
| 9525 | 9542 |
| 9526 HandleScope scope(isolate); | 9543 HandleScope scope(isolate); |
| 9527 Handle<Object> callee = args.at<Object>(0); | 9544 Handle<Object> callee = args.at<Object>(0); |
| 9528 | 9545 |
| 9529 // If "eval" didn't refer to the original GlobalEval, it's not a | 9546 // If "eval" didn't refer to the original GlobalEval, it's not a |
| 9530 // direct call to eval. | 9547 // direct call to eval. |
| 9531 // (And even if it is, but the first argument isn't a string, just let | 9548 // (And even if it is, but the first argument isn't a string, just let |
| 9532 // execution default to an indirect call to eval, which will also return | 9549 // execution default to an indirect call to eval, which will also return |
| 9533 // the first argument without doing anything). | 9550 // the first argument without doing anything). |
| 9534 if (*callee != isolate->global_context()->global_eval_fun() || | 9551 if (*callee != isolate->global_context()->global_eval_fun() || |
| 9535 !args[1]->IsString()) { | 9552 !args[1]->IsString()) { |
| 9536 return MakePair(*callee, isolate->heap()->the_hole_value()); | 9553 return MakePair(*callee, isolate->heap()->the_hole_value()); |
| 9537 } | 9554 } |
| 9538 | 9555 |
| 9539 CONVERT_STRICT_MODE_ARG(strict_mode, 3); | 9556 CONVERT_LANGUAGE_MODE_ARG(language_mode, 3); |
| 9540 ASSERT(args[4]->IsSmi()); | 9557 ASSERT(args[4]->IsSmi()); |
| 9541 return CompileGlobalEval(isolate, | 9558 return CompileGlobalEval(isolate, |
| 9542 args.at<String>(1), | 9559 args.at<String>(1), |
| 9543 args.at<Object>(2), | 9560 args.at<Object>(2), |
| 9544 strict_mode, | 9561 language_mode, |
| 9545 args.smi_at(4)); | 9562 args.smi_at(4)); |
| 9546 } | 9563 } |
| 9547 | 9564 |
| 9548 | 9565 |
| 9549 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetNewFunctionAttributes) { | 9566 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetNewFunctionAttributes) { |
| 9550 // This utility adjusts the property attributes for newly created Function | 9567 // This utility adjusts the property attributes for newly created Function |
| 9551 // object ("new Function(...)") by changing the map. | 9568 // object ("new Function(...)") by changing the map. |
| 9552 // All it does is changing the prototype property to enumerable | 9569 // All it does is changing the prototype property to enumerable |
| 9553 // as specified in ECMA262, 15.3.5.2. | 9570 // as specified in ECMA262, 15.3.5.2. |
| 9554 HandleScope scope(isolate); | 9571 HandleScope scope(isolate); |
| 9555 ASSERT(args.length() == 1); | 9572 ASSERT(args.length() == 1); |
| 9556 CONVERT_ARG_CHECKED(JSFunction, func, 0); | 9573 CONVERT_ARG_CHECKED(JSFunction, func, 0); |
| 9557 | 9574 |
| 9558 Handle<Map> map = func->shared()->strict_mode() | 9575 Handle<Map> map = func->shared()->is_classic_mode() |
| 9559 ? isolate->strict_mode_function_instance_map() | 9576 ? isolate->function_instance_map() |
| 9560 : isolate->function_instance_map(); | 9577 : isolate->strict_mode_function_instance_map(); |
| 9561 | 9578 |
| 9562 ASSERT(func->map()->instance_type() == map->instance_type()); | 9579 ASSERT(func->map()->instance_type() == map->instance_type()); |
| 9563 ASSERT(func->map()->instance_size() == map->instance_size()); | 9580 ASSERT(func->map()->instance_size() == map->instance_size()); |
| 9564 func->set_map(*map); | 9581 func->set_map(*map); |
| 9565 return *func; | 9582 return *func; |
| 9566 } | 9583 } |
| 9567 | 9584 |
| 9568 | 9585 |
| 9569 RUNTIME_FUNCTION(MaybeObject*, Runtime_AllocateInNewSpace) { | 9586 RUNTIME_FUNCTION(MaybeObject*, Runtime_AllocateInNewSpace) { |
| 9570 // Allocate a block of memory in NewSpace (filled with a filler). | 9587 // Allocate a block of memory in NewSpace (filled with a filler). |
| (...skipping 1439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11010 | 11027 |
| 11011 // Add the value being returned. | 11028 // Add the value being returned. |
| 11012 if (at_return) { | 11029 if (at_return) { |
| 11013 details->set(details_index++, *return_value); | 11030 details->set(details_index++, *return_value); |
| 11014 } | 11031 } |
| 11015 | 11032 |
| 11016 // Add the receiver (same as in function frame). | 11033 // Add the receiver (same as in function frame). |
| 11017 // THIS MUST BE DONE LAST SINCE WE MIGHT ADVANCE | 11034 // THIS MUST BE DONE LAST SINCE WE MIGHT ADVANCE |
| 11018 // THE FRAME ITERATOR TO WRAP THE RECEIVER. | 11035 // THE FRAME ITERATOR TO WRAP THE RECEIVER. |
| 11019 Handle<Object> receiver(it.frame()->receiver(), isolate); | 11036 Handle<Object> receiver(it.frame()->receiver(), isolate); |
| 11020 if (!receiver->IsJSObject() && !shared->strict_mode() && !shared->native()) { | 11037 if (!receiver->IsJSObject() && |
| 11038 shared->is_classic_mode() && |
| 11039 !shared->native()) { |
| 11021 // If the receiver is not a JSObject and the function is not a | 11040 // If the receiver is not a JSObject and the function is not a |
| 11022 // builtin or strict-mode we have hit an optimization where a | 11041 // builtin or strict-mode we have hit an optimization where a |
| 11023 // value object is not converted into a wrapped JS objects. To | 11042 // value object is not converted into a wrapped JS objects. To |
| 11024 // hide this optimization from the debugger, we wrap the receiver | 11043 // hide this optimization from the debugger, we wrap the receiver |
| 11025 // by creating correct wrapper object based on the calling frame's | 11044 // by creating correct wrapper object based on the calling frame's |
| 11026 // global context. | 11045 // global context. |
| 11027 it.Advance(); | 11046 it.Advance(); |
| 11028 Handle<Context> calling_frames_global_context( | 11047 Handle<Context> calling_frames_global_context( |
| 11029 Context::cast(Context::cast(it.frame()->context())->global_context())); | 11048 Context::cast(Context::cast(it.frame()->context())->global_context())); |
| 11030 receiver = | 11049 receiver = |
| (...skipping 1118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12149 Handle<String> function_source = | 12168 Handle<String> function_source = |
| 12150 isolate->factory()->NewStringFromAscii( | 12169 isolate->factory()->NewStringFromAscii( |
| 12151 Vector<const char>(kSourceStr, sizeof(kSourceStr) - 1)); | 12170 Vector<const char>(kSourceStr, sizeof(kSourceStr) - 1)); |
| 12152 | 12171 |
| 12153 // Currently, the eval code will be executed in non-strict mode, | 12172 // Currently, the eval code will be executed in non-strict mode, |
| 12154 // even in the strict code context. | 12173 // even in the strict code context. |
| 12155 Handle<SharedFunctionInfo> shared = | 12174 Handle<SharedFunctionInfo> shared = |
| 12156 Compiler::CompileEval(function_source, | 12175 Compiler::CompileEval(function_source, |
| 12157 context, | 12176 context, |
| 12158 context->IsGlobalContext(), | 12177 context->IsGlobalContext(), |
| 12159 kNonStrictMode, | 12178 CLASSIC_MODE, |
| 12160 RelocInfo::kNoPosition); | 12179 RelocInfo::kNoPosition); |
| 12161 if (shared.is_null()) return Failure::Exception(); | 12180 if (shared.is_null()) return Failure::Exception(); |
| 12162 Handle<JSFunction> compiled_function = | 12181 Handle<JSFunction> compiled_function = |
| 12163 isolate->factory()->NewFunctionFromSharedFunctionInfo(shared, context); | 12182 isolate->factory()->NewFunctionFromSharedFunctionInfo(shared, context); |
| 12164 | 12183 |
| 12165 // Invoke the result of the compilation to get the evaluation function. | 12184 // Invoke the result of the compilation to get the evaluation function. |
| 12166 bool has_pending_exception; | 12185 bool has_pending_exception; |
| 12167 Handle<Object> receiver(frame->receiver(), isolate); | 12186 Handle<Object> receiver(frame->receiver(), isolate); |
| 12168 Handle<Object> evaluation_function = | 12187 Handle<Object> evaluation_function = |
| 12169 Execution::Call(compiled_function, receiver, 0, NULL, | 12188 Execution::Call(compiled_function, receiver, 0, NULL, |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12246 is_global = false; | 12265 is_global = false; |
| 12247 } | 12266 } |
| 12248 | 12267 |
| 12249 // Compile the source to be evaluated. | 12268 // Compile the source to be evaluated. |
| 12250 // Currently, the eval code will be executed in non-strict mode, | 12269 // Currently, the eval code will be executed in non-strict mode, |
| 12251 // even in the strict code context. | 12270 // even in the strict code context. |
| 12252 Handle<SharedFunctionInfo> shared = | 12271 Handle<SharedFunctionInfo> shared = |
| 12253 Compiler::CompileEval(source, | 12272 Compiler::CompileEval(source, |
| 12254 context, | 12273 context, |
| 12255 is_global, | 12274 is_global, |
| 12256 kNonStrictMode, | 12275 CLASSIC_MODE, |
| 12257 RelocInfo::kNoPosition); | 12276 RelocInfo::kNoPosition); |
| 12258 if (shared.is_null()) return Failure::Exception(); | 12277 if (shared.is_null()) return Failure::Exception(); |
| 12259 Handle<JSFunction> compiled_function = | 12278 Handle<JSFunction> compiled_function = |
| 12260 Handle<JSFunction>( | 12279 Handle<JSFunction>( |
| 12261 isolate->factory()->NewFunctionFromSharedFunctionInfo(shared, | 12280 isolate->factory()->NewFunctionFromSharedFunctionInfo(shared, |
| 12262 context)); | 12281 context)); |
| 12263 | 12282 |
| 12264 // Invoke the result of the compilation to get the evaluation function. | 12283 // Invoke the result of the compilation to get the evaluation function. |
| 12265 bool has_pending_exception; | 12284 bool has_pending_exception; |
| 12266 Handle<Object> receiver = isolate->global(); | 12285 Handle<Object> receiver = isolate->global(); |
| (...skipping 1316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13583 } else { | 13602 } else { |
| 13584 // Handle last resort GC and make sure to allow future allocations | 13603 // Handle last resort GC and make sure to allow future allocations |
| 13585 // to grow the heap without causing GCs (if possible). | 13604 // to grow the heap without causing GCs (if possible). |
| 13586 isolate->counters()->gc_last_resort_from_js()->Increment(); | 13605 isolate->counters()->gc_last_resort_from_js()->Increment(); |
| 13587 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); | 13606 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); |
| 13588 } | 13607 } |
| 13589 } | 13608 } |
| 13590 | 13609 |
| 13591 | 13610 |
| 13592 } } // namespace v8::internal | 13611 } } // namespace v8::internal |
| OLD | NEW |